2024-04-10 15:59:44 +08:00
|
|
|
|
|
2023-07-18 18:10:57 +08:00
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
|
|
import 'package:get/get.dart';
|
2024-03-07 17:59:22 +08:00
|
|
|
|
import 'package:permission_handler/permission_handler.dart';
|
2023-07-18 18:10:57 +08:00
|
|
|
|
import 'package:star_lock/app_settings/app_colors.dart';
|
2023-10-11 18:24:52 +08:00
|
|
|
|
import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_logic.dart';
|
|
|
|
|
|
import 'package:star_lock/tools/custom_bottom_sheet.dart';
|
2024-04-10 16:04:33 +08:00
|
|
|
|
|
2023-07-18 18:10:57 +08:00
|
|
|
|
import '../../../appRouters.dart';
|
|
|
|
|
|
import '../../../tools/commonItem.dart';
|
2024-04-09 15:21:10 +08:00
|
|
|
|
import '../../../tools/customNetworkImage.dart';
|
2023-07-18 18:10:57 +08:00
|
|
|
|
import '../../../tools/titleAppBar.dart';
|
|
|
|
|
|
import '../../../translations/trans_lib.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class MinePersonInfoPage extends StatefulWidget {
|
|
|
|
|
|
const MinePersonInfoPage({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
State<MinePersonInfoPage> createState() => _MinePersonInfoPageState();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-04-10 15:59:44 +08:00
|
|
|
|
class _MinePersonInfoPageState extends State<MinePersonInfoPage> {
|
2023-10-09 18:45:10 +08:00
|
|
|
|
final logic = Get.put(MinePersonInfoLogic());
|
|
|
|
|
|
final state = Get.find<MinePersonInfoLogic>().state;
|
|
|
|
|
|
|
2023-07-18 18:10:57 +08:00
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
return Scaffold(
|
|
|
|
|
|
backgroundColor: AppColors.mainBackgroundColor,
|
2023-07-27 15:26:30 +08:00
|
|
|
|
appBar: TitleAppBar(
|
|
|
|
|
|
barTitle: TranslationLoader.lanKeys!.personalInformation!.tr,
|
|
|
|
|
|
haveBack: true,
|
|
|
|
|
|
backgroundColor: AppColors.mainColor),
|
|
|
|
|
|
body: Column(
|
2023-07-18 18:10:57 +08:00
|
|
|
|
children: [
|
2024-04-10 13:36:00 +08:00
|
|
|
|
Obx(() => CommonItem(
|
2024-03-13 15:51:54 +08:00
|
|
|
|
leftTitel: TranslationLoader.lanKeys!.avatar!.tr,
|
|
|
|
|
|
rightTitle: "",
|
|
|
|
|
|
allHeight: 100.h,
|
|
|
|
|
|
isHaveLine: true,
|
|
|
|
|
|
isHaveDirection: true,
|
|
|
|
|
|
isHaveRightWidget: true,
|
2024-04-10 13:36:00 +08:00
|
|
|
|
rightWidget: ClipRRect(
|
|
|
|
|
|
borderRadius: BorderRadius.circular(36.w),
|
|
|
|
|
|
child: CustomNetworkImage(url:state.headUrl.value, defaultUrl: 'images/controls_user.png', width:72.w, height:72.w),
|
2024-03-13 15:51:54 +08:00
|
|
|
|
),
|
|
|
|
|
|
action: () async {
|
2024-04-10 15:21:08 +08:00
|
|
|
|
_openModalBottomSheet();
|
2024-03-13 15:51:54 +08:00
|
|
|
|
},
|
2024-04-10 13:36:00 +08:00
|
|
|
|
)),
|
2023-10-09 18:45:10 +08:00
|
|
|
|
Obx(() => CommonItem(
|
2023-07-27 15:26:30 +08:00
|
|
|
|
leftTitel: TranslationLoader.lanKeys!.nickName!.tr,
|
2024-04-09 10:52:30 +08:00
|
|
|
|
rightTitle: state.mineInfoData.value.nickname != null ? state.mineInfoData.value.nickname! : "",
|
2023-07-27 15:26:30 +08:00
|
|
|
|
isHaveLine: true,
|
|
|
|
|
|
isHaveDirection: true,
|
|
|
|
|
|
action: () {
|
2024-04-09 10:52:30 +08:00
|
|
|
|
Navigator.pushNamed(context, Routers.minePersonInfoEditNamePage,
|
2024-04-10 13:36:00 +08:00
|
|
|
|
arguments: {'mineInfoData': state.mineInfoData.value})
|
2024-04-09 10:52:30 +08:00
|
|
|
|
.then((value) => logic.getUserInfoRequest());
|
2023-10-09 18:45:10 +08:00
|
|
|
|
})),
|
|
|
|
|
|
Obx(() => CommonItem(
|
|
|
|
|
|
leftTitel: TranslationLoader.lanKeys!.mobileNumber!.tr,
|
2024-03-05 09:29:49 +08:00
|
|
|
|
rightTitle: state.mineInfoData.value.mobile != null
|
|
|
|
|
|
? state.mineInfoData.value.mobile!
|
2023-10-09 18:52:42 +08:00
|
|
|
|
: TranslationLoader.lanKeys!.goBind!.tr,
|
2023-07-27 15:26:30 +08:00
|
|
|
|
isHaveLine: true,
|
|
|
|
|
|
isHaveDirection: true,
|
|
|
|
|
|
action: () {
|
2023-10-09 18:45:10 +08:00
|
|
|
|
//有手机号 则去修改手机号 否则去绑定新的手机号 isFrom:1 短信,2 邮箱
|
2024-03-05 09:29:49 +08:00
|
|
|
|
if (state.mineInfoData.value.mobile!.isNotEmpty) {
|
2024-04-09 10:52:30 +08:00
|
|
|
|
Navigator.pushNamed(context, Routers.mineUnbindPhoneOrEmailPage,
|
|
|
|
|
|
arguments: {'mobile': state.mineInfoData.value.mobile!, 'isFrom': '1'})
|
|
|
|
|
|
.then((value) => logic.getUserInfoRequest());
|
2023-10-09 18:45:10 +08:00
|
|
|
|
} else {
|
2024-04-09 10:52:30 +08:00
|
|
|
|
Navigator.pushNamed(context, Routers.mineBindPhoneOrEmailPage,
|
|
|
|
|
|
arguments: {'mobile': state.mineInfoData.value.mobile!, 'isFrom': '1'})
|
|
|
|
|
|
.then((value) => logic.getUserInfoRequest());
|
2023-10-09 18:45:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
})),
|
|
|
|
|
|
Obx(() => CommonItem(
|
2023-07-27 15:26:30 +08:00
|
|
|
|
leftTitel: TranslationLoader.lanKeys!.email!.tr,
|
2024-03-05 09:29:49 +08:00
|
|
|
|
rightTitle: state.mineInfoData.value.email != null
|
|
|
|
|
|
? state.mineInfoData.value.email!
|
2023-10-09 18:52:42 +08:00
|
|
|
|
: TranslationLoader.lanKeys!.goBind!.tr,
|
2023-07-27 15:26:30 +08:00
|
|
|
|
isHaveLine: true,
|
|
|
|
|
|
isHaveDirection: true,
|
|
|
|
|
|
action: () {
|
2023-10-09 18:45:10 +08:00
|
|
|
|
//有邮箱 则去修改邮箱 否则去绑定新的邮箱 isFrom:1 短信,2 邮箱
|
2024-03-05 09:29:49 +08:00
|
|
|
|
if (state.mineInfoData.value.email!.isNotEmpty) {
|
2024-04-09 10:52:30 +08:00
|
|
|
|
Navigator.pushNamed(context, Routers.mineUnbindPhoneOrEmailPage,
|
|
|
|
|
|
arguments: {'isFrom': '2', 'email': state.mineInfoData.value.email!})
|
|
|
|
|
|
.then((value) => logic.getUserInfoRequest());
|
2023-10-09 18:45:10 +08:00
|
|
|
|
} else {
|
2024-04-09 10:52:30 +08:00
|
|
|
|
Navigator.pushNamed(context, Routers.mineBindPhoneOrEmailPage,
|
|
|
|
|
|
arguments: {'isFrom': '2', 'email': state.mineInfoData.value.email!})
|
|
|
|
|
|
.then((value) => logic.getUserInfoRequest());
|
2023-10-09 18:45:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
})),
|
2023-07-27 15:26:30 +08:00
|
|
|
|
CommonItem(
|
|
|
|
|
|
leftTitel: TranslationLoader.lanKeys!.resetPasswords!.tr,
|
|
|
|
|
|
rightTitle: "",
|
|
|
|
|
|
isHaveLine: true,
|
|
|
|
|
|
isHaveDirection: true,
|
|
|
|
|
|
action: () {
|
2024-04-09 10:52:30 +08:00
|
|
|
|
Navigator.pushNamed(context, Routers.minePersonInfoResetPasswordPage);
|
2023-07-27 15:26:30 +08:00
|
|
|
|
}),
|
2023-10-13 15:12:03 +08:00
|
|
|
|
Obx(() => CommonItem(
|
2023-07-27 15:26:30 +08:00
|
|
|
|
leftTitel: TranslationLoader.lanKeys!.safetyProblem!.tr,
|
2024-04-09 10:52:30 +08:00
|
|
|
|
rightTitle: state.mineInfoData.value.haveSafeAnswer == 0 ? "去设置" : "",
|
2023-07-27 15:26:30 +08:00
|
|
|
|
isHaveLine: true,
|
|
|
|
|
|
isHaveDirection: true,
|
|
|
|
|
|
action: () {
|
2024-03-05 09:29:49 +08:00
|
|
|
|
if (state.mineInfoData.value.haveSafeAnswer == 0) {
|
2024-04-09 10:52:30 +08:00
|
|
|
|
Navigator.pushNamed(context, Routers.minePersonInfoSetSafetyProblemPage)
|
2023-10-11 18:24:52 +08:00
|
|
|
|
.then((value) => logic.getUserInfoRequest());
|
|
|
|
|
|
} else {
|
2024-04-09 10:52:30 +08:00
|
|
|
|
Navigator.pushNamed(context, Routers.minePersonInfoViewSafetyProblemPage);
|
2023-10-11 18:24:52 +08:00
|
|
|
|
}
|
2023-10-13 15:12:03 +08:00
|
|
|
|
})),
|
2023-10-09 18:45:10 +08:00
|
|
|
|
Obx(() => CommonItem(
|
2023-07-27 15:26:30 +08:00
|
|
|
|
leftTitel: TranslationLoader.lanKeys!.countryAndRegion!.tr,
|
2024-04-09 10:52:30 +08:00
|
|
|
|
rightTitle: state.mineInfoData.value.countryName != null ? state.mineInfoData.value.countryName! : "",
|
2023-07-27 15:26:30 +08:00
|
|
|
|
isHaveLine: false,
|
2023-10-09 18:45:10 +08:00
|
|
|
|
isHaveDirection: false)),
|
2023-07-18 18:10:57 +08:00
|
|
|
|
],
|
2023-07-27 15:26:30 +08:00
|
|
|
|
));
|
2023-07-18 18:10:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-13 15:51:54 +08:00
|
|
|
|
|
2024-04-09 16:30:41 +08:00
|
|
|
|
|
2024-03-07 17:59:22 +08:00
|
|
|
|
|
2024-03-22 13:51:30 +08:00
|
|
|
|
|
2024-03-13 15:51:54 +08:00
|
|
|
|
// 显示权限被永久拒绝的提示对话框
|
|
|
|
|
|
void showPermissionDeniedDialog() {
|
2024-03-07 17:59:22 +08:00
|
|
|
|
showDialog(
|
|
|
|
|
|
context: context,
|
|
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
|
|
return AlertDialog(
|
2024-03-13 15:51:54 +08:00
|
|
|
|
title: const Text('权限被拒绝'),
|
|
|
|
|
|
content: const Text('请手动在系统设置中开启相册权限以继续使用应用。'),
|
2024-03-07 17:59:22 +08:00
|
|
|
|
actions: <Widget>[
|
|
|
|
|
|
TextButton(
|
2024-03-13 15:51:54 +08:00
|
|
|
|
child: const Text('去设置'),
|
2024-03-07 17:59:22 +08:00
|
|
|
|
onPressed: () {
|
2024-03-13 15:51:54 +08:00
|
|
|
|
Navigator.of(context).pop(); // 关闭对话框
|
2024-03-21 11:36:48 +08:00
|
|
|
|
openAppSettings(); // 打开系统设置页面
|
2024-03-07 17:59:22 +08:00
|
|
|
|
},
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
);
|
|
|
|
|
|
},
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-07-18 18:10:57 +08:00
|
|
|
|
Future _openModalBottomSheet() async {
|
2023-10-11 18:24:52 +08:00
|
|
|
|
showModalBottomSheet(
|
2023-07-18 18:10:57 +08:00
|
|
|
|
context: context,
|
2024-04-09 15:21:10 +08:00
|
|
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadiusDirectional.circular(10)),
|
2023-07-18 18:10:57 +08:00
|
|
|
|
builder: (BuildContext context) {
|
2023-10-11 18:24:52 +08:00
|
|
|
|
return AlertBottomWidget(
|
|
|
|
|
|
topTitle: '',
|
|
|
|
|
|
items: const ['拍照', '从相册选择'],
|
2024-04-10 15:21:08 +08:00
|
|
|
|
chooseCallback: logic.chooseCallback,
|
2023-07-18 18:10:57 +08:00
|
|
|
|
);
|
2023-07-27 15:26:30 +08:00
|
|
|
|
});
|
2023-07-18 18:10:57 +08:00
|
|
|
|
}
|
2023-10-11 18:24:52 +08:00
|
|
|
|
|
2024-04-09 16:30:41 +08:00
|
|
|
|
@override
|
|
|
|
|
|
void dispose() {
|
|
|
|
|
|
super.dispose();
|
|
|
|
|
|
}
|
2023-07-18 18:10:57 +08:00
|
|
|
|
}
|