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 'account_setup_logic.dart';
|
||||
|
||||
class AccountSetupBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => AccountSetupLogic());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
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 AccountSetupLogic extends GetxController {
|
||||
final imLogic = Get.find<IMController>();
|
||||
final curLanguage = "".obs;
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
_updateLanguage();
|
||||
super.onReady();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
_queryMyFullInfo();
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
bool get isGlobalNotDisturb => imLogic.userInfo.value.globalRecvMsgOpt == 2;
|
||||
|
||||
bool get isAllowAddFriend => imLogic.userInfo.value.allowAddFriend == 1;
|
||||
|
||||
bool get isAllowBeep => imLogic.userInfo.value.allowBeep == 1;
|
||||
|
||||
bool get isAllowVibration => imLogic.userInfo.value.allowVibration == 1;
|
||||
|
||||
void _queryMyFullInfo() async {
|
||||
final data = await LoadingView.singleton.wrap(
|
||||
asyncFunction: () => Apis.queryMyFullInfo(),
|
||||
);
|
||||
if (data is UserFullInfo) {
|
||||
final userInfo = UserFullInfo.fromJson(data.toJson());
|
||||
imLogic.userInfo.update((val) {
|
||||
val?.allowAddFriend = userInfo.allowAddFriend;
|
||||
val?.allowBeep = userInfo.allowBeep;
|
||||
val?.allowVibration = userInfo.allowVibration;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void toggleNotDisturbMode() async {
|
||||
var status = isGlobalNotDisturb ? 0 : 2;
|
||||
await LoadingView.singleton
|
||||
.wrap(asyncFunction: () => OpenIM.iMManager.userManager.setGlobalRecvMessageOpt(status: status));
|
||||
imLogic.userInfo.update((val) {
|
||||
val?.globalRecvMsgOpt = status;
|
||||
});
|
||||
}
|
||||
|
||||
void toggleBeep() async {
|
||||
final allowBeep = !isAllowBeep ? 1 : 2;
|
||||
|
||||
await LoadingView.singleton.wrap(
|
||||
asyncFunction: () => Apis.updateUserInfo(
|
||||
allowBeep: allowBeep,
|
||||
userID: OpenIM.iMManager.userID,
|
||||
),
|
||||
);
|
||||
imLogic.userInfo.update((val) {
|
||||
val?.allowBeep = allowBeep;
|
||||
});
|
||||
}
|
||||
|
||||
void toggleVibration() async {
|
||||
final allowVibration = !isAllowVibration ? 1 : 2;
|
||||
|
||||
await LoadingView.singleton.wrap(
|
||||
asyncFunction: () => Apis.updateUserInfo(
|
||||
allowVibration: allowVibration,
|
||||
userID: OpenIM.iMManager.userID,
|
||||
),
|
||||
);
|
||||
imLogic.userInfo.update((val) {
|
||||
val?.allowVibration = allowVibration;
|
||||
});
|
||||
}
|
||||
|
||||
void toggleForbidAddMeToFriend() async {
|
||||
final allowAddFriend = !isAllowAddFriend ? 1 : 2;
|
||||
|
||||
final data = await LoadingView.singleton.wrap(
|
||||
asyncFunction: () => Apis.updateUserInfo(
|
||||
allowAddFriend: allowAddFriend,
|
||||
userID: OpenIM.iMManager.userID,
|
||||
),
|
||||
);
|
||||
imLogic.userInfo.update((val) {
|
||||
val?.allowAddFriend = allowAddFriend;
|
||||
});
|
||||
}
|
||||
|
||||
void blacklist() => AppNavigator.startBlacklist();
|
||||
|
||||
void clearChatHistory() async {
|
||||
var confirm = await Get.dialog(CustomDialog(
|
||||
title: StrRes.confirmClearChatHistory,
|
||||
));
|
||||
if (confirm == true) {
|
||||
LoadingView.singleton.wrap(asyncFunction: () async {
|
||||
await OpenIM.iMManager.messageManager.deleteAllMsgFromLocalAndSvr();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void languageSetting() => AppNavigator.startLanguageSetup();
|
||||
|
||||
void _updateLanguage() {
|
||||
var index = DataSp.getLanguage() ?? 0;
|
||||
switch (index) {
|
||||
case 1:
|
||||
curLanguage.value = StrRes.chinese;
|
||||
break;
|
||||
case 2:
|
||||
curLanguage.value = StrRes.english;
|
||||
break;
|
||||
default:
|
||||
curLanguage.value = StrRes.followSystem;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void unlockSetup() => AppNavigator.startUnlockSetup();
|
||||
|
||||
void changePwd() => AppNavigator.startChangePassword();
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
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 'account_setup_logic.dart';
|
||||
|
||||
class AccountSetupPage extends StatelessWidget {
|
||||
final logic = Get.find<AccountSetupLogic>();
|
||||
|
||||
AccountSetupPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: TitleBar.back(
|
||||
title: StrRes.accountSetup,
|
||||
),
|
||||
backgroundColor: Styles.c_F8F9FA,
|
||||
body: Obx(() => SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
10.verticalSpace,
|
||||
_buildItemView(
|
||||
label: StrRes.notDisturbMode,
|
||||
switchOn: logic.isGlobalNotDisturb,
|
||||
onChanged: (_) => logic.toggleNotDisturbMode(),
|
||||
showSwitchButton: true,
|
||||
isTopRadius: true,
|
||||
),
|
||||
_buildItemView(
|
||||
label: StrRes.allowRing,
|
||||
switchOn: logic.isAllowBeep,
|
||||
onChanged: (_) => logic.toggleBeep(),
|
||||
showSwitchButton: true,
|
||||
),
|
||||
_buildItemView(
|
||||
label: StrRes.allowVibrate,
|
||||
switchOn: logic.isAllowVibration,
|
||||
onChanged: (_) => logic.toggleVibration(),
|
||||
showSwitchButton: true,
|
||||
isBottomRadius: true,
|
||||
),
|
||||
10.verticalSpace,
|
||||
_buildItemView(
|
||||
label: StrRes.forbidAddMeToFriend,
|
||||
switchOn: !logic.isAllowAddFriend,
|
||||
onChanged: (_) => logic.toggleForbidAddMeToFriend(),
|
||||
showSwitchButton: true,
|
||||
isTopRadius: true,
|
||||
),
|
||||
_buildItemView(
|
||||
label: StrRes.blacklist,
|
||||
onTap: logic.blacklist,
|
||||
showRightArrow: true,
|
||||
),
|
||||
_buildItemView(
|
||||
label: StrRes.languageSetup,
|
||||
value: logic.curLanguage.value,
|
||||
onTap: logic.languageSetting,
|
||||
showRightArrow: true,
|
||||
isBottomRadius: true,
|
||||
),
|
||||
10.verticalSpace,
|
||||
_buildItemView(
|
||||
label: StrRes.unlockSettings,
|
||||
onTap: logic.unlockSetup,
|
||||
showRightArrow: true,
|
||||
isTopRadius: true,
|
||||
),
|
||||
_buildItemView(
|
||||
label: StrRes.changePassword,
|
||||
showRightArrow: true,
|
||||
onTap: logic.changePwd,
|
||||
),
|
||||
_buildItemView(
|
||||
label: StrRes.clearChatHistory,
|
||||
textStyle: Styles.ts_FF381F_17sp,
|
||||
onTap: logic.clearChatHistory,
|
||||
showRightArrow: true,
|
||||
isBottomRadius: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildItemView({
|
||||
required String label,
|
||||
TextStyle? textStyle,
|
||||
String? value,
|
||||
bool switchOn = false,
|
||||
bool isTopRadius = false,
|
||||
bool isBottomRadius = false,
|
||||
bool showRightArrow = false,
|
||||
bool showSwitchButton = false,
|
||||
ValueChanged<bool>? onChanged,
|
||||
Function()? onTap,
|
||||
}) =>
|
||||
Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 10.w),
|
||||
child: Ink(
|
||||
decoration: BoxDecoration(
|
||||
color: Styles.c_FFFFFF,
|
||||
borderRadius: BorderRadius.only(
|
||||
topRight: Radius.circular(isTopRadius ? 6.r : 0),
|
||||
topLeft: Radius.circular(isTopRadius ? 6.r : 0),
|
||||
bottomLeft: Radius.circular(isBottomRadius ? 6.r : 0),
|
||||
bottomRight: Radius.circular(isBottomRadius ? 6.r : 0),
|
||||
),
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
height: 46.h,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||||
child: Row(
|
||||
children: [
|
||||
label.toText..style = textStyle ?? Styles.ts_0C1C33_17sp,
|
||||
const Spacer(),
|
||||
if (showSwitchButton)
|
||||
CupertinoSwitch(
|
||||
value: switchOn,
|
||||
activeColor: Styles.c_0089FF,
|
||||
onChanged: onChanged,
|
||||
),
|
||||
if (showRightArrow)
|
||||
ImageRes.rightArrow.toImage
|
||||
..width = 24.w
|
||||
..height = 24.h,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user