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 'my_info_logic.dart';
|
||||
|
||||
class MyInfoBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => MyInfoLogic());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
import 'package:flutter_datetime_picker_plus/flutter_datetime_picker_plus.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:openim/pages/login/login_logic.dart';
|
||||
import 'package:openim/pages/mine/edit_my_info/edit_my_info_logic.dart';
|
||||
import 'package:openim/routes/app_navigator.dart';
|
||||
import 'package:openim_common/openim_common.dart';
|
||||
|
||||
import '../../../core/controller/im_controller.dart';
|
||||
|
||||
class MyInfoLogic extends GetxController {
|
||||
final imLogic = Get.find<IMController>();
|
||||
final loginType = LoginType.fromRawValue(DataSp.getLoginType());
|
||||
|
||||
void editMyName() => AppNavigator.startEditMyInfo();
|
||||
|
||||
void editEnglishName() => AppNavigator.startEditMyInfo(
|
||||
attr: EditAttr.englishName,
|
||||
);
|
||||
|
||||
void editTel() => AppNavigator.startEditMyInfo(
|
||||
attr: EditAttr.telephone,
|
||||
);
|
||||
|
||||
void editMobile() => AppNavigator.startEditMyInfo(
|
||||
attr: EditAttr.mobile,
|
||||
);
|
||||
|
||||
void editEmail() => AppNavigator.startEditMyInfo(attr: EditAttr.email, maxLength: 30);
|
||||
|
||||
void openPhotoSheet() {
|
||||
IMViews.openPhotoSheet(
|
||||
onData: (path, url) async {
|
||||
if (url != null) {
|
||||
LoadingView.singleton.wrap(
|
||||
asyncFunction: () => Apis.updateUserInfo(userID: OpenIM.iMManager.userID, faceURL: url)
|
||||
.then((value) => imLogic.userInfo.update((val) {
|
||||
val?.faceURL = url;
|
||||
})),
|
||||
);
|
||||
}
|
||||
},
|
||||
quality: 15);
|
||||
}
|
||||
|
||||
void openDatePicker() {
|
||||
var appLocale = Get.locale;
|
||||
var isZh = appLocale!.languageCode.toLowerCase().contains("zh");
|
||||
DatePicker.showDatePicker(
|
||||
Get.context!,
|
||||
locale: isZh ? LocaleType.zh : LocaleType.en,
|
||||
maxTime: DateTime.now(),
|
||||
currentTime: DateTime.fromMillisecondsSinceEpoch(imLogic.userInfo.value.birth ?? 0),
|
||||
theme: DatePickerTheme(
|
||||
cancelStyle: Styles.ts_0C1C33_17sp,
|
||||
doneStyle: Styles.ts_0089FF_17sp,
|
||||
itemStyle: Styles.ts_0C1C33_17sp,
|
||||
),
|
||||
onConfirm: (dateTime) {
|
||||
_updateBirthday(dateTime.millisecondsSinceEpoch ~/ 1000);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void selectGender() {
|
||||
Get.bottomSheet(
|
||||
BottomSheetView(
|
||||
items: [
|
||||
SheetItem(
|
||||
label: StrRes.man,
|
||||
onTap: () => _updateGender(1),
|
||||
),
|
||||
SheetItem(
|
||||
label: StrRes.woman,
|
||||
onTap: () => _updateGender(2),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _updateGender(int gender) {
|
||||
LoadingView.singleton.wrap(
|
||||
asyncFunction: () => Apis.updateUserInfo(userID: OpenIM.iMManager.userID, gender: gender)
|
||||
.then((value) => imLogic.userInfo.update((val) {
|
||||
val?.gender = gender;
|
||||
})),
|
||||
);
|
||||
}
|
||||
|
||||
void _updateBirthday(int birthday) {
|
||||
LoadingView.singleton.wrap(
|
||||
asyncFunction: () => Apis.updateUserInfo(
|
||||
userID: OpenIM.iMManager.userID,
|
||||
birth: birthday * 1000,
|
||||
).then((value) => imLogic.userInfo.update((val) {
|
||||
val?.birth = birthday * 1000;
|
||||
})),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
_queryMyFullIno();
|
||||
super.onReady();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
void _queryMyFullIno() async {
|
||||
final info = await LoadingView.singleton.wrap(
|
||||
asyncFunction: () => Apis.queryMyFullInfo(),
|
||||
);
|
||||
if (null != info) {
|
||||
imLogic.userInfo.update((val) {
|
||||
val?.nickname = info.nickname;
|
||||
val?.faceURL = info.faceURL;
|
||||
val?.gender = info.gender;
|
||||
val?.phoneNumber = info.phoneNumber;
|
||||
val?.birth = info.birth;
|
||||
val?.email = info.email;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static _trimNullStr(String? value) => IMUtils.emptyStrToNull(value);
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
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 '../../../core/controller/im_controller.dart';
|
||||
import 'my_info_logic.dart';
|
||||
|
||||
class MyInfoPage extends StatelessWidget {
|
||||
final logic = Get.find<MyInfoLogic>();
|
||||
final imLogic = Get.find<IMController>();
|
||||
|
||||
MyInfoPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: TitleBar.back(
|
||||
title: StrRes.myInfo,
|
||||
),
|
||||
backgroundColor: Styles.c_F8F9FA,
|
||||
body: Obx(() => SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
10.verticalSpace,
|
||||
_buildCornerBgView(
|
||||
children: [
|
||||
_buildItemView(
|
||||
label: StrRes.avatar,
|
||||
isAvatar: true,
|
||||
value: imLogic.userInfo.value.nickname,
|
||||
url: imLogic.userInfo.value.faceURL,
|
||||
onTap: logic.openPhotoSheet,
|
||||
),
|
||||
_buildItemView(
|
||||
label: StrRes.name,
|
||||
value: imLogic.userInfo.value.nickname,
|
||||
onTap: logic.editMyName,
|
||||
),
|
||||
_buildItemView(
|
||||
label: StrRes.gender,
|
||||
value: imLogic.userInfo.value.isMale ? StrRes.man : StrRes.woman,
|
||||
onTap: logic.selectGender,
|
||||
),
|
||||
_buildItemView(
|
||||
label: StrRes.birthDay,
|
||||
value: DateUtil.formatDateMs(
|
||||
imLogic.userInfo.value.birth ?? 0,
|
||||
format: IMUtils.getTimeFormat1(),
|
||||
),
|
||||
onTap: logic.openDatePicker,
|
||||
),
|
||||
],
|
||||
),
|
||||
10.verticalSpace,
|
||||
_buildCornerBgView(
|
||||
children: [
|
||||
_buildItemView(
|
||||
label: StrRes.mobile,
|
||||
value: imLogic.userInfo.value.phoneNumber,
|
||||
showRightArrow: false,
|
||||
),
|
||||
_buildItemView(
|
||||
label: StrRes.email,
|
||||
value: imLogic.userInfo.value.email,
|
||||
onTap: logic.editEmail,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
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,
|
||||
bool showRightArrow = true,
|
||||
Function()? onTap,
|
||||
}) =>
|
||||
GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: showRightArrow ? onTap : null,
|
||||
child: SizedBox(
|
||||
height: 46.h,
|
||||
child: Row(
|
||||
children: [
|
||||
label.toText..style = Styles.ts_0C1C33_17sp,
|
||||
const Spacer(),
|
||||
if (isAvatar)
|
||||
AvatarView(
|
||||
width: 32.w,
|
||||
height: 32.h,
|
||||
url: url,
|
||||
text: value,
|
||||
textStyle: Styles.ts_FFFFFF_10sp,
|
||||
)
|
||||
else
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: (IMUtils.emptyStrToNull(value) ?? '').toText
|
||||
..style = Styles.ts_0C1C33_17sp
|
||||
..maxLines = 1
|
||||
..overflow = TextOverflow.ellipsis
|
||||
..textAlign = TextAlign.right),
|
||||
if (showRightArrow)
|
||||
ImageRes.rightArrow.toImage
|
||||
..width = 24.w
|
||||
..height = 24.h,
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user