feat(mobile-next): 导入官方 openim-flutter-demo 固定基线 3.8.3-patch.3 并完成双构建
- 上游: github.com/OpenIMSDK/openim-flutter-demo tag 3.8.3-patch.3 commit b3dfdb1e8aaeaaf6f0793e10cadd20d5c184a31f - 并行目录 mobile-next/ 原样导入(含 LICENSE),不覆盖现网 mobile/ - 锁定 Flutter 3.24.5 / Dart 3.5.4 / JDK 17 / Gradle 7.6.3 / AGP 7.3.1 - 实测 Android debug 与 release 构建均成功(见 docs/mobile-next-baseline-import.md) - 本提交可单独回退:git revert 1db1229(重写前) Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -0,0 +1,130 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:openim_common/openim_common.dart';
|
||||
|
||||
import '../../../routes/app_navigator.dart';
|
||||
import '../../conversation/conversation_logic.dart';
|
||||
import '../select_contacts/select_contacts_logic.dart';
|
||||
|
||||
class CreateGroupLogic extends GetxController {
|
||||
final conversationLogic = Get.find<ConversationLogic>();
|
||||
final nameCtrl = TextEditingController();
|
||||
final checkedList = <UserInfo>[];
|
||||
final defaultCheckedList = <UserInfo>[];
|
||||
final allList = <UserInfo>[].obs;
|
||||
final faceURL = ''.obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
defaultCheckedList.addAll(Get.arguments['defaultCheckedList']);
|
||||
checkedList.addAll(Get.arguments['checkedList']);
|
||||
allList.addAll(defaultCheckedList);
|
||||
allList.addAll(checkedList);
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
String get groupName {
|
||||
String name = nameCtrl.text.trim();
|
||||
if (name.isEmpty) {
|
||||
int limit = min(allList.length, 3);
|
||||
name = allList.sublist(0, limit).map((e) => e.nickname).join('、');
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
completeCreation() async {
|
||||
if (allList.length > 1) {
|
||||
var info = await LoadingView.singleton.wrap(
|
||||
asyncFunction: () => OpenIM.iMManager.groupManager.createGroup(
|
||||
groupInfo: GroupInfo(
|
||||
groupID: '',
|
||||
groupName: groupName,
|
||||
faceURL: faceURL.value,
|
||||
groupType: GroupType.work,
|
||||
),
|
||||
memberUserIDs: allList.where((e) => e.userID != OpenIM.iMManager.userID).map((e) => e.userID!).toList(),
|
||||
),
|
||||
);
|
||||
conversationLogic.toChat(
|
||||
offUntilHome: true,
|
||||
groupID: info.groupID,
|
||||
nickname: groupName,
|
||||
faceURL: faceURL.value,
|
||||
sessionType: info.sessionType,
|
||||
);
|
||||
} else {
|
||||
conversationLogic.toChat(
|
||||
offUntilHome: true,
|
||||
userID: checkedList.firstOrNull?.userID,
|
||||
nickname: checkedList.firstOrNull?.nickname,
|
||||
faceURL: checkedList.firstOrNull?.faceURL,
|
||||
sessionType: ConversationType.single,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void selectAvatar() {
|
||||
IMViews.openPhotoSheet(onData: (path, url) {
|
||||
if (url != null) faceURL.value = url;
|
||||
});
|
||||
}
|
||||
|
||||
int length() {
|
||||
return (allList.length + 2) > 10 ? 10 : (allList.length + 2);
|
||||
}
|
||||
|
||||
Widget itemBuilder({
|
||||
required int index,
|
||||
required Widget Function(UserInfo info) builder,
|
||||
required Widget Function() addButton,
|
||||
required Widget Function() delButton,
|
||||
}) {
|
||||
if (allList.length > 8) {
|
||||
if (index < 8) {
|
||||
var info = allList.elementAt(index);
|
||||
return builder(info);
|
||||
} else if (index == 8) {
|
||||
return addButton();
|
||||
} else {
|
||||
return delButton();
|
||||
}
|
||||
} else {
|
||||
if (index < allList.length) {
|
||||
var info = allList.elementAt(index);
|
||||
return builder(info);
|
||||
} else if (index == allList.length) {
|
||||
return addButton();
|
||||
} else {
|
||||
return delButton();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
nameCtrl.dispose();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
void opMember({bool isDel = false}) async {
|
||||
final result = await AppNavigator.startSelectContacts(
|
||||
action: SelAction.addMember,
|
||||
checkedList: checkedList,
|
||||
defaultCheckedIDList: defaultCheckedList.map((e) => e.userID!).toList(),
|
||||
openSelectedSheet: isDel,
|
||||
);
|
||||
final list = IMUtils.convertSelectContactsResultToUserInfo(result);
|
||||
if (list is List<UserInfo>) {
|
||||
checkedList
|
||||
..clear()
|
||||
..addAll(list);
|
||||
allList
|
||||
..assignAll(defaultCheckedList)
|
||||
..addAll(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user