new add ios support
This commit is contained in:
@@ -1,7 +1,199 @@
|
||||
import 'package:flutter/services.dart';
|
||||
import 'dart:convert';
|
||||
|
||||
class GroupManager{
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_openim_sdk/src/models/group_info.dart';
|
||||
|
||||
class GroupManager {
|
||||
MethodChannel _channel;
|
||||
|
||||
GroupManager(this._channel);
|
||||
}
|
||||
|
||||
Future<List<GroupInviteResult>> inviteUserToGroup({
|
||||
required String groupId,
|
||||
required List<String> uidList,
|
||||
String? reason,
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
'inviteUserToGroup',
|
||||
_buildParam({
|
||||
'gid': groupId,
|
||||
'reason': reason,
|
||||
'uidList': uidList,
|
||||
}))
|
||||
.then((value) => _formatJson(value)
|
||||
.map((e) => GroupInviteResult.fromJson(e))
|
||||
.toList());
|
||||
}
|
||||
|
||||
Future<List<GroupInviteResult>> kickGroupMember({
|
||||
required String groupId,
|
||||
required List<String> uidList,
|
||||
String? reason,
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
'kickGroupMember',
|
||||
_buildParam({
|
||||
'gid': groupId,
|
||||
'reason': reason,
|
||||
'uidList': uidList,
|
||||
}))
|
||||
.then((value) => _formatJson(value)
|
||||
.map((e) => GroupInviteResult.fromJson(e))
|
||||
.toList());
|
||||
}
|
||||
|
||||
Future<List<GroupMembersInfo>> getGroupMembersInfo({
|
||||
required String groupId,
|
||||
required List<String> uidList,
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
'getGroupMembersInfo',
|
||||
_buildParam({
|
||||
'gid': groupId,
|
||||
'uidList': uidList,
|
||||
}))
|
||||
.then((value) => _formatJson(value)
|
||||
.map((e) => GroupMembersInfo.fromJson(e))
|
||||
.toList());
|
||||
}
|
||||
|
||||
///filter 0: all user, 1: group owner, 2: administrator
|
||||
///begin index, pull and fill 0 for the first time
|
||||
Future<GroupMembersList> getGroupMemberList({
|
||||
required String groupId,
|
||||
required int filter,
|
||||
required int next,
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
'getGroupMemberList',
|
||||
_buildParam({
|
||||
'gid': groupId,
|
||||
'filter': filter,
|
||||
'next': next,
|
||||
}))
|
||||
.then((value) => GroupMembersList.fromJson(_formatJson(value)));
|
||||
}
|
||||
|
||||
Future<List<GroupInfo>> getJoinedGroupList() {
|
||||
return _channel.invokeMethod('getJoinedGroupList', _buildParam({})).then(
|
||||
(value) =>
|
||||
_formatJson(value).map((e) => GroupInfo.fromJson(e)).toList());
|
||||
}
|
||||
|
||||
Future<String> createGroup({
|
||||
required GroupInfo groupInfo,
|
||||
required List<GroupMemberRole> list,
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
'createGroup',
|
||||
_buildParam({
|
||||
'gInfo': groupInfo.toJson(),
|
||||
'memberList': list.map((e) => e.toJson()).toList()
|
||||
}))
|
||||
.then((value) => _formatJson(value)['groupID']);
|
||||
}
|
||||
|
||||
Future<dynamic> setGroupInfo({
|
||||
required GroupInfo groupInfo,
|
||||
}) {
|
||||
return _channel.invokeMethod(
|
||||
'setGroupInfo',
|
||||
_buildParam({
|
||||
'gInfo': groupInfo.toJson(),
|
||||
}));
|
||||
}
|
||||
|
||||
Future<List<GroupInfo>> getGroupsInfo({
|
||||
required List<String> gidList,
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod('getGroupsInfo', _buildParam({'gidList': gidList}))
|
||||
.then((value) =>
|
||||
_formatJson(value).map((e) => GroupInfo.fromJson(e)).toList());
|
||||
}
|
||||
|
||||
Future<dynamic> joinGroup({
|
||||
required String gid,
|
||||
required String reason,
|
||||
}) {
|
||||
return _channel.invokeMethod(
|
||||
'joinGroup',
|
||||
_buildParam({
|
||||
'gid': gid,
|
||||
'reason': reason,
|
||||
}));
|
||||
}
|
||||
|
||||
Future<dynamic> quitGroup({
|
||||
required String gid,
|
||||
}) {
|
||||
return _channel.invokeMethod(
|
||||
'quitGroup',
|
||||
_buildParam({
|
||||
'gid': gid,
|
||||
}));
|
||||
}
|
||||
|
||||
Future<dynamic> transferGroupOwner({
|
||||
required String gid,
|
||||
required String uid,
|
||||
}) {
|
||||
return _channel.invokeMethod(
|
||||
'transferGroupOwner',
|
||||
_buildParam({
|
||||
'gid': gid,
|
||||
'uid': uid,
|
||||
}));
|
||||
}
|
||||
|
||||
Future<GroupApplicationList> getGroupApplicationList({
|
||||
required String gid,
|
||||
required String uid,
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod('getGroupApplicationList', _buildParam({}))
|
||||
.then((value) => GroupApplicationList.fromJson(_formatJson(value)));
|
||||
}
|
||||
|
||||
Future<dynamic> acceptGroupApplication({
|
||||
required GroupApplicationInfo info,
|
||||
required String reason,
|
||||
}) {
|
||||
return _channel.invokeMethod(
|
||||
'acceptGroupApplication',
|
||||
_buildParam({
|
||||
'application': info.toJson(),
|
||||
'reason': reason,
|
||||
}));
|
||||
}
|
||||
|
||||
Future<dynamic> refuseGroupApplication({
|
||||
required GroupApplicationInfo info,
|
||||
required String reason,
|
||||
}) {
|
||||
return _channel.invokeMethod(
|
||||
'refuseGroupApplication',
|
||||
_buildParam({
|
||||
'application': info.toJson(),
|
||||
'reason': reason,
|
||||
}));
|
||||
}
|
||||
|
||||
static Map _buildParam(Map param) {
|
||||
param["ManagerName"] = "groupManager";
|
||||
return param;
|
||||
}
|
||||
|
||||
static dynamic _formatJson(value) {
|
||||
return jsonDecode(_printValue(value));
|
||||
}
|
||||
|
||||
static String _printValue(value) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
226
lib/src/models/group_info.dart
Normal file
226
lib/src/models/group_info.dart
Normal file
@@ -0,0 +1,226 @@
|
||||
class GroupInfo {
|
||||
String? groupID;
|
||||
String? groupName;
|
||||
String? notification;
|
||||
String? introduction;
|
||||
String? faceUrl;
|
||||
String? ownerId;
|
||||
int? createTime;
|
||||
int? memberCount;
|
||||
|
||||
GroupInfo(
|
||||
{this.groupID,
|
||||
this.groupName,
|
||||
this.notification,
|
||||
this.introduction,
|
||||
this.faceUrl,
|
||||
this.ownerId,
|
||||
this.createTime,
|
||||
this.memberCount});
|
||||
|
||||
GroupInfo.fromJson(Map<String, dynamic> json) {
|
||||
groupID = json['groupID'];
|
||||
groupName = json['groupName'];
|
||||
notification = json['notification'];
|
||||
introduction = json['introduction'];
|
||||
faceUrl = json['faceUrl'];
|
||||
ownerId = json['ownerId'];
|
||||
createTime = json['createTime'];
|
||||
memberCount = json['memberCount'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['groupID'] = this.groupID;
|
||||
data['groupName'] = this.groupName;
|
||||
data['notification'] = this.notification;
|
||||
data['introduction'] = this.introduction;
|
||||
data['faceUrl'] = this.faceUrl;
|
||||
data['ownerId'] = this.ownerId;
|
||||
data['createTime'] = this.createTime;
|
||||
data['memberCount'] = this.memberCount;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class GroupMembersList {
|
||||
int? nextSeq;
|
||||
List<GroupMembersInfo>? data;
|
||||
|
||||
GroupMembersList({this.nextSeq, this.data});
|
||||
|
||||
GroupMembersList.fromJson(Map<String, dynamic> json) {
|
||||
nextSeq = json['nextSeq'];
|
||||
if (json['data'] is List) {
|
||||
data = (json['data'] as List)
|
||||
.map((e) => GroupMembersInfo.fromJson(e))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['nextSeq'] = this.nextSeq;
|
||||
if (this.data != null) {
|
||||
data['data'] = this.data!.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class GroupMembersInfo {
|
||||
String? groupID;
|
||||
String? userId;
|
||||
int? role;
|
||||
int? joinTime;
|
||||
String? nickName;
|
||||
String? faceUrl;
|
||||
|
||||
GroupMembersInfo(
|
||||
{this.groupID,
|
||||
this.userId,
|
||||
this.role,
|
||||
this.joinTime,
|
||||
this.nickName,
|
||||
this.faceUrl});
|
||||
|
||||
GroupMembersInfo.fromJson(Map<String, dynamic> json) {
|
||||
groupID = json['groupID'];
|
||||
userId = json['userId'];
|
||||
role = json['role'];
|
||||
joinTime = json['joinTime'];
|
||||
nickName = json['nickName'];
|
||||
faceUrl = json['faceUrl'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['groupID'] = this.groupID;
|
||||
data['userId'] = this.userId;
|
||||
data['role'] = this.role;
|
||||
data['joinTime'] = this.joinTime;
|
||||
data['nickName'] = this.nickName;
|
||||
data['faceUrl'] = this.faceUrl;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class GroupInviteResult {
|
||||
String? uid;
|
||||
int? result;
|
||||
|
||||
GroupInviteResult({this.uid, this.result});
|
||||
|
||||
GroupInviteResult.fromJson(Map<String, dynamic> json) {
|
||||
uid = json['uid'];
|
||||
result = json['result'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['uid'] = this.uid;
|
||||
data['result'] = this.result;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class GroupMemberRole {
|
||||
String? uid;
|
||||
int? setRole; //0普通成员,2管理员
|
||||
|
||||
GroupMemberRole({this.uid, this.setRole});
|
||||
|
||||
GroupMemberRole.fromJson(Map<String, dynamic> json) {
|
||||
uid = json['uid'];
|
||||
setRole = json['setRole'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['uid'] = this.uid;
|
||||
data['setRole'] = this.setRole;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class GroupApplicationInfo {
|
||||
String? groupID;
|
||||
String? fromUserID;
|
||||
String? fromUserNickName;
|
||||
String? fromUserFaceUrl;
|
||||
String? toUserID;
|
||||
int? addTime;
|
||||
String? requestMsg;
|
||||
String? handledMsg;
|
||||
int? type;
|
||||
int? handleStatus;
|
||||
int? handleResult;
|
||||
|
||||
GroupApplicationInfo(
|
||||
{this.groupID,
|
||||
this.fromUserID,
|
||||
this.fromUserNickName,
|
||||
this.fromUserFaceUrl,
|
||||
this.toUserID,
|
||||
this.addTime,
|
||||
this.requestMsg,
|
||||
this.handledMsg,
|
||||
this.type,
|
||||
this.handleStatus,
|
||||
this.handleResult});
|
||||
|
||||
GroupApplicationInfo.fromJson(Map<String, dynamic> json) {
|
||||
groupID = json['groupID'];
|
||||
fromUserID = json['fromUserID'];
|
||||
fromUserNickName = json['fromUserNickName'];
|
||||
fromUserFaceUrl = json['fromUserFaceUrl'];
|
||||
toUserID = json['toUserID'];
|
||||
addTime = json['addTime'];
|
||||
requestMsg = json['requestMsg'];
|
||||
handledMsg = json['handledMsg'];
|
||||
type = json['type'];
|
||||
handleStatus = json['handleStatus'];
|
||||
handleResult = json['handleResult'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['groupID'] = this.groupID;
|
||||
data['fromUserID'] = this.fromUserID;
|
||||
data['fromUserNickName'] = this.fromUserNickName;
|
||||
data['fromUserFaceUrl'] = this.fromUserFaceUrl;
|
||||
data['toUserID'] = this.toUserID;
|
||||
data['addTime'] = this.addTime;
|
||||
data['requestMsg'] = this.requestMsg;
|
||||
data['handledMsg'] = this.handledMsg;
|
||||
data['type'] = this.type;
|
||||
data['handleStatus'] = this.handleStatus;
|
||||
data['handleResult'] = this.handleResult;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class GroupApplicationList {
|
||||
int? count;
|
||||
List<GroupApplicationInfo>? user;
|
||||
|
||||
GroupApplicationList({this.count, this.user});
|
||||
|
||||
GroupApplicationList.fromJson(Map<String, dynamic> json) {
|
||||
count = json['count'];
|
||||
if (json['user'] is List) {
|
||||
user = (json['user'] as List)
|
||||
.map((e) => GroupApplicationInfo.fromJson(e))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['count'] = this.count;
|
||||
if (this.user != null) {
|
||||
data['user'] = this.user!.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user