fix(mobile-next): 收口我的信息只读字段显示
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter_datetime_picker_plus/flutter_datetime_picker_plus.dart';
|
|
||||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:openim/pages/login/login_logic.dart';
|
import 'package:openim/pages/login/login_logic.dart';
|
||||||
@@ -26,8 +25,6 @@ class MyInfoLogic extends GetxController {
|
|||||||
attr: EditAttr.mobile,
|
attr: EditAttr.mobile,
|
||||||
);
|
);
|
||||||
|
|
||||||
void editEmail() => AppNavigator.startEditMyInfo(attr: EditAttr.email, maxLength: 30);
|
|
||||||
|
|
||||||
void openPhotoSheet() {
|
void openPhotoSheet() {
|
||||||
IMViews.openPhotoSheet(
|
IMViews.openPhotoSheet(
|
||||||
onData: (path, url) async {
|
onData: (path, url) async {
|
||||||
@@ -43,62 +40,6 @@ class MyInfoLogic extends GetxController {
|
|||||||
quality: 15);
|
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
|
@override
|
||||||
void onReady() {
|
void onReady() {
|
||||||
_queryMyFullIno();
|
_queryMyFullIno();
|
||||||
|
|||||||
@@ -42,16 +42,18 @@ class MyInfoPage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
_buildItemView(
|
_buildItemView(
|
||||||
label: StrRes.gender,
|
label: StrRes.gender,
|
||||||
value: imLogic.userInfo.value.isMale ? StrRes.man : StrRes.woman,
|
value: _genderText(imLogic.userInfo.value.gender),
|
||||||
onTap: logic.selectGender,
|
showRightArrow: false,
|
||||||
),
|
),
|
||||||
_buildItemView(
|
_buildItemView(
|
||||||
label: StrRes.birthDay,
|
label: StrRes.birthDay,
|
||||||
value: DateUtil.formatDateMs(
|
value: imLogic.userInfo.value.birth == null
|
||||||
imLogic.userInfo.value.birth ?? 0,
|
? ''
|
||||||
|
: DateUtil.formatDateMs(
|
||||||
|
imLogic.userInfo.value.birth!,
|
||||||
format: IMUtils.getTimeFormat1(),
|
format: IMUtils.getTimeFormat1(),
|
||||||
),
|
),
|
||||||
onTap: logic.openDatePicker,
|
showRightArrow: false,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -68,7 +70,7 @@ class MyInfoPage extends StatelessWidget {
|
|||||||
_buildItemView(
|
_buildItemView(
|
||||||
label: StrRes.email,
|
label: StrRes.email,
|
||||||
value: imLogic.userInfo.value.email,
|
value: imLogic.userInfo.value.email,
|
||||||
onTap: logic.editEmail,
|
showRightArrow: false,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -93,6 +95,12 @@ class MyInfoPage extends StatelessWidget {
|
|||||||
child: Column(children: children),
|
child: Column(children: children),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
String _genderText(int? gender) {
|
||||||
|
if (gender == 1) return StrRes.man;
|
||||||
|
if (gender == 2) return StrRes.woman;
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildItemView({
|
Widget _buildItemView({
|
||||||
required String label,
|
required String label,
|
||||||
String? value,
|
String? value,
|
||||||
|
|||||||
Reference in New Issue
Block a user