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,10 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'create_group_logic.dart';
|
||||
|
||||
class CreateGroupBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => CreateGroupLogic());
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:openim_common/openim_common.dart';
|
||||
import 'package:sprintf/sprintf.dart';
|
||||
|
||||
import 'create_group_logic.dart';
|
||||
|
||||
class CreateGroupPage extends StatelessWidget {
|
||||
final logic = Get.find<CreateGroupLogic>();
|
||||
|
||||
CreateGroupPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TouchCloseSoftKeyboard(
|
||||
child: Scaffold(
|
||||
appBar: TitleBar.back(title: StrRes.createGroup),
|
||||
backgroundColor: Styles.c_F8F9FA,
|
||||
body: SingleChildScrollView(
|
||||
child: SizedBox(
|
||||
height: 1.sh - 44.h - 10.h - 34.h,
|
||||
child: Column(
|
||||
children: [
|
||||
_buildGroupBaseInfoView(),
|
||||
_buildGroupMemberView(),
|
||||
const Spacer(),
|
||||
Container(
|
||||
color: Styles.c_FFFFFF,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 16.w,
|
||||
vertical: 12.h,
|
||||
),
|
||||
child: Button(
|
||||
text: StrRes.completeCreation,
|
||||
onTap: logic.completeCreation,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildGroupBaseInfoView() => Container(
|
||||
margin: EdgeInsets.fromLTRB(12.w, 8.h, 12.w, 12.h),
|
||||
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 12.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Styles.c_FFFFFF,
|
||||
borderRadius: BorderRadius.circular(6.r),
|
||||
),
|
||||
child: Obx(() => Row(
|
||||
children: [
|
||||
if (logic.faceURL.isNotEmpty)
|
||||
AvatarView(
|
||||
width: 48.w,
|
||||
height: 48.h,
|
||||
url: logic.faceURL.value,
|
||||
onTap: logic.selectAvatar,
|
||||
)
|
||||
else
|
||||
ImageRes.cameraGray.toImage
|
||||
..width = 48.w
|
||||
..height = 48.h
|
||||
..onTap = logic.selectAvatar,
|
||||
12.horizontalSpace,
|
||||
Flexible(
|
||||
child: TextField(
|
||||
style: Styles.ts_0C1C33_17sp,
|
||||
autofocus: true,
|
||||
controller: logic.nameCtrl,
|
||||
inputFormatters: [LengthLimitingTextInputFormatter(16)],
|
||||
decoration: InputDecoration(
|
||||
hintStyle: Styles.ts_8E9AB0_17sp,
|
||||
hintText: StrRes.plsEnterGroupNameHint,
|
||||
border: InputBorder.none,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)),
|
||||
);
|
||||
|
||||
Widget _buildGroupMemberView() => Obx(() => Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Styles.c_FFFFFF,
|
||||
borderRadius: BorderRadius.circular(6.r),
|
||||
),
|
||||
margin: EdgeInsets.symmetric(horizontal: 10.w),
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 12.h),
|
||||
child: Row(
|
||||
children: [
|
||||
StrRes.groupMember.toText..style = Styles.ts_8E9AB0_17sp,
|
||||
const Spacer(),
|
||||
sprintf(StrRes.nPerson, [logic.allList.length]).toText..style = Styles.ts_8E9AB0_17sp,
|
||||
],
|
||||
),
|
||||
),
|
||||
GridView.builder(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: logic.length(),
|
||||
shrinkWrap: true,
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 5,
|
||||
crossAxisSpacing: 3.w,
|
||||
mainAxisSpacing: 2.h,
|
||||
childAspectRatio: 68.w / 78.h,
|
||||
),
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return logic.itemBuilder(
|
||||
index: index,
|
||||
builder: (info) => Column(
|
||||
children: [
|
||||
AvatarView(
|
||||
width: 48.w,
|
||||
height: 48.h,
|
||||
url: info.faceURL,
|
||||
text: info.nickname,
|
||||
textStyle: Styles.ts_FFFFFF_14sp,
|
||||
),
|
||||
2.verticalSpace,
|
||||
(info.nickname ?? '').toText
|
||||
..style = Styles.ts_8E9AB0_10sp
|
||||
..maxLines = 1
|
||||
..overflow = TextOverflow.ellipsis,
|
||||
],
|
||||
),
|
||||
addButton: () => const SizedBox.shrink(),
|
||||
delButton: () => const SizedBox.shrink(),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
));
|
||||
}
|
||||
Reference in New Issue
Block a user