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:
+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,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user