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