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 'add_by_search_logic.dart';
|
||||
|
||||
class AddContactsBySearchBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => AddContactsBySearchLogic());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:openim/pages/contacts/group_profile_panel/group_profile_panel_logic.dart';
|
||||
import 'package:openim/routes/app_navigator.dart';
|
||||
import 'package:openim_common/openim_common.dart';
|
||||
import 'package:pull_to_refresh_new/pull_to_refresh.dart';
|
||||
import 'package:sprintf/sprintf.dart';
|
||||
|
||||
enum SearchType {
|
||||
user,
|
||||
group,
|
||||
}
|
||||
|
||||
class AddContactsBySearchLogic extends GetxController {
|
||||
final refreshCtrl = RefreshController();
|
||||
final searchCtrl = TextEditingController();
|
||||
final focusNode = FocusNode();
|
||||
final userInfoList = <UserFullInfo>[].obs;
|
||||
final groupInfoList = <GroupInfo>[].obs;
|
||||
late SearchType searchType;
|
||||
int pageNo = 0;
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
searchCtrl.dispose();
|
||||
focusNode.dispose();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
searchType = Get.arguments['searchType'] ?? SearchType.user;
|
||||
searchCtrl.addListener(() {
|
||||
if (searchKey.isEmpty) {
|
||||
focusNode.requestFocus();
|
||||
userInfoList.clear();
|
||||
groupInfoList.clear();
|
||||
}
|
||||
});
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
bool get isSearchUser => searchType == SearchType.user;
|
||||
|
||||
String get searchKey => searchCtrl.text.trim();
|
||||
|
||||
bool get isNotFoundUser => userInfoList.isEmpty && searchKey.isNotEmpty;
|
||||
|
||||
bool get isNotFoundGroup => groupInfoList.isEmpty && searchKey.isNotEmpty;
|
||||
|
||||
void search() {
|
||||
if (searchKey.isEmpty) return;
|
||||
if (isSearchUser) {
|
||||
searchUser();
|
||||
} else {
|
||||
searchGroup();
|
||||
}
|
||||
}
|
||||
|
||||
void searchUser() async {
|
||||
var list = await LoadingView.singleton.wrap(
|
||||
asyncFunction: () => Apis.searchUserFullInfo(
|
||||
content: searchKey,
|
||||
pageNumber: pageNo = 1,
|
||||
showNumber: 20,
|
||||
),
|
||||
);
|
||||
userInfoList.assignAll(list ?? []);
|
||||
refreshCtrl.refreshCompleted();
|
||||
if (null == list || list.isEmpty || list.length < 20) {
|
||||
refreshCtrl.loadNoData();
|
||||
} else {
|
||||
refreshCtrl.loadComplete();
|
||||
}
|
||||
}
|
||||
|
||||
void loadMoreUser() async {
|
||||
var list = await LoadingView.singleton.wrap(
|
||||
asyncFunction: () => Apis.searchUserFullInfo(
|
||||
content: searchKey,
|
||||
pageNumber: ++pageNo,
|
||||
showNumber: 20,
|
||||
),
|
||||
);
|
||||
userInfoList.addAll(list ?? []);
|
||||
refreshCtrl.refreshCompleted();
|
||||
if (null == list || list.isEmpty || list.length < 20) {
|
||||
refreshCtrl.loadNoData();
|
||||
} else {
|
||||
refreshCtrl.loadComplete();
|
||||
}
|
||||
}
|
||||
|
||||
void searchGroup() async {
|
||||
var list = await OpenIM.iMManager.groupManager.getGroupsInfo(
|
||||
groupIDList: [searchKey],
|
||||
);
|
||||
groupInfoList.assignAll(list);
|
||||
}
|
||||
|
||||
String getMatchContent(UserFullInfo userInfo) {
|
||||
final keyword = searchCtrl.text;
|
||||
|
||||
return sprintf(StrRes.searchNicknameIs, [userInfo.nickname]);
|
||||
}
|
||||
|
||||
String? getShowName(dynamic info) {
|
||||
if (info is UserFullInfo) {
|
||||
return info.nickname;
|
||||
} else if (info is GroupInfo) {
|
||||
return info.groupName;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
void viewInfo(dynamic info) {
|
||||
if (info is UserFullInfo) {
|
||||
AppNavigator.startUserProfilePane(
|
||||
userID: info.userID!,
|
||||
nickname: info.nickname,
|
||||
faceURL: info.faceURL,
|
||||
);
|
||||
} else if (info is GroupInfo) {
|
||||
AppNavigator.startGroupProfilePanel(
|
||||
groupID: info.groupID,
|
||||
joinGroupMethod: JoinGroupMethod.search,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String getShowTitle(info) {
|
||||
if (!isSearchUser) {
|
||||
return sprintf(StrRes.searchGroupNicknameIs, [getShowName(info)]);
|
||||
}
|
||||
|
||||
UserFullInfo userFullInfo = info;
|
||||
String? tips, content;
|
||||
if (int.tryParse(searchKey) != null) {
|
||||
if (searchKey.length == 11) {
|
||||
tips = StrRes.phoneNumber;
|
||||
content = userFullInfo.phoneNumber ?? searchKey;
|
||||
} else {
|
||||
tips = StrRes.userID;
|
||||
content = userFullInfo.userID;
|
||||
}
|
||||
} else {
|
||||
tips = StrRes.searchNicknameIs;
|
||||
content = getShowName(info);
|
||||
}
|
||||
return "$tips:$content";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:openim/routes/app_navigator.dart';
|
||||
import 'package:openim_common/openim_common.dart';
|
||||
import 'package:pull_to_refresh_new/pull_to_refresh.dart';
|
||||
import 'package:sprintf/sprintf.dart';
|
||||
|
||||
import 'add_by_search_logic.dart';
|
||||
|
||||
class AddContactsBySearchPage extends StatelessWidget {
|
||||
final logic = Get.find<AddContactsBySearchLogic>();
|
||||
|
||||
AddContactsBySearchPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: TitleBar.back(
|
||||
title: logic.isSearchUser ? StrRes.addFriend : StrRes.addGroup,
|
||||
),
|
||||
backgroundColor: Styles.c_FFFFFF,
|
||||
body: Column(
|
||||
children: [
|
||||
SearchBox(
|
||||
focusNode: logic.focusNode,
|
||||
controller: logic.searchCtrl,
|
||||
hintText: logic.isSearchUser ? StrRes.searchByPhoneAndUid : StrRes.searchIDAddGroup,
|
||||
enabled: true,
|
||||
autofocus: true,
|
||||
margin: EdgeInsets.symmetric(horizontal: 17.w, vertical: 10.h),
|
||||
onSubmitted: (_) => logic.search(),
|
||||
),
|
||||
Divider(color: Styles.c_E8EAEF, height: 1.h),
|
||||
if (logic.isSearchUser)
|
||||
GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: AppNavigator.startScan,
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(top: 22.h),
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||||
child: Row(
|
||||
children: [
|
||||
ImageRes.scanBlue.toImage
|
||||
..width = 40.w
|
||||
..height = 40.h,
|
||||
8.horizontalSpace,
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
StrRes.scan.toText..style = Styles.ts_0C1C33_17sp_medium,
|
||||
8.verticalSpace,
|
||||
StrRes.scanHint.toText..style = Styles.ts_8E9AB0_12sp,
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Obx(() => Expanded(
|
||||
child: logic.isSearchUser
|
||||
? (logic.isNotFoundUser ? _buildNotFoundView() : _buildUserListView())
|
||||
: (logic.isNotFoundGroup
|
||||
? _buildNotFoundView()
|
||||
: (Column(
|
||||
children: logic.groupInfoList.map((e) => _buildItemView(e)).toList(),
|
||||
))),
|
||||
))
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildUserListView() => SmartRefresher(
|
||||
controller: logic.refreshCtrl,
|
||||
enablePullDown: false,
|
||||
enablePullUp: true,
|
||||
footer: IMViews.buildFooter(),
|
||||
onLoading: logic.loadMoreUser,
|
||||
child: ListView.builder(
|
||||
itemCount: logic.userInfoList.length,
|
||||
itemBuilder: (_, index) {
|
||||
final userInfo = logic.userInfoList.elementAt(index);
|
||||
return _buildItemView(userInfo);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
Widget _buildItemView(dynamic info) => InkWell(
|
||||
onTap: () => logic.viewInfo(info),
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||||
decoration: BoxDecoration(
|
||||
border: BorderDirectional(
|
||||
bottom: BorderSide(color: Styles.c_E8EAEF, width: 1.h),
|
||||
),
|
||||
),
|
||||
height: 49.h,
|
||||
child: Row(
|
||||
children: [
|
||||
(logic.isSearchUser ? ImageRes.searchPersonIcon : ImageRes.searchGroupIcon).toImage
|
||||
..width = 24.w
|
||||
..height = 24.h,
|
||||
12.horizontalSpace,
|
||||
logic.getShowTitle(info).toText
|
||||
..style = Styles.ts_0089FF_17sp
|
||||
..maxLines = 1
|
||||
..overflow = TextOverflow.ellipsis,
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Widget _buildNotFoundView() => Container(
|
||||
padding: EdgeInsets.symmetric(vertical: 12.h),
|
||||
child: (logic.isSearchUser ? StrRes.noFoundUser : StrRes.noFoundGroup).toText..style = Styles.ts_8E9AB0_17sp,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'add_method_logic.dart';
|
||||
|
||||
class AddContactsMethodBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => AddContactsMethodLogic());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:openim/pages/contacts/add_by_search/add_by_search_logic.dart';
|
||||
import 'package:openim/routes/app_navigator.dart';
|
||||
|
||||
class AddContactsMethodLogic extends GetxController {
|
||||
scan() => AppNavigator.startScan();
|
||||
|
||||
addFriend() =>
|
||||
AppNavigator.startAddContactsBySearch(searchType: SearchType.user);
|
||||
|
||||
createGroup() => AppNavigator.startCreateGroup(
|
||||
defaultCheckedList: [OpenIM.iMManager.userInfo]);
|
||||
|
||||
addGroup() =>
|
||||
AppNavigator.startAddContactsBySearch(searchType: SearchType.group);
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
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 'add_method_logic.dart';
|
||||
|
||||
class AddContactsMethodPage extends StatelessWidget {
|
||||
final logic = Get.find<AddContactsMethodLogic>();
|
||||
|
||||
AddContactsMethodPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: TitleBar.back(title: StrRes.add),
|
||||
body: Column(
|
||||
children: [
|
||||
10.verticalSpace,
|
||||
_buildItemView(
|
||||
icon: ImageRes.scanBlue,
|
||||
text: StrRes.scan,
|
||||
hintText: StrRes.scanHint,
|
||||
onTap: logic.scan,
|
||||
),
|
||||
_buildItemView(
|
||||
icon: ImageRes.addFriendBlue,
|
||||
text: StrRes.addFriend,
|
||||
hintText: StrRes.addFriendHint,
|
||||
onTap: logic.addFriend,
|
||||
),
|
||||
_buildItemView(
|
||||
icon: ImageRes.createGroupBlue,
|
||||
text: StrRes.createGroup,
|
||||
hintText: StrRes.createGroupHint,
|
||||
onTap: logic.createGroup,
|
||||
),
|
||||
_buildItemView(
|
||||
icon: ImageRes.addGroupBLue,
|
||||
text: StrRes.addGroup,
|
||||
hintText: StrRes.addGroupHint,
|
||||
onTap: logic.addGroup,
|
||||
underline: false,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildItemView({
|
||||
required String icon,
|
||||
required String text,
|
||||
required String hintText,
|
||||
bool underline = true,
|
||||
Function()? onTap,
|
||||
}) =>
|
||||
Ink(
|
||||
color: Styles.c_FFFFFF,
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
child: SizedBox(
|
||||
height: 74.h,
|
||||
child: Row(
|
||||
children: [
|
||||
22.horizontalSpace,
|
||||
icon.toImage
|
||||
..width = 28.w
|
||||
..height = 28.h,
|
||||
16.horizontalSpace,
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: underline
|
||||
? BoxDecoration(
|
||||
border: BorderDirectional(
|
||||
bottom: BorderSide(
|
||||
color: Styles.c_E8EAEF,
|
||||
width: .5,
|
||||
),
|
||||
),
|
||||
)
|
||||
: null,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
text.toText..style = Styles.ts_0C1C33_17sp,
|
||||
4.verticalSpace,
|
||||
hintText.toText..style = Styles.ts_8E9AB0_12sp,
|
||||
],
|
||||
),
|
||||
),
|
||||
ImageRes.rightArrow.toImage
|
||||
..width = 24.w
|
||||
..height = 24.h,
|
||||
16.horizontalSpace,
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'contacts_logic.dart';
|
||||
|
||||
class ContactsBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => ContactsLogic());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:openim/pages/contacts/group_profile_panel/group_profile_panel_logic.dart';
|
||||
import 'package:openim/routes/app_navigator.dart';
|
||||
import 'package:openim_common/openim_common.dart';
|
||||
|
||||
import '../../core/controller/im_controller.dart';
|
||||
import '../home/home_logic.dart';
|
||||
import 'select_contacts/select_contacts_logic.dart';
|
||||
|
||||
class ContactsLogic extends GetxController
|
||||
implements ViewUserProfileBridge, SelectContactsBridge, ScanBridge {
|
||||
final imLogic = Get.find<IMController>();
|
||||
final homeLogic = Get.find<HomeLogic>();
|
||||
|
||||
final friendApplicationList = <UserInfo>[];
|
||||
|
||||
int get friendApplicationCount => homeLogic.unhandledFriendApplicationCount.value;
|
||||
|
||||
int get groupApplicationCount => homeLogic.unhandledGroupApplicationCount.value;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
PackageBridge.selectContactsBridge = this;
|
||||
PackageBridge.viewUserProfileBridge = this;
|
||||
PackageBridge.scanBridge = this;
|
||||
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
PackageBridge.selectContactsBridge = null;
|
||||
PackageBridge.viewUserProfileBridge = null;
|
||||
PackageBridge.scanBridge = null;
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
void newFriend() => AppNavigator.startFriendRequests();
|
||||
|
||||
void newGroup() => AppNavigator.startGroupRequests();
|
||||
|
||||
void myFriend() => AppNavigator.startFriendList();
|
||||
|
||||
void myGroup() => AppNavigator.startGroupList();
|
||||
|
||||
void searchContacts() => AppNavigator.startGlobalSearch();
|
||||
|
||||
void addContacts() => AppNavigator.startAddContactsMethod();
|
||||
|
||||
@override
|
||||
Future<T?>? selectContacts<T>(
|
||||
int type, {
|
||||
List<String>? defaultCheckedIDList,
|
||||
List? checkedList,
|
||||
List<String>? excludeIDList,
|
||||
bool openSelectedSheet = false,
|
||||
String? groupID,
|
||||
String? ex,
|
||||
}) =>
|
||||
AppNavigator.startSelectContacts(
|
||||
action: SelAction.values[type],
|
||||
defaultCheckedIDList: defaultCheckedIDList,
|
||||
checkedList: checkedList,
|
||||
excludeIDList: excludeIDList,
|
||||
openSelectedSheet: openSelectedSheet,
|
||||
groupID: groupID,
|
||||
ex: ex,
|
||||
);
|
||||
|
||||
@override
|
||||
viewUserProfile(String userID, String? nickname, String? faceURL, [String? groupID]) =>
|
||||
AppNavigator.startUserProfilePane(
|
||||
userID: userID,
|
||||
nickname: nickname,
|
||||
faceURL: faceURL,
|
||||
groupID: groupID,
|
||||
);
|
||||
|
||||
@override
|
||||
scanOutGroupID(String groupID) => AppNavigator.startGroupProfilePanel(
|
||||
groupID: groupID,
|
||||
joinGroupMethod: JoinGroupMethod.qrcode,
|
||||
offAndToNamed: true,
|
||||
);
|
||||
|
||||
@override
|
||||
scanOutUserID(String userID) => AppNavigator.startUserProfilePane(userID: userID, offAndToNamed: true);
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
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 'contacts_logic.dart';
|
||||
|
||||
class ContactsPage extends StatelessWidget {
|
||||
final logic = Get.find<ContactsLogic>();
|
||||
|
||||
ContactsPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: TitleBar.contacts(
|
||||
onClickAddContacts: logic.addContacts,
|
||||
),
|
||||
backgroundColor: Styles.c_F8F9FA,
|
||||
body: Obx(
|
||||
() => SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
_buildItemView(
|
||||
assetsName: ImageRes.newFriend,
|
||||
label: StrRes.newFriend,
|
||||
count: logic.friendApplicationCount,
|
||||
onTap: logic.newFriend,
|
||||
),
|
||||
_buildItemView(
|
||||
assetsName: ImageRes.newGroup,
|
||||
label: StrRes.newGroupRequest,
|
||||
count: logic.groupApplicationCount,
|
||||
onTap: logic.newGroup,
|
||||
),
|
||||
10.verticalSpace,
|
||||
_buildItemView(
|
||||
assetsName: ImageRes.myFriend,
|
||||
label: StrRes.myFriend,
|
||||
onTap: logic.myFriend,
|
||||
),
|
||||
_buildItemView(
|
||||
assetsName: ImageRes.myGroup,
|
||||
label: StrRes.myGroup,
|
||||
onTap: logic.myGroup,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildItemView({
|
||||
String? assetsName,
|
||||
required String label,
|
||||
Widget? icon,
|
||||
int count = 0,
|
||||
bool showRightArrow = true,
|
||||
double? height,
|
||||
Function()? onTap,
|
||||
}) =>
|
||||
Ink(
|
||||
color: Styles.c_FFFFFF,
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
height: height ?? 60.h,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||||
child: Row(
|
||||
children: [
|
||||
if (null != assetsName)
|
||||
assetsName.toImage
|
||||
..width = 42.w
|
||||
..height = 42.h,
|
||||
if (null != icon) icon,
|
||||
12.horizontalSpace,
|
||||
label.toText..style = Styles.ts_0C1C33_17sp,
|
||||
const Spacer(),
|
||||
if (count > 0) UnreadCountView(count: count),
|
||||
4.horizontalSpace,
|
||||
if (showRightArrow)
|
||||
ImageRes.rightArrow.toImage
|
||||
..width = 24.w
|
||||
..height = 24.h,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -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(),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
));
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'friend_list_logic.dart';
|
||||
|
||||
class FriendListBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => FriendListLogic());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:azlistview/azlistview.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:openim/routes/app_navigator.dart';
|
||||
import 'package:openim_common/openim_common.dart';
|
||||
|
||||
import '../../../core/controller/im_controller.dart';
|
||||
|
||||
class FriendListLogic extends GetxController {
|
||||
final imLoic = Get.find<IMController>();
|
||||
final friendList = <ISUserInfo>[].obs;
|
||||
final userIDList = <String>[];
|
||||
late StreamSubscription delSub;
|
||||
late StreamSubscription addSub;
|
||||
late StreamSubscription infoChangedSub;
|
||||
|
||||
int _count = 10000;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
delSub = imLoic.friendDelSubject.listen(_delFriend);
|
||||
addSub = imLoic.friendAddSubject.listen(_addFriend);
|
||||
infoChangedSub = imLoic.friendInfoChangedSubject.listen(_friendInfoChanged);
|
||||
imLoic.onBlacklistAdd = _delFriend;
|
||||
imLoic.onBlacklistDeleted = _addFriend;
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
_getFriendList();
|
||||
super.onReady();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
delSub.cancel();
|
||||
addSub.cancel();
|
||||
infoChangedSub.cancel();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
_getFriendList() async {
|
||||
List<FriendInfo> list = [];
|
||||
for (int i = 0;; i++) {
|
||||
final temp = await OpenIM.iMManager.friendshipManager.getFriendListPage(
|
||||
offset: list.length,
|
||||
count: _count,
|
||||
filterBlack: true,
|
||||
);
|
||||
list.addAll(temp);
|
||||
|
||||
if (temp.length < _count) {
|
||||
break;
|
||||
}
|
||||
|
||||
_count = 1000;
|
||||
}
|
||||
|
||||
final result = list.map((e) {
|
||||
userIDList.add(e.userID!);
|
||||
|
||||
return ISUserInfo.fromJson(e.toJson());
|
||||
}).toList();
|
||||
|
||||
final convertResult = IMUtils.convertToAZList(result);
|
||||
|
||||
onUserIDList(userIDList);
|
||||
friendList.assignAll(convertResult.cast<ISUserInfo>());
|
||||
}
|
||||
|
||||
void onUserIDList(List<String> userIDList) {}
|
||||
|
||||
_addFriend(dynamic user) {
|
||||
if (user is FriendInfo || user is BlacklistInfo) {
|
||||
_addUser(user.toJson());
|
||||
}
|
||||
}
|
||||
|
||||
_delFriend(dynamic user) {
|
||||
if (user is FriendInfo || user is BlacklistInfo) {
|
||||
friendList.removeWhere((e) => e.userID == user.userID);
|
||||
}
|
||||
}
|
||||
|
||||
_friendInfoChanged(FriendInfo user) {
|
||||
friendList.removeWhere((e) => e.userID == user.userID);
|
||||
_addUser(user.toJson());
|
||||
}
|
||||
|
||||
void _addUser(Map<String, dynamic> json) {
|
||||
final info = ISUserInfo.fromJson(json);
|
||||
friendList.add(IMUtils.setAzPinyinAndTag(info) as ISUserInfo);
|
||||
|
||||
SuspensionUtil.sortListBySuspensionTag(friendList);
|
||||
|
||||
SuspensionUtil.setShowSuspensionStatus(friendList);
|
||||
}
|
||||
|
||||
void viewFriendInfo(ISUserInfo info) => AppNavigator.startUserProfilePane(
|
||||
userID: info.userID!,
|
||||
nickname: info.nickname,
|
||||
faceURL: info.faceURL,
|
||||
);
|
||||
|
||||
void searchFriend() => AppNavigator.startSearchFriend();
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
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 'friend_list_logic.dart';
|
||||
|
||||
class FriendListPage extends StatelessWidget {
|
||||
final logic = Get.find<FriendListLogic>();
|
||||
|
||||
FriendListPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: TitleBar.back(title: StrRes.myFriend),
|
||||
backgroundColor: Styles.c_F8F9FA,
|
||||
body: Column(
|
||||
children: [
|
||||
GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: logic.searchFriend,
|
||||
child: Container(
|
||||
color: Styles.c_FFFFFF,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 10.h),
|
||||
child: const SearchBox(),
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: Obx(
|
||||
() => WrapAzListView<ISUserInfo>(
|
||||
data: logic.friendList,
|
||||
itemCount: logic.friendList.length,
|
||||
itemBuilder: (_, data, index) => _buildItemView(data),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildItemView(ISUserInfo info) => Ink(
|
||||
height: 64.h,
|
||||
color: Styles.c_FFFFFF,
|
||||
child: InkWell(
|
||||
onTap: () => logic.viewFriendInfo(info),
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||||
child: Row(
|
||||
children: [
|
||||
AvatarView(
|
||||
url: info.faceURL,
|
||||
text: info.showName,
|
||||
),
|
||||
10.horizontalSpace,
|
||||
info.showName.toText..style = Styles.ts_0C1C33_17sp,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'search_friend_logic.dart';
|
||||
|
||||
class SearchFriendBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => SearchFriendLogic());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
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 '../friend_list_logic.dart';
|
||||
|
||||
class SearchFriendLogic extends GetxController {
|
||||
final logic = Get.find<FriendListLogic>();
|
||||
final focusNode = FocusNode();
|
||||
final searchCtrl = TextEditingController();
|
||||
final resultList = <ISUserInfo>[].obs;
|
||||
late bool isMultiModel;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
searchCtrl.addListener(_clearInput);
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
focusNode.dispose();
|
||||
searchCtrl.dispose();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
bool get isSearchNotResult => searchCtrl.text.trim().isNotEmpty && resultList.isEmpty;
|
||||
|
||||
_clearInput() {
|
||||
final key = searchCtrl.text.trim();
|
||||
if (key.isEmpty) {
|
||||
resultList.clear();
|
||||
}
|
||||
}
|
||||
|
||||
search() async {
|
||||
var key = searchCtrl.text.trim();
|
||||
resultList.clear();
|
||||
if (key.isNotEmpty) {
|
||||
final result = await OpenIM.iMManager.friendshipManager
|
||||
.searchFriends(keywordList: [key], isSearchNickname: true, isSearchRemark: true, isSearchUserID: true);
|
||||
final users = result.map((e) => ISUserInfo.fromJson(e.toJson())).toList();
|
||||
resultList.addAll(users);
|
||||
}
|
||||
}
|
||||
|
||||
viewFriendInfo(ISUserInfo info) => AppNavigator.startUserProfilePane(
|
||||
userID: info.userID!,
|
||||
offAndToNamed: true,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
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:search_keyword_text/search_keyword_text.dart';
|
||||
|
||||
import 'search_friend_logic.dart';
|
||||
|
||||
class SearchFriendPage extends StatelessWidget {
|
||||
final logic = Get.find<SearchFriendLogic>();
|
||||
|
||||
SearchFriendPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TouchCloseSoftKeyboard(
|
||||
child: Scaffold(
|
||||
appBar: TitleBar.search(
|
||||
focusNode: logic.focusNode,
|
||||
controller: logic.searchCtrl,
|
||||
onSubmitted: (_) => logic.search(),
|
||||
onCleared: () => logic.focusNode.requestFocus(),
|
||||
),
|
||||
backgroundColor: Styles.c_F8F9FA,
|
||||
body: Obx(() => logic.isSearchNotResult
|
||||
? _emptyListView
|
||||
: ListView.builder(
|
||||
itemCount: logic.resultList.length,
|
||||
itemBuilder: (_, index) => _buildItemView(logic.resultList[index]),
|
||||
)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildItemView(ISUserInfo info) => Ink(
|
||||
height: 64.h,
|
||||
color: Styles.c_FFFFFF,
|
||||
child: InkWell(
|
||||
onTap: () => logic.viewFriendInfo(info),
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||||
child: Row(
|
||||
children: [
|
||||
AvatarView(
|
||||
url: info.faceURL,
|
||||
text: info.showName,
|
||||
),
|
||||
10.horizontalSpace,
|
||||
SearchKeywordText(
|
||||
text: info.showName,
|
||||
keyText: logic.searchCtrl.text.trim(),
|
||||
style: Styles.ts_0C1C33_17sp,
|
||||
keyStyle: Styles.ts_0089FF_17sp,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Widget get _emptyListView => SizedBox(
|
||||
width: 1.sw,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
44.verticalSpace,
|
||||
StrRes.searchNotFound.toText..style = Styles.ts_8E9AB0_17sp,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'friend_requests_logic.dart';
|
||||
|
||||
class FriendRequestsBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => FriendRequestsLogic());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:openim/routes/app_navigator.dart';
|
||||
import 'package:openim_common/openim_common.dart';
|
||||
|
||||
import '../../../core/controller/im_controller.dart';
|
||||
import '../../home/home_logic.dart';
|
||||
|
||||
class FriendRequestsLogic extends GetxController {
|
||||
final imLogic = Get.find<IMController>();
|
||||
final homeLogic = Get.find<HomeLogic>();
|
||||
final applicationList = <FriendApplicationInfo>[].obs;
|
||||
late StreamSubscription faSub;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
faSub = imLogic.friendApplicationChangedSubject.listen((value) {
|
||||
_getFriendRequestsList();
|
||||
});
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
_getFriendRequestsList();
|
||||
super.onReady();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
faSub.cancel();
|
||||
homeLogic.getUnhandledFriendApplicationCount();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
void _getFriendRequestsList() async {
|
||||
final list = await Future.wait([
|
||||
OpenIM.iMManager.friendshipManager.getFriendApplicationListAsRecipient(),
|
||||
OpenIM.iMManager.friendshipManager.getFriendApplicationListAsApplicant(),
|
||||
]);
|
||||
|
||||
final allList = <FriendApplicationInfo>[];
|
||||
allList
|
||||
..addAll(list[0])
|
||||
..addAll(list[1]);
|
||||
|
||||
allList.sort((a, b) {
|
||||
if (a.createTime! > b.createTime!) {
|
||||
return -1;
|
||||
} else if (a.createTime! < b.createTime!) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
var haveReadList = DataSp.getHaveReadUnHandleFriendApplication();
|
||||
haveReadList ??= <String>[];
|
||||
for (var e in list[0]) {
|
||||
var id = IMUtils.buildFriendApplicationID(e);
|
||||
if (!haveReadList.contains(id)) {
|
||||
haveReadList.add(id);
|
||||
}
|
||||
}
|
||||
DataSp.putHaveReadUnHandleFriendApplication(haveReadList);
|
||||
applicationList.assignAll(allList);
|
||||
}
|
||||
|
||||
bool isISendRequest(FriendApplicationInfo info) => info.fromUserID == OpenIM.iMManager.userID;
|
||||
|
||||
void acceptFriendApplication(FriendApplicationInfo info) => AppNavigator.startProcessFriendRequests(
|
||||
applicationInfo: info,
|
||||
);
|
||||
|
||||
void refuseFriendApplication(FriendApplicationInfo info) async {}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:openim_common/openim_common.dart';
|
||||
|
||||
import 'friend_requests_logic.dart';
|
||||
|
||||
class FriendRequestsPage extends StatelessWidget {
|
||||
final logic = Get.find<FriendRequestsLogic>();
|
||||
|
||||
FriendRequestsPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: TitleBar.back(title: StrRes.newFriend),
|
||||
backgroundColor: Styles.c_F8F9FA,
|
||||
body: Obx(() => ListView.builder(
|
||||
padding: EdgeInsets.only(top: 10.h),
|
||||
itemCount: logic.applicationList.length,
|
||||
itemBuilder: (_, index) =>
|
||||
_buildItemView(logic.applicationList[index]),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildItemView(FriendApplicationInfo info) {
|
||||
final isISendRequest = info.fromUserID == OpenIM.iMManager.userID;
|
||||
String? name = isISendRequest ? info.toNickname : info.fromNickname;
|
||||
String? faceURL = isISendRequest ? info.toFaceURL : info.fromFaceURL;
|
||||
String? reason = info.reqMsg;
|
||||
|
||||
return Container(
|
||||
height: 68.h,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||||
decoration: BoxDecoration(
|
||||
color: Styles.c_FFFFFF,
|
||||
border: BorderDirectional(
|
||||
bottom: BorderSide(
|
||||
color: Styles.c_F8F9FA,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
AvatarView(url: faceURL, text: name),
|
||||
10.horizontalSpace,
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
(name ?? '').toText
|
||||
..style = Styles.ts_0C1C33_17sp
|
||||
..maxLines = 1
|
||||
..overflow = TextOverflow.ellipsis,
|
||||
4.verticalSpace,
|
||||
if (IMUtils.isNotNullEmptyStr(reason))
|
||||
(reason ?? '').toText
|
||||
..style = Styles.ts_8E9AB0_14sp
|
||||
..maxLines = 1
|
||||
..overflow = TextOverflow.ellipsis,
|
||||
],
|
||||
),
|
||||
),
|
||||
if (/*info.isWaitingHandle && */ isISendRequest)
|
||||
ImageRes.sendRequests.toImage
|
||||
..width = 20.w
|
||||
..height = 20.h,
|
||||
if (info.isWaitingHandle && !isISendRequest)
|
||||
Button(
|
||||
text: StrRes.lookOver,
|
||||
textStyle: Styles.ts_FFFFFF_14sp,
|
||||
onTap: () => logic.acceptFriendApplication(info),
|
||||
height: 28.h,
|
||||
padding: EdgeInsets.symmetric(horizontal: 13.w),
|
||||
),
|
||||
if (info.isWaitingHandle && isISendRequest)
|
||||
StrRes.waitingForVerification.toText..style = Styles.ts_8E9AB0_14sp,
|
||||
if (info.isRejected)
|
||||
StrRes.rejected.toText..style = Styles.ts_8E9AB0_14sp,
|
||||
if (info.isAgreed)
|
||||
StrRes.approved.toText..style = Styles.ts_8E9AB0_14sp,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'process_friend_requests_logic.dart';
|
||||
|
||||
class ProcessFriendRequestsBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => ProcessFriendRequestsLogic());
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:openim_common/openim_common.dart';
|
||||
|
||||
class ProcessFriendRequestsLogic extends GetxController {
|
||||
late FriendApplicationInfo applicationInfo;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
applicationInfo = Get.arguments['applicationInfo'];
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
void acceptFriendApplication() async {
|
||||
LoadingView.singleton
|
||||
.wrap(
|
||||
asyncFunction: () =>
|
||||
OpenIM.iMManager.friendshipManager.acceptFriendApplication(userID: applicationInfo.fromUserID!))
|
||||
.then(_addSuccessfully)
|
||||
.catchError((_) => IMViews.showToast(StrRes.addFailed));
|
||||
}
|
||||
|
||||
void refuseFriendApplication() async {
|
||||
LoadingView.singleton
|
||||
.wrap(
|
||||
asyncFunction: () =>
|
||||
OpenIM.iMManager.friendshipManager.refuseFriendApplication(userID: applicationInfo.fromUserID!))
|
||||
.then(_rejectSuccessfully)
|
||||
.catchError((_) => IMViews.showToast(StrRes.rejectFailed));
|
||||
}
|
||||
|
||||
_addSuccessfully(_) {
|
||||
IMViews.showToast(StrRes.addSuccessfully);
|
||||
Get.back(result: 1);
|
||||
return _;
|
||||
}
|
||||
|
||||
_rejectSuccessfully(_) {
|
||||
IMViews.showToast(StrRes.rejectSuccessfully);
|
||||
Get.back(result: -1);
|
||||
return _;
|
||||
}
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
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 'process_friend_requests_logic.dart';
|
||||
|
||||
class ProcessFriendRequestsPage extends StatelessWidget {
|
||||
final logic = Get.find<ProcessFriendRequestsLogic>();
|
||||
|
||||
ProcessFriendRequestsPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: TitleBar.back(title: StrRes.newFriend),
|
||||
backgroundColor: Styles.c_F8F9FA,
|
||||
body: Container(
|
||||
color: Styles.c_FFFFFF,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 8.h),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
AvatarView(
|
||||
width: 48.w,
|
||||
height: 48.h,
|
||||
url: logic.applicationInfo.fromFaceURL,
|
||||
text: logic.applicationInfo.fromNickname,
|
||||
),
|
||||
10.horizontalSpace,
|
||||
(logic.applicationInfo.fromNickname ?? '').toText
|
||||
..style = Styles.ts_0C1C33_17sp,
|
||||
],
|
||||
),
|
||||
12.verticalSpace,
|
||||
if (IMUtils.isNotNullEmptyStr(logic.applicationInfo.reqMsg))
|
||||
Container(
|
||||
height: 80.h,
|
||||
width: 343.w,
|
||||
margin: EdgeInsets.only(bottom: 12.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Styles.c_E8EAEF_opacity50,
|
||||
borderRadius: BorderRadius.circular(6.r),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 16.w,
|
||||
vertical: 16.h,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
(logic.applicationInfo.reqMsg ?? '').toText
|
||||
..style = Styles.ts_0C1C33_17sp,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Flexible(child: _buildRejectButton()),
|
||||
12.horizontalSpace,
|
||||
Flexible(
|
||||
child: Button(
|
||||
text: StrRes.accept,
|
||||
textStyle: Styles.ts_FFFFFF_17sp,
|
||||
onTap: logic.acceptFriendApplication,
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildRejectButton() => Material(
|
||||
child: Ink(
|
||||
height: 44.h,
|
||||
decoration: BoxDecoration(
|
||||
color: Styles.c_FFFFFF,
|
||||
border: Border.all(
|
||||
color: Styles.c_E8EAEF,
|
||||
width: 1,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(6.r),
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: logic.refuseFriendApplication,
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
child: StrRes.reject.toText..style = Styles.ts_0C1C33_17sp,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'group_list_logic.dart';
|
||||
|
||||
class GroupListBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => GroupListLogic());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:openim/routes/app_navigator.dart';
|
||||
import 'package:pull_to_refresh_new/pull_to_refresh.dart';
|
||||
|
||||
import '../../../core/controller/im_controller.dart';
|
||||
import '../../../core/im_callback.dart';
|
||||
import '../../conversation/conversation_logic.dart';
|
||||
|
||||
class GroupListLogic extends GetxController {
|
||||
final imLoic = Get.find<IMController>();
|
||||
final iCreateRefreshController = RefreshController(initialRefresh: true);
|
||||
final iJoinRefreshController = RefreshController(initialRefresh: true);
|
||||
|
||||
final iCreateGlobalKey = GlobalKey();
|
||||
final iJoinGlobalKey = GlobalKey();
|
||||
|
||||
final conversationLogic = Get.find<ConversationLogic>();
|
||||
final index = 0.obs;
|
||||
final iCreatedList = <GroupInfo>[].obs;
|
||||
final iJoinedList = <GroupInfo>[].obs;
|
||||
|
||||
int iCreatedOffset = 0;
|
||||
int iJoinedOffset = 0;
|
||||
|
||||
int count = 1000;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
imLoic.imSdkStatusPublishSubject.last.then((con) {
|
||||
if (con.status == IMSdkStatus.syncEnded) {
|
||||
iCreatedInitial();
|
||||
iJoinedInitial();
|
||||
}
|
||||
});
|
||||
|
||||
iCreatedInitial();
|
||||
iJoinedInitial();
|
||||
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
void switchTab(i) {
|
||||
index.value = i;
|
||||
}
|
||||
|
||||
void iCreatedInitial() async {
|
||||
iCreatedOffset = 0;
|
||||
iCreatedList.clear();
|
||||
final length = await initial(iCreate: true, offset: iCreatedOffset);
|
||||
|
||||
iCreateRefreshController.refreshCompleted();
|
||||
|
||||
if (length >= count) {
|
||||
iCreatedOffset += length;
|
||||
} else {
|
||||
iCreateRefreshController.loadNoData();
|
||||
}
|
||||
}
|
||||
|
||||
void iCreatedLoadMore() async {
|
||||
final length = await loadMore(iCreate: true, offset: iCreatedOffset);
|
||||
|
||||
if (length < count) {
|
||||
iCreateRefreshController.loadNoData();
|
||||
} else {
|
||||
iCreateRefreshController.loadComplete();
|
||||
iCreatedOffset += length;
|
||||
}
|
||||
}
|
||||
|
||||
void iJoinedInitial() async {
|
||||
iJoinedOffset = 0;
|
||||
iJoinedList.clear();
|
||||
final length = await initial(iCreate: false, offset: iJoinedOffset);
|
||||
|
||||
iJoinRefreshController.refreshCompleted();
|
||||
|
||||
if (length >= count) {
|
||||
iJoinedOffset += length;
|
||||
} else {
|
||||
iJoinRefreshController.loadNoData();
|
||||
}
|
||||
}
|
||||
|
||||
void iJoinedLoadMore() async {
|
||||
final length = await loadMore(iCreate: false, offset: iJoinedOffset);
|
||||
|
||||
if (length < count) {
|
||||
iJoinRefreshController.loadNoData();
|
||||
} else {
|
||||
iJoinRefreshController.loadComplete();
|
||||
iJoinedOffset += length;
|
||||
}
|
||||
}
|
||||
|
||||
Future<int> initial({bool iCreate = true, int offset = 0}) async {
|
||||
final list = await OpenIM.iMManager.groupManager.getJoinedGroupListPage(offset: offset, count: count);
|
||||
|
||||
int iCreatedCount = 0;
|
||||
int iJoinedCount = 0;
|
||||
|
||||
if (iCreate) {
|
||||
final result = list.where((e) => e.ownerUserID == OpenIM.iMManager.userID);
|
||||
iCreatedList.addAll(result);
|
||||
iCreatedCount = result.length;
|
||||
} else {
|
||||
final result = list.where((e) => e.ownerUserID != OpenIM.iMManager.userID);
|
||||
iJoinedList.addAll(result);
|
||||
iJoinedCount = result.length;
|
||||
}
|
||||
|
||||
return iCreate ? iCreatedCount : iJoinedCount;
|
||||
}
|
||||
|
||||
Future<int> loadMore({bool iCreate = true, int offset = 0}) async {
|
||||
final list = await OpenIM.iMManager.groupManager.getJoinedGroupListPage(offset: offset, count: count);
|
||||
|
||||
int iCreatedCount = 0;
|
||||
int iJoinedCount = 0;
|
||||
|
||||
if (iCreate) {
|
||||
final result = list.where((e) => e.ownerUserID == OpenIM.iMManager.userID);
|
||||
iCreatedList.addAll(result);
|
||||
iCreatedCount = result.length;
|
||||
} else {
|
||||
final result = list.where((e) => e.ownerUserID != OpenIM.iMManager.userID);
|
||||
iJoinedList.addAll(result);
|
||||
iJoinedCount = result.length;
|
||||
}
|
||||
|
||||
return iCreate ? iCreatedCount : iJoinedCount;
|
||||
}
|
||||
|
||||
void toGroupChat(GroupInfo info) {
|
||||
conversationLogic.toChat(
|
||||
offUntilHome: false,
|
||||
groupID: info.groupID,
|
||||
nickname: info.groupName,
|
||||
faceURL: info.faceURL,
|
||||
sessionType: info.sessionType,
|
||||
);
|
||||
}
|
||||
|
||||
void searchGroup() => AppNavigator.startSearchGroup();
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:openim_common/openim_common.dart';
|
||||
import 'package:pull_to_refresh_new/pull_to_refresh.dart';
|
||||
import 'package:sprintf/sprintf.dart';
|
||||
|
||||
import 'group_list_logic.dart';
|
||||
|
||||
class GroupListPage extends StatelessWidget {
|
||||
final logic = Get.find<GroupListLogic>();
|
||||
|
||||
GroupListPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: TitleBar.back(title: StrRes.myGroup),
|
||||
backgroundColor: Styles.c_F8F9FA,
|
||||
body: Column(
|
||||
children: [
|
||||
GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: logic.searchGroup,
|
||||
child: Container(
|
||||
color: Styles.c_FFFFFF,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 10.h),
|
||||
child: const SearchBox(),
|
||||
),
|
||||
),
|
||||
Obx(
|
||||
() => CustomTabBar(
|
||||
labels: [StrRes.iCreatedGroup, StrRes.iJoinedGroup],
|
||||
index: logic.index.value,
|
||||
onTabChanged: (i) => logic.switchTab(i),
|
||||
showUnderline: true,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Obx(
|
||||
() => logic.index.value == 0 ? _buildICreatedListView() : _buildIJoinedListView(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildICreatedListView() => SmartRefresher(
|
||||
key: logic.iCreateGlobalKey,
|
||||
controller: logic.iCreateRefreshController,
|
||||
header: IMViews.buildHeader(30),
|
||||
footer: IMViews.buildFooter(),
|
||||
enablePullUp: true,
|
||||
enablePullDown: true,
|
||||
onRefresh: logic.iCreatedInitial,
|
||||
onLoading: logic.iCreatedLoadMore,
|
||||
child: ListView.builder(
|
||||
physics: const BouncingScrollPhysics(),
|
||||
itemCount: logic.iCreatedList.length,
|
||||
itemBuilder: (_, index) => _buildItemView(logic.iCreatedList[index]),
|
||||
),
|
||||
);
|
||||
|
||||
Widget _buildIJoinedListView() => SmartRefresher(
|
||||
key: logic.iJoinGlobalKey,
|
||||
controller: logic.iJoinRefreshController,
|
||||
header: IMViews.buildHeader(30),
|
||||
footer: IMViews.buildFooter(),
|
||||
enablePullUp: true,
|
||||
enablePullDown: true,
|
||||
onRefresh: logic.iJoinedInitial,
|
||||
onLoading: logic.iJoinedLoadMore,
|
||||
child: ListView.builder(
|
||||
physics: const BouncingScrollPhysics(),
|
||||
itemCount: logic.iJoinedList.length,
|
||||
itemBuilder: (_, index) => _buildItemView(logic.iJoinedList[index]),
|
||||
),
|
||||
);
|
||||
|
||||
Widget _buildItemView(GroupInfo info) => Ink(
|
||||
height: 64.h,
|
||||
color: Styles.c_FFFFFF,
|
||||
child: InkWell(
|
||||
onTap: () => logic.toGroupChat(info),
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||||
child: Row(
|
||||
children: [
|
||||
AvatarView(
|
||||
url: info.faceURL,
|
||||
text: info.groupName,
|
||||
isGroup: true,
|
||||
),
|
||||
10.horizontalSpace,
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
(info.groupName ?? '').toText..style = Styles.ts_0C1C33_17sp,
|
||||
sprintf(StrRes.nPerson, [info.memberCount]).toText..style = Styles.ts_8E9AB0_14sp,
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'search_group_logic.dart';
|
||||
|
||||
class SearchGroupBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => SearchGroupLogic());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../conversation/conversation_logic.dart';
|
||||
import '../group_list_logic.dart';
|
||||
|
||||
class SearchGroupLogic extends GetxController {
|
||||
final conversationLogic = Get.find<ConversationLogic>();
|
||||
final logic = Get.find<GroupListLogic>();
|
||||
final focusNode = FocusNode();
|
||||
final searchCtrl = TextEditingController();
|
||||
final resultList = <GroupInfo>[].obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
searchCtrl.addListener(_clearInput);
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
focusNode.dispose();
|
||||
searchCtrl.dispose();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
bool get isSearchNotResult => searchCtrl.text.trim().isNotEmpty && resultList.isEmpty;
|
||||
|
||||
_clearInput() {
|
||||
final key = searchCtrl.text.trim();
|
||||
if (key.isEmpty) {
|
||||
resultList.clear();
|
||||
}
|
||||
}
|
||||
|
||||
search() async {
|
||||
var key = searchCtrl.text.trim();
|
||||
|
||||
final result = await OpenIM.iMManager.groupManager.searchGroups(keywordList: [key], isSearchGroupName: true);
|
||||
resultList.clear();
|
||||
resultList.addAll(result);
|
||||
}
|
||||
|
||||
void toGroupChat(GroupInfo info) {
|
||||
conversationLogic.toChat(
|
||||
offUntilHome: false,
|
||||
groupID: info.groupID,
|
||||
nickname: info.groupName,
|
||||
faceURL: info.faceURL,
|
||||
sessionType: info.sessionType,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:openim_common/openim_common.dart';
|
||||
import 'package:search_keyword_text/search_keyword_text.dart';
|
||||
import 'package:sprintf/sprintf.dart';
|
||||
|
||||
import 'search_group_logic.dart';
|
||||
|
||||
class SearchGroupPage extends StatelessWidget {
|
||||
final logic = Get.find<SearchGroupLogic>();
|
||||
|
||||
SearchGroupPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TouchCloseSoftKeyboard(
|
||||
child: Scaffold(
|
||||
appBar: TitleBar.search(
|
||||
focusNode: logic.focusNode,
|
||||
controller: logic.searchCtrl,
|
||||
onSubmitted: (_) => logic.search(),
|
||||
onCleared: () => logic.focusNode.requestFocus(),
|
||||
),
|
||||
backgroundColor: Styles.c_F8F9FA,
|
||||
body: Obx(() => logic.isSearchNotResult
|
||||
? _emptyListView
|
||||
: ListView.builder(
|
||||
itemCount: logic.resultList.length,
|
||||
itemBuilder: (_, index) => _buildItemView(logic.resultList[index]),
|
||||
)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildItemView(GroupInfo info) => Ink(
|
||||
height: 64.h,
|
||||
color: Styles.c_FFFFFF,
|
||||
child: InkWell(
|
||||
onTap: () => logic.toGroupChat(info),
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||||
child: Row(
|
||||
children: [
|
||||
AvatarView(
|
||||
url: info.faceURL,
|
||||
text: info.groupName,
|
||||
isGroup: true,
|
||||
),
|
||||
10.horizontalSpace,
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SearchKeywordText(
|
||||
text: info.groupName ?? '',
|
||||
keyText: logic.searchCtrl.text.trim(),
|
||||
style: Styles.ts_0C1C33_17sp,
|
||||
keyStyle: Styles.ts_0089FF_17sp,
|
||||
),
|
||||
sprintf(StrRes.nPerson, [info.memberCount]).toText..style = Styles.ts_8E9AB0_14sp,
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Widget get _emptyListView => SizedBox(
|
||||
width: 1.sw,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
44.verticalSpace,
|
||||
StrRes.searchNotFound.toText..style = Styles.ts_8E9AB0_17sp,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -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,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'group_requests_logic.dart';
|
||||
|
||||
class GroupRequestsBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => GroupRequestsLogic());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:openim/routes/app_navigator.dart';
|
||||
import 'package:openim_common/openim_common.dart';
|
||||
|
||||
import '../../../core/controller/im_controller.dart';
|
||||
import '../../home/home_logic.dart';
|
||||
|
||||
class GroupRequestsLogic extends GetxController {
|
||||
final imLogic = Get.find<IMController>();
|
||||
final homeLogic = Get.find<HomeLogic>();
|
||||
final list = <GroupApplicationInfo>[].obs;
|
||||
final groupList = <String, GroupInfo>{}.obs;
|
||||
final memberList = <GroupMembersInfo>[].obs;
|
||||
final userInfoList = <UserInfo>[].obs;
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
getApplicationList();
|
||||
getJoinedGroup();
|
||||
super.onReady();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
imLogic.groupApplicationChangedSubject.listen((info) {
|
||||
getApplicationList();
|
||||
});
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
homeLogic.getUnhandledGroupApplicationCount();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
bool isInvite(GroupApplicationInfo info) {
|
||||
if (info.joinSource == 2) {
|
||||
return info.inviterUserID != null && info.inviterUserID!.isNotEmpty;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
getApplicationList() async {
|
||||
final list = await LoadingView.singleton.wrap(asyncFunction: () async {
|
||||
final list = await Future.wait([
|
||||
OpenIM.iMManager.groupManager.getGroupApplicationListAsRecipient(),
|
||||
OpenIM.iMManager.groupManager.getGroupApplicationListAsApplicant(),
|
||||
]);
|
||||
|
||||
final allList = <GroupApplicationInfo>[];
|
||||
allList
|
||||
..addAll(list[0])
|
||||
..addAll(list[1]);
|
||||
|
||||
allList.sort((a, b) {
|
||||
if (a.reqTime! > b.reqTime!) {
|
||||
return -1;
|
||||
} else if (a.reqTime! < b.reqTime!) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
var map = <String, List<String>>{};
|
||||
var inviterList = <String>[];
|
||||
|
||||
var haveReadList = DataSp.getHaveReadUnHandleGroupApplication();
|
||||
haveReadList ??= <String>[];
|
||||
for (var a in list[0]) {
|
||||
var id = IMUtils.buildGroupApplicationID(a);
|
||||
if (!haveReadList.contains(id)) {
|
||||
haveReadList.add(id);
|
||||
}
|
||||
}
|
||||
DataSp.putHaveReadUnHandleGroupApplication(haveReadList);
|
||||
|
||||
var groupIDList = <String>[];
|
||||
|
||||
for (var a in allList) {
|
||||
if (isInvite(a)) {
|
||||
if (!map.containsKey(a.groupID)) {
|
||||
map[a.groupID!] = [a.inviterUserID!];
|
||||
} else {
|
||||
if (!map[a.groupID!]!.contains(a.inviterUserID!)) {
|
||||
map[a.groupID!]!.add(a.inviterUserID!);
|
||||
}
|
||||
}
|
||||
if (!inviterList.contains(a.inviterUserID!)) {
|
||||
inviterList.add(a.inviterUserID!);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (map.isNotEmpty) {
|
||||
await Future.wait(map.entries.map((e) => OpenIM.iMManager.groupManager
|
||||
.getGroupMembersInfo(groupID: e.key, userIDList: e.value)
|
||||
.then((list) => memberList.assignAll(list))));
|
||||
}
|
||||
|
||||
if (inviterList.isNotEmpty) {
|
||||
await OpenIM.iMManager.userManager
|
||||
.getUsersInfo(userIDList: inviterList)
|
||||
.then((list) => userInfoList.assignAll(list.map((e) => e.simpleUserInfo).toList()));
|
||||
}
|
||||
|
||||
return allList;
|
||||
});
|
||||
|
||||
this.list.assignAll(list);
|
||||
}
|
||||
|
||||
void getJoinedGroup() {
|
||||
OpenIM.iMManager.groupManager.getJoinedGroupList().then((list) {
|
||||
var map = <String, GroupInfo>{};
|
||||
for (var e in list) {
|
||||
map[e.groupID] = e;
|
||||
}
|
||||
groupList.addAll(map);
|
||||
});
|
||||
}
|
||||
|
||||
String getGroupName(GroupApplicationInfo info) => info.groupName ?? groupList[info.groupID]?.groupName ?? '';
|
||||
|
||||
String getInviterNickname(GroupApplicationInfo info) =>
|
||||
(getMemberInfo(info.inviterUserID!)?.nickname) ?? (getUserInfo(info.inviterUserID!)?.nickname) ?? '-';
|
||||
|
||||
GroupMembersInfo? getMemberInfo(inviterUserID) => memberList.firstWhereOrNull((e) => e.userID == inviterUserID);
|
||||
|
||||
UserInfo? getUserInfo(inviterUserID) => userInfoList.firstWhereOrNull((e) => e.userID == inviterUserID);
|
||||
|
||||
void handle(GroupApplicationInfo info) async {
|
||||
var result = await AppNavigator.startProcessGroupRequests(applicationInfo: info);
|
||||
if (result is int) {
|
||||
info.handleResult = result;
|
||||
list.refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.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_requests_logic.dart';
|
||||
|
||||
class GroupRequestsPage extends StatelessWidget {
|
||||
final logic = Get.find<GroupRequestsLogic>();
|
||||
|
||||
GroupRequestsPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: TitleBar.back(title: StrRes.newGroupRequest),
|
||||
backgroundColor: Styles.c_F8F9FA,
|
||||
body: Obx(() => ListView.builder(
|
||||
padding: EdgeInsets.only(top: 10.h),
|
||||
itemCount: logic.list.length,
|
||||
itemBuilder: (_, index) => _buildItemView(logic.list[index]),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildItemView(GroupApplicationInfo info) {
|
||||
final isISendRequest = info.userID == OpenIM.iMManager.userID;
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 10.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Styles.c_FFFFFF,
|
||||
border: BorderDirectional(
|
||||
bottom: BorderSide(color: Styles.c_F8F9FA, width: 1.h),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
AvatarView(
|
||||
url: info.userFaceURL,
|
||||
text: info.nickname,
|
||||
),
|
||||
10.horizontalSpace,
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
(info.nickname ?? '').toText
|
||||
..style = Styles.ts_0C1C33_17sp
|
||||
..maxLines = 1
|
||||
..overflow = TextOverflow.ellipsis,
|
||||
4.verticalSpace,
|
||||
if (!logic.isInvite(info))
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
text: StrRes.applyJoin,
|
||||
style: Styles.ts_8E9AB0_14sp,
|
||||
children: [
|
||||
WidgetSpan(child: 2.horizontalSpace),
|
||||
TextSpan(
|
||||
text: logic.getGroupName(info),
|
||||
style: Styles.ts_0089FF_14sp,
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
else
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
text: logic.getInviterNickname(info),
|
||||
style: Styles.ts_0089FF_14sp,
|
||||
children: [
|
||||
WidgetSpan(child: 2.horizontalSpace),
|
||||
TextSpan(
|
||||
text: StrRes.invite,
|
||||
style: Styles.ts_8E9AB0_14sp,
|
||||
),
|
||||
WidgetSpan(child: 2.horizontalSpace),
|
||||
TextSpan(
|
||||
text: info.nickname,
|
||||
style: Styles.ts_0089FF_14sp,
|
||||
),
|
||||
WidgetSpan(child: 2.horizontalSpace),
|
||||
TextSpan(
|
||||
text: StrRes.joinIn,
|
||||
style: Styles.ts_8E9AB0_14sp,
|
||||
),
|
||||
WidgetSpan(child: 2.horizontalSpace),
|
||||
TextSpan(
|
||||
text: logic.getGroupName(info),
|
||||
style: Styles.ts_0089FF_14sp,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (null != IMUtils.emptyStrToNull(info.reqMsg))
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 4.h),
|
||||
child: sprintf(StrRes.applyReason, [info.reqMsg!]).toText
|
||||
..style = Styles.ts_8E9AB0_14sp
|
||||
..maxLines = 1
|
||||
..overflow = TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
if (/*info.handleResult == 0 && */ isISendRequest)
|
||||
ImageRes.sendRequests.toImage
|
||||
..width = 20.w
|
||||
..height = 20.h,
|
||||
if (info.handleResult == 0 && !isISendRequest)
|
||||
Button(
|
||||
text: StrRes.lookOver,
|
||||
textStyle: Styles.ts_FFFFFF_14sp,
|
||||
height: 28.h,
|
||||
padding: EdgeInsets.symmetric(horizontal: 13.w),
|
||||
onTap: () => logic.handle(info),
|
||||
),
|
||||
if (info.handleResult == 0 && isISendRequest)
|
||||
StrRes.waitingForVerification.toText..style = Styles.ts_8E9AB0_14sp,
|
||||
if (info.handleResult == -1) StrRes.rejected.toText..style = Styles.ts_8E9AB0_14sp,
|
||||
if (info.handleResult == 1) StrRes.approved.toText..style = Styles.ts_8E9AB0_14sp,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'process_group_requests_logic.dart';
|
||||
|
||||
class ProcessGroupRequestsBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => ProcessGroupRequestsLogic());
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:openim_common/openim_common.dart';
|
||||
|
||||
import '../group_requests_logic.dart';
|
||||
|
||||
class ProcessGroupRequestsLogic extends GetxController {
|
||||
final groupRequestsLogic = Get.find<GroupRequestsLogic>();
|
||||
late GroupApplicationInfo applicationInfo;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
applicationInfo = Get.arguments['applicationInfo'];
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
bool get isInvite => groupRequestsLogic.isInvite(applicationInfo);
|
||||
|
||||
String get groupName => groupRequestsLogic.getGroupName(applicationInfo);
|
||||
|
||||
String get inviterNickname => groupRequestsLogic.getInviterNickname(applicationInfo);
|
||||
|
||||
GroupMembersInfo? getMemberInfo(inviterUserID) => groupRequestsLogic.getMemberInfo(inviterUserID);
|
||||
|
||||
UserInfo? getUserInfo(inviterUserID) => groupRequestsLogic.getUserInfo(inviterUserID);
|
||||
|
||||
String get sourceFrom {
|
||||
if (applicationInfo.joinSource == 2) {
|
||||
return '$inviterNickname${StrRes.byMemberInvite}';
|
||||
} else if (applicationInfo.joinSource == 4) {
|
||||
return StrRes.byScanQrcode;
|
||||
}
|
||||
return StrRes.bySearch;
|
||||
}
|
||||
|
||||
void approve() {
|
||||
LoadingView.singleton
|
||||
.wrap(
|
||||
asyncFunction: () => OpenIM.iMManager.groupManager.acceptGroupApplication(
|
||||
groupID: applicationInfo.groupID!,
|
||||
userID: applicationInfo.userID!,
|
||||
handleMsg: "reason",
|
||||
))
|
||||
.then((value) => Get.back(result: 1))
|
||||
.catchError(_parse);
|
||||
}
|
||||
|
||||
void reject() {
|
||||
LoadingView.singleton
|
||||
.wrap(
|
||||
asyncFunction: () => OpenIM.iMManager.groupManager.refuseGroupApplication(
|
||||
groupID: applicationInfo.groupID!,
|
||||
userID: applicationInfo.userID!,
|
||||
handleMsg: "reason",
|
||||
))
|
||||
.then((value) => Get.back(result: -1))
|
||||
.catchError(_parse)
|
||||
.catchError((_) => IMViews.showToast(StrRes.rejectFailed));
|
||||
}
|
||||
|
||||
_parse(e) {
|
||||
if (e is PlatformException) {
|
||||
if (e.code == '${SDKErrorCode.groupApplicationHasBeenProcessed}') {
|
||||
IMViews.showToast(StrRes.groupRequestHandled);
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
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 'process_group_requests_logic.dart';
|
||||
|
||||
class ProcessGroupRequestsPage extends StatelessWidget {
|
||||
final logic = Get.find<ProcessGroupRequestsLogic>();
|
||||
|
||||
ProcessGroupRequestsPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: TitleBar.back(title: StrRes.newGroup),
|
||||
backgroundColor: Styles.c_F8F9FA,
|
||||
body: Container(
|
||||
color: Styles.c_FFFFFF,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 16.w,
|
||||
vertical: 16.h,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
AvatarView(
|
||||
width: 48.w,
|
||||
height: 48.h,
|
||||
url: logic.applicationInfo.userFaceURL,
|
||||
text: logic.applicationInfo.nickname,
|
||||
),
|
||||
10.horizontalSpace,
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
(logic.applicationInfo.nickname ?? '').toText..style = Styles.ts_0C1C33_17sp,
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
text: StrRes.applyJoin,
|
||||
style: Styles.ts_8E9AB0_14sp,
|
||||
children: [
|
||||
WidgetSpan(child: 2.horizontalSpace),
|
||||
TextSpan(
|
||||
text: logic.groupName,
|
||||
style: Styles.ts_0089FF_14sp,
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
12.verticalSpace,
|
||||
if (IMUtils.isNotNullEmptyStr(logic.applicationInfo.reqMsg))
|
||||
Container(
|
||||
height: 80.h,
|
||||
width: 343.w,
|
||||
margin: EdgeInsets.only(bottom: 12.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Styles.c_E8EAEF_opacity50,
|
||||
borderRadius: BorderRadius.circular(6.r),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 16.w,
|
||||
vertical: 8.h,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
(logic.applicationInfo.reqMsg ?? '').toText..style = Styles.ts_0C1C33_17sp,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
sprintf(StrRes.sourceFrom, [logic.sourceFrom]).toText..style = Styles.ts_8E9AB0_14sp
|
||||
],
|
||||
),
|
||||
12.verticalSpace,
|
||||
Row(
|
||||
children: [
|
||||
Flexible(child: _buildRejectButton()),
|
||||
12.horizontalSpace,
|
||||
Flexible(
|
||||
child: Button(
|
||||
onTap: logic.approve,
|
||||
text: StrRes.accept,
|
||||
textStyle: Styles.ts_FFFFFF_17sp,
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildRejectButton() => Material(
|
||||
child: Ink(
|
||||
height: 44.h,
|
||||
decoration: BoxDecoration(
|
||||
color: Styles.c_FFFFFF,
|
||||
border: Border.all(
|
||||
color: Styles.c_E8EAEF,
|
||||
width: 1,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(6.r),
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: logic.reject,
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
child: StrRes.reject.toText..style = Styles.ts_0C1C33_17sp,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'friend_list_logic.dart';
|
||||
|
||||
class SelectContactsFromFriendsBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => SelectContactsFromFriendsLogic());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:openim/pages/contacts/friend_list/friend_list_logic.dart';
|
||||
import 'package:openim/routes/app_navigator.dart';
|
||||
import 'package:openim_common/openim_common.dart';
|
||||
|
||||
import '../select_contacts_logic.dart';
|
||||
|
||||
class SelectContactsFromFriendsLogic extends FriendListLogic {
|
||||
final selectContactsLogic = Get.find<SelectContactsLogic>();
|
||||
|
||||
@override
|
||||
searchFriend() async {
|
||||
final result = await AppNavigator.startSelectContactsFromSearchFriends();
|
||||
if (null != result) {
|
||||
Get.back(result: result);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onUserIDList(List<String> userIDList) {
|
||||
selectContactsLogic.updateDefaultCheckedList(userIDList);
|
||||
super.onUserIDList(userIDList);
|
||||
}
|
||||
|
||||
bool get isSelectAll {
|
||||
if (selectContactsLogic.checkedList.isEmpty) {
|
||||
return false;
|
||||
} else if (operableList
|
||||
.every((item) => selectContactsLogic.isChecked(item))) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Iterable<ISUserInfo> get operableList => friendList.where(_remove);
|
||||
|
||||
bool _remove(ISUserInfo info) => !selectContactsLogic.isDefaultChecked(info);
|
||||
|
||||
selectAll() {
|
||||
if (isSelectAll) {
|
||||
for (var info in operableList) {
|
||||
selectContactsLogic.removeItem(info);
|
||||
}
|
||||
} else {
|
||||
for (var info in operableList) {
|
||||
final isChecked = selectContactsLogic.isChecked(info);
|
||||
if (!isChecked) {
|
||||
selectContactsLogic.toggleChecked(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
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 '../select_contacts_logic.dart';
|
||||
import 'friend_list_logic.dart';
|
||||
|
||||
class SelectContactsFromFriendsPage extends StatelessWidget {
|
||||
final logic = Get.find<SelectContactsFromFriendsLogic>();
|
||||
final selectContactsLogic = Get.find<SelectContactsLogic>();
|
||||
|
||||
SelectContactsFromFriendsPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: TitleBar.back(title: StrRes.myFriend),
|
||||
backgroundColor: Styles.c_F8F9FA,
|
||||
body: Column(
|
||||
children: [
|
||||
GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: logic.searchFriend,
|
||||
child: Container(
|
||||
color: Styles.c_FFFFFF,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 10.h),
|
||||
child: const SearchBox(),
|
||||
),
|
||||
),
|
||||
if (selectContactsLogic.isMultiModel)
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 10.h),
|
||||
child: Ink(
|
||||
height: 64.h,
|
||||
color: Styles.c_FFFFFF,
|
||||
child: InkWell(
|
||||
onTap: logic.selectAll,
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||||
child: Row(
|
||||
children: [
|
||||
Obx(() => Padding(
|
||||
padding: EdgeInsets.only(right: 10.w),
|
||||
child: ChatRadio(checked: logic.isSelectAll),
|
||||
)),
|
||||
10.horizontalSpace,
|
||||
StrRes.selectAll.toText..style = Styles.ts_0C1C33_17sp,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: Obx(
|
||||
() => WrapAzListView<ISUserInfo>(
|
||||
data: logic.friendList,
|
||||
itemCount: logic.friendList.length,
|
||||
itemBuilder: (_, data, index) => _buildItemView(data),
|
||||
),
|
||||
),
|
||||
),
|
||||
selectContactsLogic.checkedConfirmView,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildItemView(ISUserInfo info) {
|
||||
Widget buildChild() => Ink(
|
||||
height: 64.h,
|
||||
color: Styles.c_FFFFFF,
|
||||
child: InkWell(
|
||||
onTap: selectContactsLogic.onTap(info),
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||||
child: Row(
|
||||
children: [
|
||||
if (selectContactsLogic.isMultiModel)
|
||||
Padding(
|
||||
padding: EdgeInsets.only(right: 10.w),
|
||||
child: ChatRadio(
|
||||
checked: selectContactsLogic.isChecked(info),
|
||||
enabled: !selectContactsLogic.isDefaultChecked(info),
|
||||
),
|
||||
),
|
||||
AvatarView(
|
||||
url: info.faceURL,
|
||||
text: info.showName,
|
||||
),
|
||||
10.horizontalSpace,
|
||||
info.showName.toText..style = Styles.ts_0C1C33_17sp,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
return selectContactsLogic.isMultiModel ? Obx(buildChild) : buildChild();
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'search_friend_logic.dart';
|
||||
|
||||
class SelectContactsFromSearchFriendsBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => SelectContactsFromSearchFriendsLogic());
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:openim_common/openim_common.dart';
|
||||
|
||||
import '../friend_list_logic.dart';
|
||||
|
||||
class SelectContactsFromSearchFriendsLogic extends GetxController {
|
||||
final logic = Get.find<SelectContactsFromFriendsLogic>();
|
||||
final focusNode = FocusNode();
|
||||
final searchCtrl = TextEditingController();
|
||||
final resultList = <ISUserInfo>[].obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
searchCtrl.addListener(_clearInput);
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
focusNode.dispose();
|
||||
searchCtrl.dispose();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
bool get isSearchNotResult => searchCtrl.text.trim().isNotEmpty && resultList.isEmpty;
|
||||
|
||||
_clearInput() {
|
||||
final key = searchCtrl.text.trim();
|
||||
if (key.isEmpty) {
|
||||
resultList.clear();
|
||||
}
|
||||
}
|
||||
|
||||
search() {
|
||||
var key = searchCtrl.text.trim();
|
||||
resultList.clear();
|
||||
if (key.isNotEmpty) {
|
||||
for (var element in logic.friendList) {
|
||||
if (element.showName.toUpperCase().contains(key.toUpperCase())) {
|
||||
resultList.add(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
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:search_keyword_text/search_keyword_text.dart';
|
||||
|
||||
import '../../select_contacts_logic.dart';
|
||||
import 'search_friend_logic.dart';
|
||||
|
||||
class SelectContactsFromSearchFriendsPage extends StatelessWidget {
|
||||
final logic = Get.find<SelectContactsFromSearchFriendsLogic>();
|
||||
final selectContactsLogic = Get.find<SelectContactsLogic>();
|
||||
|
||||
SelectContactsFromSearchFriendsPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TouchCloseSoftKeyboard(
|
||||
child: Scaffold(
|
||||
appBar: TitleBar.search(
|
||||
focusNode: logic.focusNode,
|
||||
controller: logic.searchCtrl,
|
||||
onSubmitted: (_) => logic.search(),
|
||||
onCleared: () => logic.focusNode.requestFocus(),
|
||||
),
|
||||
backgroundColor: Styles.c_F8F9FA,
|
||||
body: Obx(() => logic.isSearchNotResult
|
||||
? _emptyListView
|
||||
: ListView.builder(
|
||||
itemCount: logic.resultList.length,
|
||||
itemBuilder: (_, index) => _buildItemView(logic.resultList[index]),
|
||||
)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildItemView(ISUserInfo info) {
|
||||
Widget buildChild() => Ink(
|
||||
height: 64.h,
|
||||
color: Styles.c_FFFFFF,
|
||||
child: InkWell(
|
||||
onTap: selectContactsLogic.onTap(info),
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||||
child: Row(
|
||||
children: [
|
||||
if (selectContactsLogic.isMultiModel)
|
||||
Padding(
|
||||
padding: EdgeInsets.only(right: 10.w),
|
||||
child: ChatRadio(
|
||||
checked: selectContactsLogic.isChecked(info),
|
||||
enabled: !selectContactsLogic.isDefaultChecked(info),
|
||||
),
|
||||
),
|
||||
AvatarView(
|
||||
url: info.faceURL,
|
||||
text: info.showName,
|
||||
),
|
||||
10.horizontalSpace,
|
||||
SearchKeywordText(
|
||||
text: info.showName,
|
||||
keyText: logic.searchCtrl.text.trim(),
|
||||
style: Styles.ts_0C1C33_17sp,
|
||||
keyStyle: Styles.ts_0089FF_17sp,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
return selectContactsLogic.isMultiModel ? Obx(buildChild) : buildChild();
|
||||
}
|
||||
|
||||
Widget get _emptyListView => SizedBox(
|
||||
width: 1.sw,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
44.verticalSpace,
|
||||
StrRes.searchNotFound.toText..style = Styles.ts_8E9AB0_17sp,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'group_list_logic.dart';
|
||||
|
||||
class SelectContactsFromGroupBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => SelectContactsFromGroupLogic());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../routes/app_navigator.dart';
|
||||
import '../select_contacts_logic.dart';
|
||||
|
||||
class SelectContactsFromGroupLogic extends GetxController {
|
||||
final selectContactsLogic = Get.find<SelectContactsLogic>();
|
||||
final allList = <GroupInfo>[].obs;
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
_getGroupRelatedToMe();
|
||||
super.onReady();
|
||||
}
|
||||
|
||||
void _getGroupRelatedToMe() async {
|
||||
final list = await OpenIM.iMManager.groupManager.getJoinedGroupList();
|
||||
allList.addAll(list);
|
||||
}
|
||||
|
||||
Iterable<GroupInfo> get operableList => allList.where(_remove);
|
||||
|
||||
bool _remove(GroupInfo info) => !selectContactsLogic.isDefaultChecked(info);
|
||||
|
||||
bool get isSelectAll {
|
||||
if (selectContactsLogic.checkedList.isEmpty) {
|
||||
return false;
|
||||
} else if (operableList
|
||||
.every((item) => selectContactsLogic.isChecked(item))) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
selectAll() {
|
||||
if (isSelectAll) {
|
||||
for (var info in operableList) {
|
||||
selectContactsLogic.removeItem(info);
|
||||
}
|
||||
} else {
|
||||
for (var info in operableList) {
|
||||
final isChecked = selectContactsLogic.isChecked(info);
|
||||
if (!isChecked) {
|
||||
selectContactsLogic.toggleChecked(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void searchGroup() async {
|
||||
final result = await AppNavigator.startSelectContactsFromSearchGroup();
|
||||
if (null != result) {
|
||||
Get.back(result: result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.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 '../select_contacts_logic.dart';
|
||||
import 'group_list_logic.dart';
|
||||
|
||||
class SelectContactsFromGroupPage extends StatelessWidget {
|
||||
final logic = Get.find<SelectContactsFromGroupLogic>();
|
||||
final selectContactsLogic = Get.find<SelectContactsLogic>();
|
||||
|
||||
SelectContactsFromGroupPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: TitleBar.back(title: StrRes.myGroup),
|
||||
backgroundColor: Styles.c_F8F9FA,
|
||||
body: Column(
|
||||
children: [
|
||||
GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: logic.searchGroup,
|
||||
child: Container(
|
||||
color: Styles.c_FFFFFF,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 10.h),
|
||||
child: const SearchBox(),
|
||||
),
|
||||
),
|
||||
if (selectContactsLogic.isMultiModel)
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 10.h),
|
||||
child: Ink(
|
||||
height: 64.h,
|
||||
color: Styles.c_FFFFFF,
|
||||
child: InkWell(
|
||||
onTap: logic.selectAll,
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||||
child: Row(
|
||||
children: [
|
||||
Obx(() => Padding(
|
||||
padding: EdgeInsets.only(right: 10.w),
|
||||
child: ChatRadio(checked: logic.isSelectAll),
|
||||
)),
|
||||
10.horizontalSpace,
|
||||
StrRes.selectAll.toText..style = Styles.ts_0C1C33_17sp,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Obx(() => ListView.builder(
|
||||
itemCount: logic.allList.length,
|
||||
itemBuilder: (_, index) =>
|
||||
_buildItemView(logic.allList[index]),
|
||||
))),
|
||||
selectContactsLogic.checkedConfirmView,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildItemView(GroupInfo info) {
|
||||
Widget buildChild() => Ink(
|
||||
height: 64.h,
|
||||
color: Styles.c_FFFFFF,
|
||||
child: InkWell(
|
||||
onTap: selectContactsLogic.onTap(info),
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||||
child: Row(
|
||||
children: [
|
||||
if (selectContactsLogic.isMultiModel)
|
||||
Padding(
|
||||
padding: EdgeInsets.only(right: 10.w),
|
||||
child: ChatRadio(
|
||||
checked: selectContactsLogic.isChecked(info),
|
||||
enabled: !selectContactsLogic.isDefaultChecked(info),
|
||||
),
|
||||
),
|
||||
AvatarView(
|
||||
url: info.faceURL,
|
||||
text: info.groupName,
|
||||
isGroup: true,
|
||||
),
|
||||
10.horizontalSpace,
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
(info.groupName ?? '').toText
|
||||
..style = Styles.ts_0C1C33_17sp
|
||||
..maxLines = 1
|
||||
..overflow = TextOverflow.ellipsis,
|
||||
sprintf(StrRes.nPerson, [info.memberCount]).toText
|
||||
..style = Styles.ts_8E9AB0_14sp,
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
return selectContactsLogic.isMultiModel ? Obx(buildChild) : buildChild();
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'search_group_logic.dart';
|
||||
|
||||
class SelectContactsFromSearchGroupBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => SelectContactsFromSearchGroupLogic());
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../group_list_logic.dart';
|
||||
|
||||
class SelectContactsFromSearchGroupLogic extends GetxController {
|
||||
final logic = Get.find<SelectContactsFromGroupLogic>();
|
||||
final focusNode = FocusNode();
|
||||
final searchCtrl = TextEditingController();
|
||||
final resultList = <GroupInfo>[].obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
searchCtrl.addListener(_clearInput);
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
focusNode.dispose();
|
||||
searchCtrl.dispose();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
bool get isSearchNotResult =>
|
||||
searchCtrl.text.trim().isNotEmpty && resultList.isEmpty;
|
||||
|
||||
_clearInput() {
|
||||
final key = searchCtrl.text.trim();
|
||||
if (key.isEmpty) {
|
||||
resultList.clear();
|
||||
}
|
||||
}
|
||||
|
||||
search() {
|
||||
var key = searchCtrl.text.trim();
|
||||
resultList.clear();
|
||||
if (key.isNotEmpty) {
|
||||
for (var element in logic.allList) {
|
||||
if ((element.groupName ?? '')
|
||||
.toUpperCase()
|
||||
.contains(key.toUpperCase())) {
|
||||
resultList.add(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:openim_common/openim_common.dart';
|
||||
import 'package:search_keyword_text/search_keyword_text.dart';
|
||||
import 'package:sprintf/sprintf.dart';
|
||||
|
||||
import '../../select_contacts_logic.dart';
|
||||
import 'search_group_logic.dart';
|
||||
|
||||
class SelectContactsFromSearchGroupPage extends StatelessWidget {
|
||||
final logic = Get.find<SelectContactsFromSearchGroupLogic>();
|
||||
final selectContactsLogic = Get.find<SelectContactsLogic>();
|
||||
|
||||
SelectContactsFromSearchGroupPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TouchCloseSoftKeyboard(
|
||||
child: Scaffold(
|
||||
appBar: TitleBar.search(
|
||||
focusNode: logic.focusNode,
|
||||
controller: logic.searchCtrl,
|
||||
onSubmitted: (_) => logic.search(),
|
||||
onCleared: () => logic.focusNode.requestFocus(),
|
||||
),
|
||||
backgroundColor: Styles.c_F8F9FA,
|
||||
body: Obx(() => logic.isSearchNotResult
|
||||
? _emptyListView
|
||||
: ListView.builder(
|
||||
itemCount: logic.resultList.length,
|
||||
itemBuilder: (_, index) => _buildItemView(logic.resultList[index]),
|
||||
)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildItemView(GroupInfo info) {
|
||||
Widget buildChild() => Ink(
|
||||
height: 64.h,
|
||||
color: Styles.c_FFFFFF,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
selectContactsLogic.toggleChecked(info);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||||
child: Row(
|
||||
children: [
|
||||
if (selectContactsLogic.isMultiModel)
|
||||
Padding(
|
||||
padding: EdgeInsets.only(right: 10.w),
|
||||
child: ChatRadio(
|
||||
checked: selectContactsLogic.isChecked(info),
|
||||
),
|
||||
),
|
||||
AvatarView(
|
||||
url: info.faceURL,
|
||||
text: info.groupName,
|
||||
isGroup: true,
|
||||
),
|
||||
10.horizontalSpace,
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SearchKeywordText(
|
||||
text: info.groupName ?? '',
|
||||
keyText: logic.searchCtrl.text.trim(),
|
||||
style: Styles.ts_0C1C33_17sp,
|
||||
keyStyle: Styles.ts_0089FF_17sp,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
sprintf(StrRes.nPerson, [info.memberCount]).toText..style = Styles.ts_8E9AB0_14sp,
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
return selectContactsLogic.isMultiModel ? Obx(buildChild) : buildChild();
|
||||
}
|
||||
|
||||
Widget get _emptyListView => SizedBox(
|
||||
width: 1.sw,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
44.verticalSpace,
|
||||
StrRes.searchNotFound.toText..style = Styles.ts_8E9AB0_17sp,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'search_contacts_logic.dart';
|
||||
|
||||
class SelectContactsFromSearchBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => SelectContactsFromSearchLogic());
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:openim_common/openim_common.dart';
|
||||
|
||||
import '../../../global_search/global_search_logic.dart';
|
||||
import '../select_contacts_logic.dart';
|
||||
|
||||
class SelectContactsFromSearchLogic extends CommonSearchLogic {
|
||||
final selectContactsLogic = Get.find<SelectContactsLogic>();
|
||||
final resultList = <dynamic>{}.obs;
|
||||
|
||||
bool get isSearchNotResult => searchCtrl.text.trim().isNotEmpty && resultList.isEmpty;
|
||||
|
||||
@override
|
||||
void clearList() {
|
||||
resultList.clear();
|
||||
}
|
||||
|
||||
void search() async {
|
||||
final result = await LoadingView.singleton.wrap(
|
||||
asyncFunction: () => Future.wait([
|
||||
searchFriend(),
|
||||
if (!selectContactsLogic.hiddenGroup) searchGroup(),
|
||||
]));
|
||||
final friendList = result[0] as List<FriendInfo>;
|
||||
clearList();
|
||||
resultList
|
||||
..addAll(friendList);
|
||||
if (selectContactsLogic.action == SelAction.addMember) {
|
||||
var memberInfoList = await getMemberInfo(friendList.map((e) => e.userID!).toList());
|
||||
for (var element in memberInfoList) {
|
||||
selectContactsLogic.defaultCheckedIDList.add(element.userID!);
|
||||
}
|
||||
}
|
||||
if (result.length == 3) {
|
||||
final groupList = result[2] as List<GroupInfo>;
|
||||
resultList.addAll(groupList);
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<GroupMembersInfo>> getMemberInfo(List<String> uidList) async {
|
||||
return await OpenIM.iMManager.groupManager
|
||||
.getGroupMembersInfo(groupID: selectContactsLogic.groupID!, userIDList: uidList);
|
||||
}
|
||||
}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:openim_common/openim_common.dart';
|
||||
import 'package:search_keyword_text/search_keyword_text.dart';
|
||||
|
||||
import '../select_contacts_logic.dart';
|
||||
import 'search_contacts_logic.dart';
|
||||
|
||||
class SelectContactsFromSearchPage extends StatelessWidget {
|
||||
final logic = Get.find<SelectContactsFromSearchLogic>();
|
||||
final selectContactsLogic = Get.find<SelectContactsLogic>();
|
||||
|
||||
SelectContactsFromSearchPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TouchCloseSoftKeyboard(
|
||||
child: Scaffold(
|
||||
appBar: TitleBar.search(
|
||||
focusNode: logic.focusNode,
|
||||
controller: logic.searchCtrl,
|
||||
onSubmitted: (_) => logic.search(),
|
||||
onCleared: () => logic.focusNode.requestFocus(),
|
||||
),
|
||||
backgroundColor: Styles.c_F8F9FA,
|
||||
body: Obx(() => logic.isSearchNotResult
|
||||
? _emptyListView
|
||||
: ListView.builder(
|
||||
itemCount: logic.resultList.length,
|
||||
itemBuilder: (_, index) => _buildItemView(logic.resultList.elementAt(index)),
|
||||
)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildItemView(dynamic info) {
|
||||
Widget buildChild() => Ink(
|
||||
height: 64.h,
|
||||
color: Styles.c_FFFFFF,
|
||||
child: InkWell(
|
||||
onTap: selectContactsLogic.onTap(info),
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||||
child: Row(
|
||||
children: [
|
||||
if (selectContactsLogic.isMultiModel)
|
||||
Padding(
|
||||
padding: EdgeInsets.only(right: 10.w),
|
||||
child: ChatRadio(
|
||||
checked: selectContactsLogic.isChecked(info),
|
||||
enabled: !selectContactsLogic.isDefaultChecked(info),
|
||||
),
|
||||
),
|
||||
AvatarView(
|
||||
url: logic.parseFaceURL(info),
|
||||
text: logic.parseNickname(info),
|
||||
isGroup: info is GroupInfo,
|
||||
),
|
||||
10.horizontalSpace,
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SearchKeywordText(
|
||||
text: logic.parseNickname(info) ?? '',
|
||||
keyText: logic.searchCtrl.text.trim(),
|
||||
style: Styles.ts_0C1C33_17sp,
|
||||
keyStyle: Styles.ts_0089FF_17sp,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
return selectContactsLogic.isMultiModel ? Obx(buildChild) : buildChild();
|
||||
}
|
||||
|
||||
Widget get _emptyListView => SizedBox(
|
||||
width: 1.sw,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
44.verticalSpace,
|
||||
StrRes.searchNotFound.toText..style = Styles.ts_8E9AB0_17sp,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'select_contacts_logic.dart';
|
||||
|
||||
class SelectContactsBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => SelectContactsLogic());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,226 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:openim/pages/conversation/conversation_logic.dart';
|
||||
import 'package:openim/routes/app_navigator.dart';
|
||||
import 'package:openim_common/openim_common.dart';
|
||||
|
||||
import 'select_contacts_view.dart';
|
||||
|
||||
enum SelAction {
|
||||
forward,
|
||||
|
||||
carte,
|
||||
|
||||
crateGroup,
|
||||
|
||||
addMember,
|
||||
|
||||
recommend,
|
||||
}
|
||||
|
||||
class SelectContactsLogic extends GetxController implements OrganizationMultiSelBridge {
|
||||
final checkedList = <String, dynamic>{}.obs; // 已经选中的
|
||||
final defaultCheckedIDList = <String>{}.obs; // 默认选中,且不能修改
|
||||
List<String>? excludeIDList; // 剔除某些数据
|
||||
late SelAction action;
|
||||
late bool openSelectedSheet;
|
||||
String? groupID;
|
||||
final conversationList = <ConversationInfo>[].obs;
|
||||
String? ex;
|
||||
final inputCtrl = TextEditingController();
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
action = Get.arguments['action'];
|
||||
groupID = Get.arguments['groupID'];
|
||||
excludeIDList = Get.arguments['excludeIDList'];
|
||||
defaultCheckedIDList.addAll(Get.arguments['defaultCheckedIDList'] ?? []);
|
||||
checkedList.addAll(Get.arguments['checkedList'] ?? {});
|
||||
openSelectedSheet = Get.arguments['openSelectedSheet'];
|
||||
ex = Get.arguments['ex'];
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
inputCtrl.dispose();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
_queryConversationList();
|
||||
if (openSelectedSheet) viewSelectedContactsList();
|
||||
super.onReady();
|
||||
}
|
||||
|
||||
@override
|
||||
bool get isMultiModel => action != SelAction.carte;
|
||||
|
||||
bool get hiddenGroup => action == SelAction.carte || action == SelAction.crateGroup || action == SelAction.addMember;
|
||||
|
||||
bool get hiddenConversations =>
|
||||
action == SelAction.carte || action == SelAction.crateGroup || action == SelAction.addMember;
|
||||
|
||||
_queryConversationList() async {
|
||||
if (!hiddenConversations) {
|
||||
final cons = Get.find<ConversationLogic>().list;
|
||||
|
||||
final futures = cons.map((con) async {
|
||||
if (con.isGroupChat) {
|
||||
final result = await OpenIM.iMManager.groupManager.isJoinedGroup(groupID: con.groupID!);
|
||||
return result ? con : null;
|
||||
}
|
||||
return con.conversationType == ConversationType.notification ? null : con;
|
||||
}).toList();
|
||||
|
||||
final results = await Future.wait(futures);
|
||||
final filteredCons = results.where((con) => con != null).cast<ConversationInfo>().toList();
|
||||
|
||||
conversationList.addAll(filteredCons);
|
||||
}
|
||||
}
|
||||
|
||||
static String? parseID(e) {
|
||||
if (e is ConversationInfo) {
|
||||
return e.isSingleChat ? e.userID : e.groupID;
|
||||
} else if (e is GroupInfo) {
|
||||
return e.groupID;
|
||||
} else if (e is UserInfo || e is FriendInfo || e is UserFullInfo) {
|
||||
return e.userID;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static String? parseName(e) {
|
||||
if (e is ConversationInfo) {
|
||||
return e.showName;
|
||||
} else if (e is GroupInfo) {
|
||||
return e.groupName;
|
||||
} else if (e is UserInfo || e is FriendInfo || e is UserFullInfo) {
|
||||
return e.nickname;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static String? parseFaceURL(e) {
|
||||
if (e is ConversationInfo) {
|
||||
return e.faceURL;
|
||||
} else if (e is GroupInfo) {
|
||||
return e.faceURL;
|
||||
} else if (e is UserInfo || e is FriendInfo || e is UserFullInfo) {
|
||||
return e.faceURL;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
bool isChecked(info) => checkedList.containsKey(parseID(info));
|
||||
|
||||
@override
|
||||
bool isDefaultChecked(info) => defaultCheckedIDList.contains(parseID(info));
|
||||
|
||||
@override
|
||||
Function()? onTap(dynamic info) => isDefaultChecked(info) ? null : () => toggleChecked(info);
|
||||
|
||||
@override
|
||||
removeItem(dynamic info) {
|
||||
checkedList.remove(parseID(info));
|
||||
}
|
||||
|
||||
@override
|
||||
toggleChecked(dynamic info) {
|
||||
if (isMultiModel) {
|
||||
final key = parseID(info);
|
||||
if (checkedList.containsKey(key)) {
|
||||
checkedList.remove(key);
|
||||
} else {
|
||||
checkedList.putIfAbsent(key ?? '', () => info);
|
||||
}
|
||||
} else {
|
||||
confirmSelectedItem(info);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
updateDefaultCheckedList(List<String> userIDList) async {
|
||||
if (groupID != null) {
|
||||
var list = await OpenIM.iMManager.groupManager.getGroupMembersInfo(
|
||||
groupID: groupID!,
|
||||
userIDList: userIDList,
|
||||
);
|
||||
defaultCheckedIDList.addAll(list.map((e) => e.userID!));
|
||||
}
|
||||
}
|
||||
|
||||
String get checkedStrTips => checkedList.values.map(parseName).join('、');
|
||||
|
||||
viewSelectedContactsList() => Get.bottomSheet(
|
||||
SelectedContactsListView(),
|
||||
isScrollControlled: true,
|
||||
);
|
||||
|
||||
selectFromMyFriend() async {
|
||||
final result = await AppNavigator.startSelectContactsFromFriends();
|
||||
if (null != result) {
|
||||
Get.back(result: result);
|
||||
}
|
||||
}
|
||||
|
||||
selectFromMyGroup() async {
|
||||
final result = await AppNavigator.startSelectContactsFromGroup();
|
||||
if (null != result) {
|
||||
Get.back(result: result);
|
||||
}
|
||||
}
|
||||
|
||||
void selectFromSearch() async {
|
||||
final result = await AppNavigator.startSelectContactsFromSearch();
|
||||
if (null != result) {
|
||||
Get.back(result: result);
|
||||
}
|
||||
}
|
||||
|
||||
selectTagGroup() async {
|
||||
final result = await await AppNavigator.startSelectContactsFromTag();
|
||||
if (null != result) {
|
||||
Get.back(result: result);
|
||||
}
|
||||
}
|
||||
|
||||
confirmSelectedList() async {
|
||||
if (action == SelAction.forward || action == SelAction.recommend) {
|
||||
final sure = await Get.dialog(ForwardHintDialog(
|
||||
title: ex ?? '',
|
||||
checkedList: checkedList.values.toList(),
|
||||
));
|
||||
if (sure == true) {
|
||||
Get.back(result: {
|
||||
"checkedList": checkedList.values,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
Get.back(result: checkedList.value);
|
||||
}
|
||||
}
|
||||
|
||||
confirmSelectedItem(dynamic info) async {
|
||||
if (action == SelAction.carte) {
|
||||
final sure = await Get.dialog(CustomDialog(
|
||||
title: StrRes.sendCarteConfirmHint,
|
||||
));
|
||||
if (sure == true) {
|
||||
Get.back(result: UserInfo.fromJson(info.toJson()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool get enabledConfirmButton => checkedList.isNotEmpty;
|
||||
|
||||
@override
|
||||
Widget get checkedConfirmView => isMultiModel ? CheckedConfirmView() : const SizedBox();
|
||||
}
|
||||
@@ -0,0 +1,309 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.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 'select_contacts_logic.dart';
|
||||
|
||||
class SelectContactsPage extends StatelessWidget {
|
||||
final logic = Get.find<SelectContactsLogic>();
|
||||
|
||||
SelectContactsPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: TitleBar.back(),
|
||||
backgroundColor: Styles.c_F8F9FA,
|
||||
body: Column(
|
||||
children: [
|
||||
GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: logic.selectFromSearch,
|
||||
child: Container(
|
||||
color: Styles.c_FFFFFF,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 10.h),
|
||||
child: const SearchBox(),
|
||||
),
|
||||
),
|
||||
10.verticalSpace,
|
||||
Flexible(
|
||||
child: Obx(() => CustomScrollView(
|
||||
slivers: [
|
||||
SliverFixedExtentList(
|
||||
delegate: SliverChildListDelegate(
|
||||
[
|
||||
_buildCategoryItemView(
|
||||
label: StrRes.myFriend,
|
||||
onTap: logic.selectFromMyFriend,
|
||||
),
|
||||
if (!logic.hiddenGroup)
|
||||
_buildCategoryItemView(
|
||||
label: StrRes.myGroup,
|
||||
onTap: logic.selectFromMyGroup,
|
||||
),
|
||||
],
|
||||
),
|
||||
itemExtent: 56.h,
|
||||
),
|
||||
if (logic.conversationList.isNotEmpty)
|
||||
SliverToBoxAdapter(
|
||||
child: Container(
|
||||
height: 29.h,
|
||||
alignment: Alignment.centerLeft,
|
||||
margin: EdgeInsets.symmetric(horizontal: 16.w),
|
||||
child: StrRes.recentConversations.toText..style = Styles.ts_8E9AB0_12sp,
|
||||
),
|
||||
),
|
||||
SliverFixedExtentList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
childCount: logic.conversationList.length,
|
||||
(_, index) => _buildRecentConversationsItemView(
|
||||
logic.conversationList.elementAt(index),
|
||||
),
|
||||
),
|
||||
itemExtent: 64.h,
|
||||
),
|
||||
],
|
||||
)),
|
||||
),
|
||||
logic.checkedConfirmView,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCategoryItemView({
|
||||
required String label,
|
||||
Function()? onTap,
|
||||
}) =>
|
||||
Ink(
|
||||
height: 56.h,
|
||||
color: Styles.c_FFFFFF,
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||||
child: Row(
|
||||
children: [
|
||||
label.toText..style = Styles.ts_0C1C33_17sp,
|
||||
const Spacer(),
|
||||
ImageRes.rightArrow.toImage
|
||||
..width = 24.w
|
||||
..height = 24.h,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Widget _buildRecentConversationsItemView(ConversationInfo info) {
|
||||
Widget buildChild() => Ink(
|
||||
height: 56.h,
|
||||
color: Styles.c_FFFFFF,
|
||||
child: InkWell(
|
||||
onTap: logic.onTap(info),
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||||
child: Row(
|
||||
children: [
|
||||
if (logic.isMultiModel)
|
||||
Padding(
|
||||
padding: EdgeInsets.only(right: 10.w),
|
||||
child: ChatRadio(
|
||||
checked: logic.isChecked(info),
|
||||
),
|
||||
),
|
||||
AvatarView(
|
||||
url: info.faceURL,
|
||||
text: info.showName,
|
||||
isGroup: !info.isSingleChat,
|
||||
),
|
||||
10.horizontalSpace,
|
||||
Flexible(
|
||||
child: (info.showName ?? '').toText
|
||||
..style = Styles.ts_0C1C33_17sp
|
||||
..maxLines = 1
|
||||
..overflow = TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
return logic.isMultiModel ? Obx(buildChild) : buildChild();
|
||||
}
|
||||
}
|
||||
|
||||
class CheckedConfirmView extends StatelessWidget {
|
||||
CheckedConfirmView({Key? key}) : super(key: key);
|
||||
final logic = Get.find<SelectContactsLogic>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: 66.h,
|
||||
decoration: BoxDecoration(
|
||||
color: Styles.c_FFFFFF,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
offset: Offset(0, -1.h),
|
||||
blurRadius: 4.r,
|
||||
spreadRadius: 1.r,
|
||||
color: Styles.c_000000_opacity4,
|
||||
),
|
||||
],
|
||||
),
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||||
child: Obx(() => Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: logic.viewSelectedContactsList,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
sprintf(StrRes.selectedPeopleCount, [logic.checkedList.length]).toText
|
||||
..style = Styles.ts_0089FF_14sp,
|
||||
ImageRes.expandUpArrow.toImage
|
||||
..width = 24.w
|
||||
..height = 24.h,
|
||||
],
|
||||
),
|
||||
if (logic.checkedList.isNotEmpty) 4.verticalSpace,
|
||||
logic.checkedStrTips.toText
|
||||
..style = Styles.ts_8E9AB0_14sp
|
||||
..maxLines = 1
|
||||
..overflow = TextOverflow.ellipsis,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Button(
|
||||
height: 40.h,
|
||||
enabled: logic.enabledConfirmButton,
|
||||
padding: EdgeInsets.symmetric(horizontal: 14.w),
|
||||
text: sprintf(StrRes.confirmSelectedPeople, [
|
||||
logic.checkedList.length,
|
||||
'999',
|
||||
]),
|
||||
textStyle: Styles.ts_FFFFFF_14sp,
|
||||
onTap: logic.confirmSelectedList,
|
||||
),
|
||||
],
|
||||
)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SelectedContactsListView extends StatelessWidget {
|
||||
SelectedContactsListView({Key? key}) : super(key: key);
|
||||
final logic = Get.find<SelectContactsLogic>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
constraints: BoxConstraints(maxHeight: 548.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Styles.c_FFFFFF,
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(6.r),
|
||||
topRight: Radius.circular(6.r),
|
||||
),
|
||||
),
|
||||
child: Obx(() => Column(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||||
decoration: BoxDecoration(
|
||||
border: BorderDirectional(
|
||||
bottom: BorderSide(color: Styles.c_E8EAEF, width: 1),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
sprintf(StrRes.selectedPeopleCount, [logic.checkedList.length]).toText
|
||||
..style = Styles.ts_0C1C33_17sp_medium,
|
||||
const Spacer(),
|
||||
GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () => Get.back(),
|
||||
child: Container(
|
||||
height: 52.h,
|
||||
alignment: Alignment.center,
|
||||
child: StrRes.confirm.toText..style = Styles.ts_0089FF_17sp,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: logic.checkedList.length,
|
||||
shrinkWrap: true,
|
||||
itemBuilder: (_, index) => _buildItemView(index),
|
||||
),
|
||||
),
|
||||
],
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildItemView(int index) {
|
||||
final info = logic.checkedList.values.elementAt(index);
|
||||
String? name;
|
||||
String? faceURL;
|
||||
bool isGroup = false;
|
||||
name = SelectContactsLogic.parseName(info);
|
||||
faceURL = SelectContactsLogic.parseFaceURL(info);
|
||||
if (info is ConversationInfo) {
|
||||
isGroup = !info.isSingleChat;
|
||||
} else if (info is GroupInfo) {
|
||||
isGroup = true;
|
||||
name = info.groupName;
|
||||
faceURL = info.faceURL;
|
||||
} else if (info is UserInfo) {
|
||||
name = info.nickname;
|
||||
faceURL = info.faceURL;
|
||||
}
|
||||
return Container(
|
||||
height: 64.h,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||||
color: Styles.c_FFFFFF,
|
||||
child: Row(
|
||||
children: [
|
||||
AvatarView(url: faceURL, text: name, isGroup: isGroup),
|
||||
10.horizontalSpace,
|
||||
Expanded(
|
||||
child: (name ?? '').toText
|
||||
..style = Styles.ts_0C1C33_17sp
|
||||
..maxLines = 1
|
||||
..overflow = TextOverflow.ellipsis,
|
||||
),
|
||||
GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () => logic.removeItem(info),
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 13.w, vertical: 4.h),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(2.r),
|
||||
border: Border.all(
|
||||
color: Styles.c_E8EAEF,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: StrRes.remove.toText..style = Styles.ts_0089FF_17sp,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'send_verification_application_logic.dart';
|
||||
|
||||
class SendVerificationApplicationBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => SendVerificationApplicationLogic());
|
||||
}
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:openim_common/openim_common.dart';
|
||||
|
||||
import '../group_profile_panel/group_profile_panel_logic.dart';
|
||||
|
||||
class SendVerificationApplicationLogic extends GetxController {
|
||||
final inputCtrl = TextEditingController();
|
||||
String? userID;
|
||||
String? groupID;
|
||||
JoinGroupMethod? joinGroupMethod;
|
||||
|
||||
bool get isEnterGroup => groupID != null;
|
||||
|
||||
bool get isAddFriend => userID != null;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
userID = Get.arguments['userID'];
|
||||
groupID = Get.arguments['groupID'];
|
||||
joinGroupMethod = Get.arguments['joinGroupMethod'];
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
void send() async {
|
||||
if (isAddFriend) {
|
||||
_applyAddFriend();
|
||||
} else if (isEnterGroup) {
|
||||
_applyEnterGroup();
|
||||
}
|
||||
}
|
||||
|
||||
_applyAddFriend() async {
|
||||
try {
|
||||
await LoadingView.singleton.wrap(
|
||||
asyncFunction: () => OpenIM.iMManager.friendshipManager.addFriend(
|
||||
userID: userID!,
|
||||
reason: inputCtrl.text.trim(),
|
||||
),
|
||||
);
|
||||
Get.back();
|
||||
IMViews.showToast(StrRes.sendSuccessfully);
|
||||
} catch (_) {
|
||||
if (_ is PlatformException) {
|
||||
if (_.code == '${SDKErrorCode.refuseToAddFriends}') {
|
||||
IMViews.showToast(StrRes.canNotAddFriends);
|
||||
return;
|
||||
}
|
||||
}
|
||||
IMViews.showToast(StrRes.sendFailed);
|
||||
}
|
||||
}
|
||||
|
||||
_applyEnterGroup() {
|
||||
LoadingView.singleton
|
||||
.wrap(
|
||||
asyncFunction: () => OpenIM.iMManager.groupManager.joinGroup(
|
||||
groupID: groupID!,
|
||||
reason: inputCtrl.text.trim(),
|
||||
joinSource: joinGroupMethod == JoinGroupMethod.qrcode ? 4 : 3,
|
||||
),
|
||||
)
|
||||
.then((value) => IMViews.showToast(StrRes.sendSuccessfully))
|
||||
.then((value) => Get.back())
|
||||
.catchError((e) => IMViews.showToast(StrRes.sendFailed));
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
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 'send_verification_application_logic.dart';
|
||||
|
||||
class SendVerificationApplicationPage extends StatelessWidget {
|
||||
final logic = Get.find<SendVerificationApplicationLogic>();
|
||||
|
||||
SendVerificationApplicationPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TouchCloseSoftKeyboard(
|
||||
child: Scaffold(
|
||||
appBar: TitleBar.back(
|
||||
title: logic.isEnterGroup ? StrRes.groupVerification : StrRes.friendVerification,
|
||||
right: StrRes.send.toText
|
||||
..style = Styles.ts_0C1C33_17sp
|
||||
..onTap = logic.send,
|
||||
),
|
||||
backgroundColor: Styles.c_F8F9FA,
|
||||
body: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 6.h, horizontal: 16.w),
|
||||
child: (logic.isEnterGroup ? StrRes.sendEnterGroupApplication : StrRes.sendToBeFriendApplication).toText
|
||||
..style = Styles.ts_8E9AB0_14sp,
|
||||
),
|
||||
Container(
|
||||
height: 122.h,
|
||||
color: Styles.c_FFFFFF,
|
||||
padding: EdgeInsets.symmetric(vertical: 12.h),
|
||||
child: TextField(
|
||||
controller: logic.inputCtrl,
|
||||
autofocus: true,
|
||||
maxLines: 10,
|
||||
maxLength: 20,
|
||||
decoration: InputDecoration(
|
||||
isDense: true,
|
||||
border: InputBorder.none,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
horizontal: 16.w,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'friend_setup_logic.dart';
|
||||
|
||||
class FriendSetupBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => FriendSetupLogic());
|
||||
}
|
||||
}
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
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 '../../../chat/chat_logic.dart';
|
||||
import '../../../conversation/conversation_logic.dart';
|
||||
import '../../select_contacts/select_contacts_logic.dart';
|
||||
import '../user_profile _panel_logic.dart';
|
||||
|
||||
class FriendSetupLogic extends GetxController {
|
||||
final conversationLogic = Get.find<ConversationLogic>();
|
||||
final userProfilesLogic = Get.find<UserProfilePanelLogic>(tag: GetTags.userProfile);
|
||||
late String userID;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
userID = Get.arguments['userID'];
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
void toggleBlacklist() {
|
||||
if (userProfilesLogic.userInfo.value.isBlacklist == true) {
|
||||
removeBlacklist();
|
||||
} else {
|
||||
addBlacklist();
|
||||
}
|
||||
}
|
||||
|
||||
void addBlacklist() async {
|
||||
var confirm = await Get.dialog(CustomDialog(title: StrRes.areYouSureAddBlacklist));
|
||||
if (confirm == true) {
|
||||
await OpenIM.iMManager.friendshipManager.addBlacklist(
|
||||
userID: userProfilesLogic.userInfo.value.userID!,
|
||||
);
|
||||
userProfilesLogic.userInfo.update((val) {
|
||||
val?.isBlacklist = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void removeBlacklist() async {
|
||||
await OpenIM.iMManager.friendshipManager.removeBlacklist(
|
||||
userID: userProfilesLogic.userInfo.value.userID!,
|
||||
);
|
||||
userProfilesLogic.userInfo.update((val) {
|
||||
val?.isBlacklist = false;
|
||||
});
|
||||
}
|
||||
|
||||
void deleteFromFriendList() async {
|
||||
var confirm = await Get.dialog(CustomDialog(
|
||||
title: StrRes.areYouSureDelFriend,
|
||||
rightText: StrRes.delete,
|
||||
));
|
||||
if (confirm) {
|
||||
await LoadingView.singleton.wrap(asyncFunction: () async {
|
||||
await OpenIM.iMManager.friendshipManager.deleteFriend(
|
||||
userID: userProfilesLogic.userInfo.value.userID!,
|
||||
);
|
||||
userProfilesLogic.userInfo.update((val) {
|
||||
val?.isFriendship = false;
|
||||
});
|
||||
|
||||
final userIDList = [
|
||||
userProfilesLogic.userInfo.value.userID,
|
||||
OpenIM.iMManager.userID,
|
||||
];
|
||||
userIDList.sort();
|
||||
final conversationID = 'si_${userIDList.join('_')}';
|
||||
|
||||
await OpenIM.iMManager.conversationManager.deleteConversationAndDeleteAllMsg(conversationID: conversationID);
|
||||
|
||||
conversationLogic.list.removeWhere((e) => e.conversationID == conversationID);
|
||||
});
|
||||
|
||||
if (userProfilesLogic.offAllWhenDelFriend == true) {
|
||||
AppNavigator.startBackMain();
|
||||
} else {
|
||||
Get.back();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
recommendToFriend() async {
|
||||
final isRegistered = Get.isRegistered<ChatLogic>(tag: GetTags.chat);
|
||||
if (isRegistered) {
|
||||
final logic = Get.find<ChatLogic>(tag: GetTags.chat);
|
||||
logic.recommendFriendCarte(UserInfo.fromJson(userProfilesLogic.userInfo.value.toJson()));
|
||||
return;
|
||||
}
|
||||
final result = await AppNavigator.startSelectContacts(
|
||||
action: SelAction.recommend,
|
||||
ex: '[${StrRes.carte}]${userProfilesLogic.userInfo.value.nickname}',
|
||||
);
|
||||
if (null != result) {
|
||||
final customEx = result['customEx'];
|
||||
final checkedList = result['checkedList'];
|
||||
for (var info in checkedList) {
|
||||
final userID = IMUtils.convertCheckedToUserID(info);
|
||||
final groupID = IMUtils.convertCheckedToGroupID(info);
|
||||
if (customEx is String && customEx.isNotEmpty) {
|
||||
OpenIM.iMManager.messageManager.sendMessage(
|
||||
message: await OpenIM.iMManager.messageManager.createTextMessage(
|
||||
text: customEx,
|
||||
),
|
||||
userID: userID,
|
||||
groupID: groupID,
|
||||
offlinePushInfo: Config.offlinePushInfo,
|
||||
);
|
||||
}
|
||||
|
||||
OpenIM.iMManager.messageManager.sendMessage(
|
||||
message: await OpenIM.iMManager.messageManager.createCardMessage(
|
||||
userID: userProfilesLogic.userInfo.value.userID!,
|
||||
nickname: userProfilesLogic.userInfo.value.showName,
|
||||
faceURL: userProfilesLogic.userInfo.value.faceURL,
|
||||
),
|
||||
userID: userID,
|
||||
groupID: groupID,
|
||||
offlinePushInfo: Config.offlinePushInfo,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setFriendRemark() => AppNavigator.startSetFriendRemark();
|
||||
}
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
import 'package:flutter/cupertino.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 'friend_setup_logic.dart';
|
||||
|
||||
class FriendSetupPage extends StatelessWidget {
|
||||
final logic = Get.find<FriendSetupLogic>();
|
||||
|
||||
FriendSetupPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: TitleBar.back(
|
||||
title: StrRes.friendSetup,
|
||||
),
|
||||
backgroundColor: Styles.c_F8F9FA,
|
||||
body: Column(
|
||||
children: [
|
||||
10.verticalSpace,
|
||||
_buildItemView(
|
||||
label: StrRes.setupRemark,
|
||||
borderRadius: BorderRadius.only(
|
||||
topRight: Radius.circular(6.r),
|
||||
topLeft: Radius.circular(6.r),
|
||||
),
|
||||
showRightArrow: true,
|
||||
onTap: logic.setFriendRemark,
|
||||
),
|
||||
_buildItemView(
|
||||
label: StrRes.recommendToFriend,
|
||||
borderRadius: BorderRadius.only(
|
||||
bottomLeft: Radius.circular(6.r),
|
||||
bottomRight: Radius.circular(6.r),
|
||||
),
|
||||
showRightArrow: true,
|
||||
onTap: logic.recommendToFriend,
|
||||
),
|
||||
10.verticalSpace,
|
||||
Obx(() => _buildItemView(
|
||||
label: StrRes.addToBlacklist,
|
||||
showSwitchButton: true,
|
||||
switchOn:
|
||||
logic.userProfilesLogic.userInfo.value.isBlacklist == true,
|
||||
onChanged: (_) => logic.toggleBlacklist(),
|
||||
)),
|
||||
10.verticalSpace,
|
||||
_buildItemView(
|
||||
isDelFriendButton: true,
|
||||
onTap: logic.deleteFromFriendList,
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildItemView({
|
||||
String? label,
|
||||
bool showRightArrow = false,
|
||||
bool showSwitchButton = false,
|
||||
BorderRadius? borderRadius,
|
||||
bool switchOn = false,
|
||||
bool isDelFriendButton = false,
|
||||
ValueChanged<bool>? onChanged,
|
||||
Function()? onTap,
|
||||
}) =>
|
||||
Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 10.w),
|
||||
child: Ink(
|
||||
height: 46.h,
|
||||
decoration: BoxDecoration(
|
||||
color: Styles.c_FFFFFF,
|
||||
borderRadius: borderRadius ?? BorderRadius.circular(6.r),
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
alignment: isDelFriendButton ? Alignment.center : null,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||||
child: isDelFriendButton
|
||||
? (StrRes.unfriend.toText..style = Styles.ts_FF381F_17sp)
|
||||
: Row(
|
||||
children: [
|
||||
(label ?? '').toText..style = Styles.ts_0C1C33_17sp,
|
||||
const Spacer(),
|
||||
if (showRightArrow)
|
||||
ImageRes.rightArrow.toImage
|
||||
..width = 24.w
|
||||
..height = 24.h,
|
||||
if (showSwitchButton)
|
||||
CupertinoSwitch(
|
||||
value: switchOn,
|
||||
onChanged: onChanged,
|
||||
activeColor: Styles.c_0089FF,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'personal_info_logic.dart';
|
||||
|
||||
class PersonalInfoBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => PersonalInfoLogic());
|
||||
}
|
||||
}
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:common_utils/common_utils.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:openim_common/openim_common.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import '../user_profile _panel_logic.dart';
|
||||
|
||||
class PersonalInfoLogic extends GetxController {
|
||||
final userProfilesLogic = Get.find<UserProfilePanelLogic>(tag: GetTags.userProfile);
|
||||
late String userID;
|
||||
final userFullInfo = UserFullInfo().obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
userID = Get.arguments['userID'];
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
_queryUserFullInfo();
|
||||
super.onReady();
|
||||
}
|
||||
|
||||
void _queryUserFullInfo() async {
|
||||
final existUser = UserCacheManager().getUserInfo(userID);
|
||||
if (existUser != null) {
|
||||
userFullInfo.update((val) {
|
||||
val?.nickname = existUser.nickname;
|
||||
val?.faceURL = existUser.faceURL;
|
||||
val?.status = existUser.status;
|
||||
val?.level = existUser.level;
|
||||
val?.phoneNumber = existUser.phoneNumber;
|
||||
val?.areaCode = existUser.areaCode;
|
||||
val?.birth = existUser.birth;
|
||||
val?.email = existUser.email;
|
||||
val?.gender = existUser.gender;
|
||||
val?.mobile = existUser.mobile;
|
||||
});
|
||||
}
|
||||
|
||||
final list = await LoadingView.singleton.wrap(
|
||||
asyncFunction: () => Apis.getUserFullInfo(userIDList: [userID]),
|
||||
);
|
||||
final info = list?.firstOrNull;
|
||||
if (null != info) {
|
||||
UserCacheManager().addOrUpdateUserInfo(userID, info);
|
||||
|
||||
userFullInfo.update((val) {
|
||||
val?.nickname = info.nickname;
|
||||
val?.faceURL = info.faceURL;
|
||||
val?.gender = info.gender;
|
||||
val?.englishName = info.englishName;
|
||||
val?.birth = info.birth;
|
||||
val?.telephone = info.telephone;
|
||||
val?.phoneNumber = info.phoneNumber;
|
||||
val?.email = info.email;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
String? get nickname => IMUtils.emptyStrToNull(userProfilesLogic.userInfo.value.nickname) ?? IMUtils.emptyStrToNull(userFullInfo.value.nickname);
|
||||
|
||||
String? get faceURL => IMUtils.emptyStrToNull(userProfilesLogic.userInfo.value.faceURL) ?? IMUtils.emptyStrToNull(userFullInfo.value.faceURL);
|
||||
|
||||
bool get isMale => (userProfilesLogic.userInfo.value.gender ?? userFullInfo.value.gender) == 1;
|
||||
|
||||
String? get englishName => IMUtils.emptyStrToNull(userFullInfo.value.englishName) ?? '-';
|
||||
|
||||
int? get _birth => userProfilesLogic.userInfo.value.birth ?? userFullInfo.value.birth;
|
||||
|
||||
String? get birth => _birth == null ? '-' : DateUtil.formatDateMs(_birth!, format: IMUtils.getTimeFormat1());
|
||||
|
||||
String? get telephone => IMUtils.emptyStrToNull(userFullInfo.value.telephone) ?? '-';
|
||||
|
||||
String? get phoneNumber => IMUtils.emptyStrToNull(userFullInfo.value.phoneNumber) ?? '-';
|
||||
|
||||
String? get email => IMUtils.emptyStrToNull(userFullInfo.value.email) ?? '-';
|
||||
|
||||
clickPhoneNumber() => _callSystemPhone(userFullInfo.value.phoneNumber);
|
||||
|
||||
clickTel() => _callSystemPhone(userFullInfo.value.telephone);
|
||||
|
||||
clickEmail() => _callSystemEmail(userFullInfo.value.email);
|
||||
|
||||
_callSystemPhone(String? phone) async {
|
||||
final value = IMUtils.emptyStrToNull(phone);
|
||||
if (null != value) {
|
||||
final uri = Uri.parse('tel:$value');
|
||||
try {
|
||||
launchUrl(uri);
|
||||
} catch (_) {}
|
||||
}
|
||||
}
|
||||
|
||||
_callSystemEmail(String? email) {
|
||||
final value = IMUtils.emptyStrToNull(email);
|
||||
if (null != value) {
|
||||
final uri = Uri.parse('mailto:$value');
|
||||
try {
|
||||
launchUrl(uri);
|
||||
} catch (_) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
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 'personal_info_logic.dart';
|
||||
|
||||
class PersonalInfoPage extends StatelessWidget {
|
||||
final logic = Get.find<PersonalInfoLogic>();
|
||||
|
||||
PersonalInfoPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: TitleBar.back(
|
||||
title: StrRes.personalInfo,
|
||||
),
|
||||
backgroundColor: Styles.c_F8F9FA,
|
||||
body: SingleChildScrollView(
|
||||
child: Obx(
|
||||
() => Column(
|
||||
children: [
|
||||
10.verticalSpace,
|
||||
_buildCornerBgView(
|
||||
children: [
|
||||
_buildItemView(
|
||||
label: StrRes.avatar,
|
||||
isAvatar: true,
|
||||
value: logic.nickname,
|
||||
url: logic.faceURL,
|
||||
),
|
||||
_buildItemView(
|
||||
label: StrRes.name,
|
||||
value: logic.nickname,
|
||||
),
|
||||
_buildItemView(
|
||||
label: StrRes.gender,
|
||||
value: logic.isMale ? StrRes.man : StrRes.woman,
|
||||
),
|
||||
_buildItemView(
|
||||
label: StrRes.englishName,
|
||||
value: logic.englishName,
|
||||
),
|
||||
_buildItemView(
|
||||
label: StrRes.birthDay,
|
||||
value: logic.birth,
|
||||
),
|
||||
],
|
||||
),
|
||||
10.verticalSpace,
|
||||
_buildCornerBgView(
|
||||
children: [
|
||||
_buildItemView(
|
||||
label: StrRes.mobile,
|
||||
value: logic.phoneNumber,
|
||||
onTap: logic.clickPhoneNumber,
|
||||
),
|
||||
_buildItemView(
|
||||
label: StrRes.email,
|
||||
value: logic.email,
|
||||
onTap: logic.clickEmail,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCornerBgView({required List<Widget> children}) => Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||||
margin: EdgeInsets.symmetric(horizontal: 10.w),
|
||||
decoration: BoxDecoration(
|
||||
color: Styles.c_FFFFFF,
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(6.r),
|
||||
topRight: Radius.circular(6.r),
|
||||
bottomLeft: Radius.circular(6.r),
|
||||
bottomRight: Radius.circular(6.r),
|
||||
),
|
||||
),
|
||||
child: Column(children: children),
|
||||
);
|
||||
|
||||
Widget _buildItemView({
|
||||
required String label,
|
||||
String? value,
|
||||
String? url,
|
||||
bool isAvatar = false,
|
||||
Function()? onTap,
|
||||
}) =>
|
||||
GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: onTap,
|
||||
child: SizedBox(
|
||||
height: 46.h,
|
||||
child: Row(
|
||||
children: [
|
||||
label.toText..style = Styles.ts_0C1C33_17sp,
|
||||
const Spacer(),
|
||||
if (null != value && !isAvatar) value.toText..style = Styles.ts_0C1C33_17sp,
|
||||
if (isAvatar)
|
||||
AvatarView(
|
||||
width: 32.w,
|
||||
height: 32.h,
|
||||
url: url,
|
||||
text: value,
|
||||
textStyle: Styles.ts_FFFFFF_10sp,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'set_remark_logic.dart';
|
||||
|
||||
class SetFriendRemarkBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => SetFriendRemarkLogic());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:openim_common/openim_common.dart';
|
||||
|
||||
import '../user_profile _panel_logic.dart';
|
||||
|
||||
class SetFriendRemarkLogic extends GetxController {
|
||||
final userProfilesLogic =
|
||||
Get.find<UserProfilePanelLogic>(tag: GetTags.userProfile);
|
||||
late TextEditingController inputCtrl;
|
||||
|
||||
void save() async {
|
||||
try {
|
||||
await LoadingView.singleton.wrap(
|
||||
asyncFunction: () => OpenIM.iMManager.friendshipManager.setFriendRemark(
|
||||
userID: userProfilesLogic.userInfo.value.userID!,
|
||||
remark: inputCtrl.text.trim(),
|
||||
),
|
||||
);
|
||||
IMViews.showToast(StrRes.saveSuccessfully);
|
||||
Get.back(result: inputCtrl.text.trim());
|
||||
} catch (_) {
|
||||
IMViews.showToast(StrRes.saveFailed);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
inputCtrl =
|
||||
TextEditingController(text: userProfilesLogic.userInfo.value.remark);
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
inputCtrl.dispose();
|
||||
super.onClose();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
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 'set_remark_logic.dart';
|
||||
|
||||
class SetFriendRemarkPage extends StatelessWidget {
|
||||
final logic = Get.find<SetFriendRemarkLogic>();
|
||||
|
||||
SetFriendRemarkPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: TitleBar.back(
|
||||
title: StrRes.remark,
|
||||
right: StrRes.save.toText
|
||||
..style = Styles.ts_0C1C33_17sp
|
||||
..onTap = logic.save,
|
||||
),
|
||||
backgroundColor: Styles.c_FFFFFF,
|
||||
body: Column(
|
||||
children: [
|
||||
22.verticalSpace,
|
||||
Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 10.w),
|
||||
decoration: BoxDecoration(
|
||||
color: Styles.c_E8EAEF,
|
||||
borderRadius: BorderRadius.circular(4.r),
|
||||
),
|
||||
child: TextField(
|
||||
controller: logic.inputCtrl,
|
||||
style: Styles.ts_0C1C33_17sp,
|
||||
autofocus: true,
|
||||
inputFormatters: [LengthLimitingTextInputFormatter(16)],
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 10.h,
|
||||
horizontal: 12.w,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:openim_common/openim_common.dart';
|
||||
|
||||
import 'user_profile _panel_logic.dart';
|
||||
|
||||
class UserProfilePanelBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => UserProfilePanelLogic(), tag: GetTags.userProfile);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,373 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:common_utils/common_utils.dart';
|
||||
import 'package:extended_image/extended_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:openim/routes/app_navigator.dart';
|
||||
import 'package:openim_common/openim_common.dart';
|
||||
import 'package:sprintf/sprintf.dart';
|
||||
import 'package:openim_live/openim_live.dart';
|
||||
|
||||
import '../../../core/controller/app_controller.dart';
|
||||
import '../../../core/controller/im_controller.dart';
|
||||
import '../../conversation/conversation_logic.dart';
|
||||
|
||||
class UserProfilePanelLogic extends GetxController {
|
||||
final appLogic = Get.find<AppController>();
|
||||
final imLogic = Get.find<IMController>();
|
||||
final conversationLogic = Get.find<ConversationLogic>();
|
||||
late Rx<UserFullInfo> userInfo;
|
||||
GroupMembersInfo? groupMembersInfo;
|
||||
GroupInfo? groupInfo;
|
||||
String? groupID;
|
||||
bool? offAllWhenDelFriend = false;
|
||||
bool? forceCanAdd = false;
|
||||
final iHasMutePermissions = false.obs;
|
||||
final iAmOwner = false.obs;
|
||||
final mutedTime = "".obs;
|
||||
final onlineStatus = false.obs;
|
||||
final onlineStatusDesc = ''.obs;
|
||||
final groupUserNickname = "".obs;
|
||||
final joinGroupTime = 0.obs;
|
||||
final joinGroupMethod = ''.obs;
|
||||
final hasAdminPermission = false.obs;
|
||||
final notAllowLookGroupMemberProfiles = true.obs;
|
||||
final notAllowAddGroupMemberFriend = false.obs;
|
||||
final iHaveAdminOrOwnerPermission = false.obs;
|
||||
late StreamSubscription _friendAddedSub;
|
||||
late StreamSubscription _friendDeletedSub;
|
||||
late StreamSubscription _friendInfoChangedSub;
|
||||
late StreamSubscription _memberInfoChangedSub;
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
_friendAddedSub.cancel();
|
||||
_friendInfoChangedSub.cancel();
|
||||
_memberInfoChangedSub.cancel();
|
||||
_friendDeletedSub.cancel();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
userInfo = (UserFullInfo()
|
||||
..userID = Get.arguments['userID']
|
||||
..nickname = Get.arguments['nickname']
|
||||
..faceURL = Get.arguments['faceURL'])
|
||||
.obs;
|
||||
groupID = Get.arguments['groupID'];
|
||||
offAllWhenDelFriend = Get.arguments['offAllWhenDelFriend'];
|
||||
forceCanAdd = Get.arguments['forceCanAdd'];
|
||||
|
||||
_friendAddedSub = imLogic.friendAddSubject.listen((user) {
|
||||
if (user.userID == userInfo.value.userID) {
|
||||
userInfo.update((val) {
|
||||
val?.isFriendship = true;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
_friendDeletedSub = imLogic.friendDelSubject.listen((user) {
|
||||
if (user.userID == userInfo.value.userID) {
|
||||
UserCacheManager().removeUserInfo(user.userID!);
|
||||
_getUsersInfo();
|
||||
}
|
||||
});
|
||||
|
||||
_friendInfoChangedSub = imLogic.friendInfoChangedSubject.listen((user) {
|
||||
if (user.userID == userInfo.value.userID) {
|
||||
userInfo.update((val) {
|
||||
val?.nickname = user.nickname;
|
||||
val?.remark = user.remark;
|
||||
});
|
||||
|
||||
UserCacheManager().addOrUpdateUserInfo(user.userID!, userInfo.value);
|
||||
}
|
||||
});
|
||||
|
||||
_memberInfoChangedSub = imLogic.memberInfoChangedSubject.listen((value) {
|
||||
if (value.userID == userInfo.value.userID) {
|
||||
if (null != value.muteEndTime) {
|
||||
_calMuteTime(value.muteEndTime!);
|
||||
}
|
||||
groupUserNickname.value = value.nickname ?? '';
|
||||
}
|
||||
});
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
_getUsersInfo();
|
||||
_queryGroupInfo();
|
||||
_queryGroupMemberInfo();
|
||||
|
||||
super.onReady();
|
||||
}
|
||||
|
||||
bool get isMyself => userInfo.value.userID == OpenIM.iMManager.userID;
|
||||
|
||||
bool get isGroupMemberPage => null != groupID && groupID!.isNotEmpty;
|
||||
|
||||
bool get isFriendship => userInfo.value.isFriendship == true;
|
||||
|
||||
bool get isAllowAddFriend => userInfo.value.allowAddFriend == 1;
|
||||
|
||||
bool get allowSendMsgNotFriend {
|
||||
final r = null == appLogic.clientConfigMap['allowSendMsgNotFriend'] ||
|
||||
appLogic.clientConfigMap['allowSendMsgNotFriend'] == '1';
|
||||
return r;
|
||||
}
|
||||
|
||||
void _getUsersInfo() async {
|
||||
final userID = userInfo.value.userID!;
|
||||
final existUser = UserCacheManager().getUserInfo(userID);
|
||||
if (existUser != null) {
|
||||
userInfo.update((val) {
|
||||
val?.nickname = existUser.nickname;
|
||||
val?.faceURL = existUser.faceURL;
|
||||
val?.status = existUser.status;
|
||||
val?.level = existUser.level;
|
||||
val?.phoneNumber = existUser.phoneNumber;
|
||||
val?.areaCode = existUser.areaCode;
|
||||
val?.birth = existUser.birth;
|
||||
val?.email = existUser.email;
|
||||
val?.gender = existUser.gender;
|
||||
val?.mobile = existUser.mobile;
|
||||
});
|
||||
}
|
||||
|
||||
if (userID == OpenIM.iMManager.userID) {
|
||||
final user = await OpenIM.iMManager.userManager.getSelfUserInfo();
|
||||
|
||||
userInfo.update((val) {
|
||||
val?.nickname = user.nickname;
|
||||
val?.faceURL = user.faceURL;
|
||||
});
|
||||
|
||||
UserCacheManager().addOrUpdateUserInfo(userID, userInfo.value);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
final friendInfo = (await OpenIM.iMManager.friendshipManager.getFriendsInfo(
|
||||
userIDList: [userID],
|
||||
))
|
||||
.firstOrNull;
|
||||
|
||||
final blackList = await OpenIM.iMManager.friendshipManager.getBlacklist();
|
||||
|
||||
final isFriendship = friendInfo != null;
|
||||
final isBlack = blackList.firstWhereOrNull((e) => e.userID == friendInfo?.userID) != null;
|
||||
|
||||
if (friendInfo == null) {
|
||||
final user = (await OpenIM.iMManager.userManager.getUsersInfoWithCache(
|
||||
[userID],
|
||||
))
|
||||
.firstOrNull;
|
||||
if (user != null) {
|
||||
userInfo.update((val) {
|
||||
val?.nickname = user.nickname;
|
||||
val?.faceURL = user.faceURL;
|
||||
val?.remark = friendInfo?.remark;
|
||||
val?.isBlacklist = isBlack;
|
||||
val?.isFriendship = isFriendship;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
userInfo.update((val) {
|
||||
val?.nickname = friendInfo.nickname;
|
||||
val?.faceURL = friendInfo.faceURL;
|
||||
val?.remark = friendInfo.remark;
|
||||
val?.isBlacklist = isBlack;
|
||||
val?.isFriendship = isFriendship;
|
||||
});
|
||||
}
|
||||
UserCacheManager().addOrUpdateUserInfo(userID, userInfo.value);
|
||||
|
||||
final list2 = await Apis.getUserFullInfo(userIDList: [userID]);
|
||||
final fullInfo = list2?.firstOrNull;
|
||||
|
||||
if (null != fullInfo) {
|
||||
userInfo.update((val) {
|
||||
val?.allowAddFriend = fullInfo.allowAddFriend;
|
||||
val?.status = fullInfo.status;
|
||||
val?.level = fullInfo.level;
|
||||
val?.phoneNumber = fullInfo.phoneNumber;
|
||||
val?.areaCode = fullInfo.areaCode;
|
||||
val?.birth = fullInfo.birth;
|
||||
val?.email = fullInfo.email;
|
||||
val?.gender = fullInfo.gender;
|
||||
val?.mobile = fullInfo.mobile;
|
||||
val?.nickname = fullInfo.nickname;
|
||||
val?.faceURL = fullInfo.faceURL;
|
||||
val?.remark = friendInfo?.remark;
|
||||
val?.isBlacklist = isBlack;
|
||||
val?.isFriendship = isFriendship;
|
||||
});
|
||||
|
||||
UserCacheManager().addOrUpdateUserInfo(userID, userInfo.value);
|
||||
}
|
||||
}
|
||||
|
||||
void _resetAvatar(String url) async {
|
||||
clearMemoryImageCache(keyToMd5(url));
|
||||
await clearDiskCachedImage(url);
|
||||
PaintingBinding.instance.imageCache.evict(keyToMd5(url));
|
||||
userInfo.refresh();
|
||||
}
|
||||
|
||||
_queryGroupInfo() async {
|
||||
if (isGroupMemberPage) {
|
||||
var list = await OpenIM.iMManager.groupManager.getGroupsInfo(
|
||||
groupIDList: [groupID!],
|
||||
);
|
||||
groupInfo = list.firstOrNull;
|
||||
|
||||
notAllowLookGroupMemberProfiles.value = groupInfo?.lookMemberInfo == 1;
|
||||
|
||||
notAllowAddGroupMemberFriend.value = groupInfo?.applyMemberFriend == 1;
|
||||
}
|
||||
}
|
||||
|
||||
_queryGroupMemberInfo() async {
|
||||
if (isGroupMemberPage) {
|
||||
final list = await OpenIM.iMManager.groupManager.getGroupMembersInfo(
|
||||
groupID: groupID!,
|
||||
userIDList: [userInfo.value.userID!, if (!isMyself) OpenIM.iMManager.userID],
|
||||
);
|
||||
final other = list.firstWhereOrNull((e) => e.userID == userInfo.value.userID);
|
||||
groupMembersInfo = other;
|
||||
groupUserNickname.value = other?.nickname ?? '';
|
||||
joinGroupTime.value = other?.joinTime ?? 0;
|
||||
|
||||
_getJoinGroupMethod(other);
|
||||
|
||||
hasAdminPermission.value = other?.roleLevel == GroupRoleLevel.admin;
|
||||
|
||||
if (!isMyself) {
|
||||
var me = list.firstWhereOrNull((e) => e.userID == OpenIM.iMManager.userID);
|
||||
|
||||
iAmOwner.value = me?.roleLevel == GroupRoleLevel.owner;
|
||||
|
||||
iHasMutePermissions.value = me?.roleLevel == GroupRoleLevel.owner ||
|
||||
(me?.roleLevel == GroupRoleLevel.admin && other?.roleLevel == GroupRoleLevel.member);
|
||||
|
||||
iHaveAdminOrOwnerPermission.value =
|
||||
me?.roleLevel == GroupRoleLevel.owner || me?.roleLevel == GroupRoleLevel.admin;
|
||||
}
|
||||
|
||||
if (null != other && null != other.muteEndTime && other.muteEndTime! > 0) {
|
||||
_calMuteTime(other.muteEndTime!);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_getJoinGroupMethod(GroupMembersInfo? other) async {
|
||||
if (other?.joinSource == 2) {
|
||||
if (other!.inviterUserID != null && other.inviterUserID != other.userID) {
|
||||
final list = await OpenIM.iMManager.groupManager.getGroupMembersInfo(
|
||||
groupID: groupID!,
|
||||
userIDList: [other.inviterUserID!],
|
||||
);
|
||||
var inviterUserInfo = list.firstOrNull;
|
||||
joinGroupMethod.value = sprintf(
|
||||
StrRes.byInviteJoinGroup,
|
||||
[inviterUserInfo?.nickname ?? ''],
|
||||
);
|
||||
}
|
||||
} else if (other?.joinSource == 3) {
|
||||
joinGroupMethod.value = StrRes.byIDJoinGroup;
|
||||
} else if (other?.joinSource == 4) {
|
||||
joinGroupMethod.value = StrRes.byQrcodeJoinGroup;
|
||||
}
|
||||
}
|
||||
|
||||
_calMuteTime(int time) {
|
||||
var date = DateUtil.formatDateMs(time, format: IMUtils.getTimeFormat2());
|
||||
var now = DateTime.now().millisecondsSinceEpoch ~/ 1000;
|
||||
var diff = time - now;
|
||||
if (diff > 0) {
|
||||
mutedTime.value = date;
|
||||
} else {
|
||||
mutedTime.value = "";
|
||||
}
|
||||
}
|
||||
|
||||
String getShowName() {
|
||||
if (isGroupMemberPage) {
|
||||
if (isFriendship) {
|
||||
if (null != IMUtils.emptyStrToNull(userInfo.value.remark)) {
|
||||
return '${groupUserNickname.value}(${IMUtils.emptyStrToNull(userInfo.value.remark)})';
|
||||
}
|
||||
}
|
||||
if (groupUserNickname.value.isEmpty) {
|
||||
return userInfo.value.nickname ??= "";
|
||||
}
|
||||
return groupUserNickname.value;
|
||||
}
|
||||
if (userInfo.value.remark != null && userInfo.value.remark!.isNotEmpty) {
|
||||
return '${userInfo.value.nickname}(${userInfo.value.remark})';
|
||||
}
|
||||
return userInfo.value.nickname ?? '';
|
||||
}
|
||||
|
||||
void toChat() {
|
||||
conversationLogic.toChat(
|
||||
userID: userInfo.value.userID,
|
||||
nickname: userInfo.value.showName,
|
||||
faceURL: userInfo.value.faceURL,
|
||||
);
|
||||
}
|
||||
|
||||
void toCall() {
|
||||
IMViews.openIMCallSheet(userInfo.value.showName, (index) {
|
||||
imLogic.call(
|
||||
callObj: CallObj.single,
|
||||
callType: index == 0 ? CallType.audio : CallType.video,
|
||||
inviteeUserIDList: [userInfo.value.userID!],
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
void copyID() {
|
||||
IMUtils.copy(text: userInfo.value.userID!);
|
||||
}
|
||||
|
||||
void addFriend() => AppNavigator.startSendVerificationApplication(
|
||||
userID: userInfo.value.userID!,
|
||||
);
|
||||
|
||||
void viewPersonalInfo() => AppNavigator.startPersonalInfo(
|
||||
userID: userInfo.value.userID!,
|
||||
);
|
||||
|
||||
void friendSetup() => AppNavigator.startFriendSetup(
|
||||
userID: userInfo.value.userID!,
|
||||
);
|
||||
}
|
||||
|
||||
class UserCacheManager {
|
||||
static final UserCacheManager _instance = UserCacheManager._();
|
||||
UserCacheManager._();
|
||||
final Map<String, UserFullInfo> _userInfoMap = {};
|
||||
|
||||
void addOrUpdateUserInfo(String userID, UserFullInfo userInfo) {
|
||||
_userInfoMap[userID] = userInfo;
|
||||
}
|
||||
|
||||
UserFullInfo? getUserInfo(String userID) {
|
||||
return _userInfoMap[userID];
|
||||
}
|
||||
|
||||
void removeUserInfo(String userID) {
|
||||
_userInfoMap.remove(userID);
|
||||
}
|
||||
|
||||
factory UserCacheManager() {
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,254 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:common_utils/common_utils.dart';
|
||||
import 'package:flutter/cupertino.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 'user_profile _panel_logic.dart';
|
||||
|
||||
class UserProfilePanelPage extends StatelessWidget {
|
||||
final logic = Get.find<UserProfilePanelLogic>(tag: GetTags.userProfile);
|
||||
|
||||
UserProfilePanelPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Obx(
|
||||
() => Scaffold(
|
||||
appBar: TitleBar.back(
|
||||
right: logic.isFriendship
|
||||
? (ImageRes.moreBlack.toImage
|
||||
..width = 24.w
|
||||
..height = 24.h
|
||||
..onTap = logic.friendSetup)
|
||||
: null,
|
||||
),
|
||||
backgroundColor: Styles.c_F8F9FA,
|
||||
body: SizedBox(
|
||||
height: 1.sh,
|
||||
child: Stack(
|
||||
children: [
|
||||
SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
_buildBaseInfoView(),
|
||||
if (logic.isGroupMemberPage) _buildEnterGroupMethodView(),
|
||||
if (logic.isFriendship ||
|
||||
logic.isMyself ||
|
||||
logic.isGroupMemberPage && !logic.notAllowLookGroupMemberProfiles.value)
|
||||
_buildItemView(
|
||||
label: StrRes.personalInfo,
|
||||
showRightArrow: true,
|
||||
onTap: logic.viewPersonalInfo,
|
||||
),
|
||||
SizedBox(height: 108.h),
|
||||
],
|
||||
),
|
||||
),
|
||||
if ((logic.isFriendship || logic.allowSendMsgNotFriend) && !logic.isMyself) _buildButtonGroup(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBaseInfoView() => Container(
|
||||
color: Styles.c_FFFFFF,
|
||||
height: 80.h,
|
||||
margin: EdgeInsets.only(bottom: 10.h),
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||||
child: Row(
|
||||
children: [
|
||||
AvatarView(
|
||||
url: logic.userInfo.value.faceURL,
|
||||
text: logic.userInfo.value.nickname,
|
||||
width: 48.w,
|
||||
height: 48.h,
|
||||
textStyle: Styles.ts_FFFFFF_14sp,
|
||||
enabledPreview: true,
|
||||
),
|
||||
12.horizontalSpace,
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
logic.getShowName().toText
|
||||
..style = Styles.ts_0C1C33_17sp_medium
|
||||
..maxLines = 1
|
||||
..overflow = TextOverflow.ellipsis,
|
||||
if (!logic.isGroupMemberPage || logic.isGroupMemberPage && !logic.notAllowAddGroupMemberFriend.value)
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 4.h),
|
||||
child: (logic.userInfo.value.userID ?? '').toText
|
||||
..style = Styles.ts_8E9AB0_14sp
|
||||
..onTap = logic.copyID,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (!logic.isMyself &&
|
||||
logic.isAllowAddFriend &&
|
||||
!logic.isFriendship &&
|
||||
(!logic.isGroupMemberPage ||
|
||||
logic.forceCanAdd == true ||
|
||||
logic.isGroupMemberPage && !logic.notAllowAddGroupMemberFriend.value))
|
||||
Material(
|
||||
child: Ink(
|
||||
decoration: BoxDecoration(
|
||||
color: Styles.c_0089FF,
|
||||
borderRadius: BorderRadius.circular(6.r),
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: logic.addFriend,
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 9.w,
|
||||
vertical: 4.h,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
ImageRes.addContacts.toImage
|
||||
..width = 21.w
|
||||
..height = 21.h
|
||||
..color = Styles.c_FFFFFF,
|
||||
2.horizontalSpace,
|
||||
StrRes.add.toText..style = Styles.ts_FFFFFF_14sp,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
Widget _buildEnterGroupMethodView() {
|
||||
if (logic.joinGroupTime.value == 0 && logic.joinGroupMethod.value.isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
return Container(
|
||||
color: Styles.c_FFFFFF,
|
||||
margin: EdgeInsets.only(bottom: 10.h),
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 8.h),
|
||||
child: Table(
|
||||
defaultVerticalAlignment: TableCellVerticalAlignment.top,
|
||||
columnWidths: {0: FixedColumnWidth(100.w)},
|
||||
children: [
|
||||
if (logic.joinGroupTime.value > 0)
|
||||
_buildTabRowView(
|
||||
label: StrRes.joinGroupDate,
|
||||
value: DateUtil.formatDateMs(
|
||||
logic.joinGroupTime.value,
|
||||
format: DateFormats.zh_y_mo_d,
|
||||
),
|
||||
),
|
||||
if (logic.joinGroupMethod.value.isNotEmpty)
|
||||
_buildTabRowView(
|
||||
label: StrRes.joinGroupMethod,
|
||||
value: logic.joinGroupMethod.value,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
TableRow _buildTabRowView({
|
||||
required String label,
|
||||
String? value,
|
||||
}) =>
|
||||
TableRow(
|
||||
children: [
|
||||
TableCell(
|
||||
child: Container(
|
||||
constraints: BoxConstraints(minHeight: 40.h),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: label.toText..style = Styles.ts_8E9AB0_17sp,
|
||||
),
|
||||
),
|
||||
TableCell(
|
||||
child: Container(
|
||||
constraints: BoxConstraints(minHeight: 40.h),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: (value ?? '').toText..style = Styles.ts_0C1C33_17sp,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
Widget _buildItemView({
|
||||
required String label,
|
||||
String? value,
|
||||
bool addMargin = false,
|
||||
bool showSwitchButton = false,
|
||||
bool showRightArrow = false,
|
||||
bool switchOn = false,
|
||||
ValueChanged<bool>? onChanged,
|
||||
Function()? onTap,
|
||||
}) =>
|
||||
Container(
|
||||
margin: EdgeInsets.only(bottom: addMargin ? 10.h : 0),
|
||||
child: Ink(
|
||||
color: Styles.c_FFFFFF,
|
||||
height: 56.h,
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||||
child: Row(
|
||||
children: [
|
||||
label.toText..style = Styles.ts_0C1C33_17sp,
|
||||
const Spacer(),
|
||||
if (showSwitchButton)
|
||||
CupertinoSwitch(
|
||||
value: switchOn,
|
||||
activeColor: Styles.c_0089FF,
|
||||
onChanged: onChanged,
|
||||
),
|
||||
if (null != value) value.toText..style = Styles.ts_0C1C33_17sp,
|
||||
if (showRightArrow)
|
||||
ImageRes.rightArrow.toImage
|
||||
..width = 24.w
|
||||
..height = 24.h,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Widget _buildButtonGroup() => Positioned(
|
||||
bottom: 0.h,
|
||||
width: 1.sw,
|
||||
child: ClipRRect(
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 4, sigmaY: 4),
|
||||
child: Container(
|
||||
color: Styles.c_F8F9FA.withOpacity(.3),
|
||||
padding: EdgeInsets.symmetric(horizontal: 9.w),
|
||||
height: 108.h,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ImageTextButton.call(
|
||||
onTap: logic.toCall,
|
||||
),
|
||||
),
|
||||
11.horizontalSpace,
|
||||
Expanded(
|
||||
child: ImageTextButton.message(
|
||||
onTap: logic.toChat,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user