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 'edit_my_info_logic.dart';
|
||||
|
||||
class EditMyInfoBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => EditMyInfoLogic());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
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 '../../../core/controller/im_controller.dart';
|
||||
|
||||
enum EditAttr {
|
||||
nickname,
|
||||
englishName,
|
||||
telephone,
|
||||
mobile,
|
||||
email,
|
||||
}
|
||||
|
||||
class EditMyInfoLogic extends GetxController {
|
||||
final imLogic = Get.find<IMController>();
|
||||
late TextEditingController inputCtrl;
|
||||
late EditAttr editAttr;
|
||||
late int maxLength;
|
||||
String? title;
|
||||
String? defaultValue;
|
||||
TextInputType? keyboardType;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
editAttr = Get.arguments['editAttr'];
|
||||
maxLength = Get.arguments['maxLength'] ?? 16;
|
||||
_initAttr();
|
||||
inputCtrl = TextEditingController(text: defaultValue);
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
_initAttr() {
|
||||
switch (editAttr) {
|
||||
case EditAttr.nickname:
|
||||
title = StrRes.name;
|
||||
defaultValue = imLogic.userInfo.value.nickname;
|
||||
keyboardType = TextInputType.text;
|
||||
break;
|
||||
case EditAttr.englishName:
|
||||
break;
|
||||
case EditAttr.telephone:
|
||||
break;
|
||||
case EditAttr.mobile:
|
||||
title = StrRes.mobile;
|
||||
defaultValue = imLogic.userInfo.value.phoneNumber;
|
||||
keyboardType = TextInputType.phone;
|
||||
break;
|
||||
case EditAttr.email:
|
||||
title = StrRes.email;
|
||||
defaultValue = imLogic.userInfo.value.email;
|
||||
keyboardType = TextInputType.emailAddress;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void save() async {
|
||||
final value = inputCtrl.text.trim();
|
||||
if (editAttr == EditAttr.nickname) {
|
||||
await LoadingView.singleton.wrap(
|
||||
asyncFunction: () => Apis.updateUserInfo(
|
||||
userID: OpenIM.iMManager.userID,
|
||||
nickname: value,
|
||||
),
|
||||
);
|
||||
imLogic.userInfo.update((val) {
|
||||
val?.nickname = value;
|
||||
});
|
||||
} else if (editAttr == EditAttr.mobile) {
|
||||
await LoadingView.singleton.wrap(
|
||||
asyncFunction: () => Apis.updateUserInfo(
|
||||
userID: OpenIM.iMManager.userID,
|
||||
phoneNumber: value,
|
||||
),
|
||||
);
|
||||
imLogic.userInfo.update((val) {
|
||||
val?.phoneNumber = value;
|
||||
});
|
||||
} else if (editAttr == EditAttr.email) {
|
||||
if (defaultValue?.isNotEmpty == true && value.isEmpty) {
|
||||
IMViews.showToast(StrRes.plsEnterEmail);
|
||||
return;
|
||||
}
|
||||
await LoadingView.singleton.wrap(
|
||||
asyncFunction: () => Apis.updateUserInfo(
|
||||
userID: OpenIM.iMManager.userID,
|
||||
email: value,
|
||||
),
|
||||
);
|
||||
imLogic.userInfo.update((val) {
|
||||
val?.email = value;
|
||||
});
|
||||
}
|
||||
Get.back();
|
||||
}
|
||||
}
|
||||
@@ -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 'edit_my_info_logic.dart';
|
||||
|
||||
class EditMyInfoPage extends StatelessWidget {
|
||||
final logic = Get.find<EditMyInfoLogic>();
|
||||
EditMyInfoPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: TitleBar.back(
|
||||
title: logic.title,
|
||||
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,
|
||||
keyboardType: logic.keyboardType,
|
||||
inputFormatters: [LengthLimitingTextInputFormatter(logic.maxLength)],
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 10.h,
|
||||
horizontal: 12.w,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user