252 lines
11 KiB
Dart
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/app_settings/app_colors.dart';
import 'package:star_lock/flavors.dart';
import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_entity.dart';
import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_logic.dart';
import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_state.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';
class MinePersonInfoPage extends StatefulWidget {
MinePersonInfoPage({Key? key, this.showAbout = false})
: super(key: key);
bool showAbout;
@override
State<MinePersonInfoPage> createState() => _MinePersonInfoPageState();
}
class _MinePersonInfoPageState extends State<MinePersonInfoPage> {
final MinePersonInfoLogic logic = Get.put(MinePersonInfoLogic());
final MinePersonInfoState state = Get.find<MinePersonInfoLogic>().state;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: F.sw(
skyCall: () => AppColors.mainBackgroundColor,
xhjCall: () => AppColors.mainBackgroundColor),
appBar: TitleAppBar(
barTitle: '个人信息'.tr,
haveBack: true,
backgroundColor: AppColors.mainColor),
body: Column(
children: <Widget>[
SizedBox(
height: 20.h,
),
Container(
margin: EdgeInsets.symmetric(vertical: 10.h, horizontal: 15.w),
child: ClipRRect(
borderRadius: BorderRadius.circular(20.r),
child: Column(
children: <Widget>[
Obx(() => CommonItem(
leftTitel: '头像'.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: '昵称'.tr,
rightTitle: state.mineInfoData.value.nickname != null
? state.mineInfoData.value.nickname!
: '',
isHaveLine: true,
isHaveDirection: true,
action: () {
Navigator.pushNamed(
context, Routers.minePersonInfoEditNamePage,
arguments: <String, MinePersonInfoData>{
'mineInfoData': state.mineInfoData.value
}).then((Object? value) => logic.getUserInfoRequest());
})),
Obx(() => CommonItem(
leftTitel: '手机号'.tr,
// rightTitle: (state.mineInfoData.value.mobile ?? '').isNotEmpty
// ? state.mineInfoData.value.mobile!
// : TranslationLoader.lanKeys!.goBind!.tr,
// rightWidget: Container(
// width: 15.w,
// height: 15.h,
// decoration: const BoxDecoration(
// color: Colors.red,
// shape: BoxShape.circle,
// ),
// ),
rightWidget:
(state.mineInfoData.value.mobile ?? '').isEmpty?
Container(
width: 15.w,
height: 15.h,
decoration: const BoxDecoration(
color: Colors.red,
shape: BoxShape.circle,
),
):
Text(
state.mineInfoData.value.mobile ?? '',
textAlign: TextAlign.right,
overflow: TextOverflow.ellipsis,
maxLines: 2,
style: TextStyle(
fontSize: 22.sp, color: AppColors.darkGrayTextColor),
),
isHaveRightWidget: true,
isHaveLine: true,
isHaveDirection: true,
action: () {
//有手机号 则去修改手机号 否则去绑定新的手机号 isFrom1 短信2 邮箱
if (state.mineInfoData.value.mobile!.isNotEmpty) {
Navigator.pushNamed(
context, Routers.mineUnbindPhoneOrEmailPage,
arguments: <String, String>{
'mobile': state.mineInfoData.value.mobile!,
'isFrom': '1'
}).then((Object? value) => logic.getUserInfoRequest());
} else {
Navigator.pushNamed(
context, Routers.mineBindPhoneOrEmailPage,
arguments: <String, String>{
'mobile': state.mineInfoData.value.mobile!,
'isFrom': '1'
}).then((Object? value) => logic.getUserInfoRequest());
}
})),
Obx(() => CommonItem(
leftTitel: '邮箱'.tr,
// rightTitle: (state.mineInfoData.value.email??'').isNotEmpty
// ? state.mineInfoData.value.email!
// : TranslationLoader.lanKeys!.goBind!.tr,
rightWidget:
(state.mineInfoData.value.email ?? '').isEmpty?
Container(
width: 15.w,
height: 15.h,
decoration: const BoxDecoration(
color: Colors.red,
shape: BoxShape.circle,
),
):
Text(
state.mineInfoData.value.email ?? '',
textAlign: TextAlign.right,
overflow: TextOverflow.ellipsis,
maxLines: 2,
style: TextStyle(
fontSize: 22.sp, color: AppColors.darkGrayTextColor),
),
isHaveRightWidget: true,
isHaveLine: true,
isHaveDirection: true,
action: () {
//有邮箱 则去修改邮箱 否则去绑定新的邮箱 isFrom1 短信2 邮箱
if (state.mineInfoData.value.email!.isNotEmpty) {
Navigator.pushNamed(
context, Routers.mineUnbindPhoneOrEmailPage,
arguments: <String, String>{
'isFrom': '2',
'email': state.mineInfoData.value.email!
}).then((Object? value) => logic.getUserInfoRequest());
} else {
Navigator.pushNamed(
context, Routers.mineBindPhoneOrEmailPage,
arguments: <String, String>{
'isFrom': '2',
'email': state.mineInfoData.value.email!
}).then((Object? value) => logic.getUserInfoRequest());
}
})),
CommonItem(
leftTitel: '重置密码'.tr,
rightTitle: '',
isHaveLine: true,
isHaveDirection: true,
action: () {
Navigator.pushNamed(
context, Routers.minePersonInfoResetPasswordPage);
}),
Obx(() => CommonItem(
leftTitel: '安全问题'.tr,
isHaveRightWidget: true,
// rightTitle: state.mineInfoData.value.haveSafeAnswer == 0
// ? '去设置'.tr
// : '',
rightWidget:
state.mineInfoData.value.haveSafeAnswer == 0 ?
Container(
width: 15.w,
height: 15.h,
decoration: const BoxDecoration(
color: Colors.red,
shape: BoxShape.circle,
),
):Container(),
isHaveLine: true,
isHaveDirection: true,
action: () {
if (state.mineInfoData.value.haveSafeAnswer == 0) {
Navigator.pushNamed(context,
Routers.minePersonInfoSetSafetyProblemPage)
.then((Object? value) => logic.getUserInfoRequest());
} else {
Navigator.pushNamed(context,
Routers.minePersonInfoViewSafetyProblemPage);
}
})),
Obx(() => CommonItem(
leftTitel: '国家/地区'.tr,
rightTitle: state.mineInfoData.value.countryName != null
? state.mineInfoData.value.countryName!
: '',
isHaveLine: true,
isHaveDirection: false)),
],
),
),
),
],
));
}
Future _openModalBottomSheet() async {
showModalBottomSheet(
context: context,
shape: RoundedRectangleBorder(
borderRadius: BorderRadiusDirectional.circular(10)),
builder: (BuildContext context) {
return AlertBottomWidget(
topTitle: '',
items: <String>['拍照'.tr, '从相册选择'.tr],
chooseCallback: logic.chooseCallback,
);
});
}
@override
void dispose() {
super.dispose();
}
}