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 'group_profile_panel_logic.dart';
|
||||
|
||||
class GroupProfilePanelBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => GroupProfilePanelLogic());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../core/controller/im_controller.dart';
|
||||
import '../../../routes/app_navigator.dart';
|
||||
import '../../conversation/conversation_logic.dart';
|
||||
|
||||
enum JoinGroupMethod { search, qrcode, invite }
|
||||
|
||||
class GroupProfilePanelLogic extends GetxController {
|
||||
final conversationLogic = Get.find<ConversationLogic>();
|
||||
final imLogic = Get.find<IMController>();
|
||||
final isJoined = false.obs;
|
||||
final members = <GroupMembersInfo>[].obs;
|
||||
late Rx<GroupInfo> groupInfo;
|
||||
late JoinGroupMethod joinGroupMethod;
|
||||
|
||||
late StreamSubscription sub;
|
||||
late StreamSubscription joinedGroupAddedSub;
|
||||
late StreamSubscription memberAddedSub;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
groupInfo = Rx(GroupInfo(groupID: Get.arguments['groupID']));
|
||||
joinGroupMethod = Get.arguments['joinGroupMethod'];
|
||||
sub = imLogic.groupApplicationChangedSubject.listen(_onChanged);
|
||||
joinedGroupAddedSub = imLogic.joinedGroupAddedSubject.listen(_onChanged);
|
||||
memberAddedSub = imLogic.memberAddedSubject.listen(_onChanged);
|
||||
_checkGroup();
|
||||
_getGroupInfo();
|
||||
_getMembers();
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
_onChanged(dynamic value) {
|
||||
if (value is GroupApplicationInfo) {
|
||||
if (value.groupID == groupInfo.value.groupID && value.handleResult == 1) {
|
||||
if (!isJoined.value) {
|
||||
isJoined.value = true;
|
||||
_getGroupInfo();
|
||||
_getMembers();
|
||||
}
|
||||
}
|
||||
} else if (value is GroupInfo) {
|
||||
if (value.groupID == groupInfo.value.groupID) {
|
||||
if (!isJoined.value) {
|
||||
isJoined.value = true;
|
||||
_getGroupInfo();
|
||||
_getMembers();
|
||||
}
|
||||
}
|
||||
} else if (value is GroupMembersInfo) {
|
||||
if (value.groupID == groupInfo.value.groupID && value.userID == OpenIM.iMManager.userID) {
|
||||
if (!isJoined.value) {
|
||||
isJoined.value = true;
|
||||
_getGroupInfo();
|
||||
_getMembers();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_getGroupInfo() async {
|
||||
var list = await OpenIM.iMManager.groupManager.getGroupsInfo(
|
||||
groupIDList: [groupInfo.value.groupID],
|
||||
);
|
||||
var info = list.firstOrNull;
|
||||
if (null != info) {
|
||||
groupInfo.update((val) {
|
||||
val?.groupName = info.groupName;
|
||||
val?.faceURL = info.faceURL;
|
||||
val?.memberCount = info.memberCount;
|
||||
val?.groupType = info.groupType;
|
||||
val?.createTime = info.createTime;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
_checkGroup() async {
|
||||
isJoined.value = await OpenIM.iMManager.groupManager.isJoinedGroup(
|
||||
groupID: groupInfo.value.groupID,
|
||||
);
|
||||
}
|
||||
|
||||
_getMembers() async {
|
||||
var list = await OpenIM.iMManager.groupManager.getGroupMemberList(
|
||||
groupID: groupInfo.value.groupID,
|
||||
count: 10,
|
||||
);
|
||||
members.assignAll(list);
|
||||
}
|
||||
|
||||
enterGroup() async {
|
||||
if (isJoined.value) {
|
||||
conversationLogic.toChat(
|
||||
groupID: groupInfo.value.groupID,
|
||||
nickname: groupInfo.value.groupName,
|
||||
faceURL: groupInfo.value.faceURL,
|
||||
sessionType: groupInfo.value.sessionType,
|
||||
);
|
||||
} else {
|
||||
AppNavigator.startSendVerificationApplication(
|
||||
groupID: groupInfo.value.groupID,
|
||||
joinGroupMethod: joinGroupMethod,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
sub.cancel();
|
||||
joinedGroupAddedSub.cancel();
|
||||
memberAddedSub.cancel();
|
||||
super.onClose();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:common_utils/common_utils.dart';
|
||||
import 'package:flutter/material.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 'group_profile_panel_logic.dart';
|
||||
|
||||
class GroupProfilePanelPage extends StatelessWidget {
|
||||
final logic = Get.find<GroupProfilePanelLogic>();
|
||||
|
||||
GroupProfilePanelPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: TitleBar.back(),
|
||||
backgroundColor: Styles.c_F8F9FA,
|
||||
body: Obx(() => Column(
|
||||
children: [
|
||||
_buildBaseInfo(),
|
||||
if (logic.members.isNotEmpty) _buildGroupMemberList(),
|
||||
Container(
|
||||
height: 56.h,
|
||||
color: Styles.c_FFFFFF,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||||
child: Row(
|
||||
children: [
|
||||
StrRes.groupID.toText..style = Styles.ts_0C1C33_17sp,
|
||||
12.horizontalSpace,
|
||||
logic.groupInfo.value.groupID.toText
|
||||
..style = Styles.ts_8E9AB0_17sp,
|
||||
],
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 12.h),
|
||||
color: Styles.c_FFFFFF,
|
||||
child: Button(
|
||||
text: logic.isJoined.value
|
||||
? StrRes.enterGroup
|
||||
: StrRes.applyJoin,
|
||||
onTap: logic.enterGroup,
|
||||
),
|
||||
),
|
||||
],
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBaseInfo() => Container(
|
||||
height: 80.h,
|
||||
color: Styles.c_FFFFFF,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||||
margin: EdgeInsets.only(bottom: 10.h),
|
||||
child: Row(
|
||||
children: [
|
||||
AvatarView(
|
||||
width: 48.w,
|
||||
height: 48.h,
|
||||
url: logic.groupInfo.value.faceURL,
|
||||
text: logic.groupInfo.value.groupName,
|
||||
isGroup: true,
|
||||
),
|
||||
12.horizontalSpace,
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
(logic.groupInfo.value.groupName ?? '').toText
|
||||
..style = Styles.ts_0C1C33_17sp_medium,
|
||||
4.verticalSpace,
|
||||
Row(
|
||||
children: [
|
||||
ImageRes.createGroupTime.toImage
|
||||
..width = 12.w
|
||||
..height = 12.h,
|
||||
6.horizontalSpace,
|
||||
DateUtil.formatDateMs(
|
||||
(logic.groupInfo.value.createTime ?? 0),
|
||||
format: IMUtils.getTimeFormat1(),
|
||||
).toText
|
||||
..style = Styles.ts_8E9AB0_14sp,
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
Widget _buildGroupMemberList() => Container(
|
||||
color: Styles.c_FFFFFF,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 12.h),
|
||||
margin: EdgeInsets.only(bottom: 10.h),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
text: StrRes.groupMember,
|
||||
style: Styles.ts_0C1C33_17sp,
|
||||
children: [
|
||||
WidgetSpan(child: 12.horizontalSpace),
|
||||
TextSpan(
|
||||
text: sprintf(
|
||||
StrRes.nPerson, [logic.groupInfo.value.memberCount]),
|
||||
style: Styles.ts_8E9AB0_17sp,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
10.verticalSpace,
|
||||
GridView.builder(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 7,
|
||||
crossAxisSpacing: 6.w,
|
||||
childAspectRatio: 1,
|
||||
),
|
||||
itemCount: min(logic.members.length, 7),
|
||||
shrinkWrap: true,
|
||||
itemBuilder: (_, index) {
|
||||
final member = logic.members.elementAt(index);
|
||||
if (index == 6 && logic.members.length != 7) {
|
||||
return ImageRes.moreMembers.toImage
|
||||
..width = 44.w
|
||||
..height = 44.h;
|
||||
}
|
||||
return AvatarView(
|
||||
width: 44.w,
|
||||
height: 44.h,
|
||||
text: member.nickname,
|
||||
url: member.faceURL,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user