2023-10-11 18:24:52 +08:00
|
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
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';
|
2023-10-11 18:24:52 +08:00
|
|
|
|
import 'package:image_picker/image_picker.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';
|
2023-07-18 18:10:57 +08:00
|
|
|
|
import '../../../appRouters.dart';
|
|
|
|
|
|
import '../../../tools/commonItem.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> {
|
2023-10-09 18:45:10 +08:00
|
|
|
|
final logic = Get.put(MinePersonInfoLogic());
|
|
|
|
|
|
final state = Get.find<MinePersonInfoLogic>().state;
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
void initState() {
|
|
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
|
|
|
|
logic.getUserInfoRequest();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
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: [
|
2023-07-27 15:26:30 +08:00
|
|
|
|
CommonItem(
|
|
|
|
|
|
leftTitel: TranslationLoader.lanKeys!.avatar!.tr,
|
|
|
|
|
|
rightTitle: "",
|
|
|
|
|
|
allHeight: 100.h,
|
|
|
|
|
|
isHaveLine: true,
|
|
|
|
|
|
isHaveDirection: true,
|
|
|
|
|
|
isHaveRightWidget: true,
|
2023-10-13 09:20:28 +08:00
|
|
|
|
rightWidget: ClipOval(
|
2023-10-11 18:24:52 +08:00
|
|
|
|
child: state.image != null
|
2023-10-13 09:20:28 +08:00
|
|
|
|
? Image.file(
|
|
|
|
|
|
File(state.image!.path),
|
|
|
|
|
|
width: 72.w,
|
|
|
|
|
|
height: 72.w,
|
|
|
|
|
|
fit: BoxFit.fill,
|
|
|
|
|
|
)
|
|
|
|
|
|
: Image.asset(
|
|
|
|
|
|
'images/controls_user.png',
|
|
|
|
|
|
width: 72.w,
|
|
|
|
|
|
height: 72.w,
|
|
|
|
|
|
fit: BoxFit.fill,
|
|
|
|
|
|
),
|
2023-10-11 18:24:52 +08:00
|
|
|
|
),
|
2023-07-27 15:26:30 +08:00
|
|
|
|
action: () {
|
|
|
|
|
|
_openModalBottomSheet();
|
|
|
|
|
|
},
|
|
|
|
|
|
),
|
2023-10-09 18:45:10 +08:00
|
|
|
|
Obx(() => CommonItem(
|
2023-07-27 15:26:30 +08:00
|
|
|
|
leftTitel: TranslationLoader.lanKeys!.nickName!.tr,
|
2023-10-09 18:45:10 +08:00
|
|
|
|
rightTitle: state.nickname.value,
|
2023-07-27 15:26:30 +08:00
|
|
|
|
isHaveLine: true,
|
|
|
|
|
|
isHaveDirection: true,
|
|
|
|
|
|
action: () {
|
|
|
|
|
|
Navigator.pushNamed(
|
2023-10-09 18:45:10 +08:00
|
|
|
|
context, Routers.minePersonInfoEditNamePage,
|
|
|
|
|
|
arguments: {'nickName': state.nickname.value})
|
|
|
|
|
|
.then((value) => logic.getUserInfoRequest());
|
|
|
|
|
|
})),
|
|
|
|
|
|
Obx(() => CommonItem(
|
|
|
|
|
|
leftTitel: TranslationLoader.lanKeys!.mobileNumber!.tr,
|
2023-10-09 18:52:42 +08:00
|
|
|
|
rightTitle: state.mobileStr.value.isNotEmpty
|
|
|
|
|
|
? state.mobileStr.value
|
|
|
|
|
|
: 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 邮箱
|
|
|
|
|
|
if (state.mobileStr.value.isNotEmpty) {
|
|
|
|
|
|
Navigator.pushNamed(
|
2023-10-11 18:24:52 +08:00
|
|
|
|
context, Routers.mineUnbindPhoneOrEmailPage,
|
2023-10-09 18:45:10 +08:00
|
|
|
|
arguments: {
|
|
|
|
|
|
'mobile': state.mobileStr.value,
|
|
|
|
|
|
'isFrom': '1'
|
2023-10-13 15:12:03 +08:00
|
|
|
|
}).then((value) => logic.getUserInfoRequest());
|
2023-10-09 18:45:10 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
Navigator.pushNamed(
|
2023-10-11 18:24:52 +08:00
|
|
|
|
context, Routers.mineBindPhoneOrEmailPage, arguments: {
|
|
|
|
|
|
'mobile': state.mobileStr.value,
|
|
|
|
|
|
'isFrom': '1'
|
2023-10-13 15:12:03 +08:00
|
|
|
|
}).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,
|
2023-10-09 18:52:42 +08:00
|
|
|
|
rightTitle: state.emailStr.value.isNotEmpty
|
|
|
|
|
|
? state.emailStr.value
|
|
|
|
|
|
: 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 邮箱
|
|
|
|
|
|
if (state.emailStr.value.isNotEmpty) {
|
|
|
|
|
|
Navigator.pushNamed(
|
2023-10-11 18:24:52 +08:00
|
|
|
|
context, Routers.mineUnbindPhoneOrEmailPage,
|
2023-10-09 18:45:10 +08:00
|
|
|
|
arguments: {
|
|
|
|
|
|
'isFrom': '2',
|
|
|
|
|
|
'email': state.emailStr.value
|
2023-10-13 15:12:03 +08:00
|
|
|
|
}).then((value) => logic.getUserInfoRequest());
|
2023-10-09 18:45:10 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
Navigator.pushNamed(
|
2023-10-11 18:24:52 +08:00
|
|
|
|
context, Routers.mineBindPhoneOrEmailPage, arguments: {
|
|
|
|
|
|
'isFrom': '2',
|
|
|
|
|
|
'email': state.emailStr.value
|
2023-10-13 15:12:03 +08:00
|
|
|
|
}).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: () {
|
|
|
|
|
|
Navigator.pushNamed(
|
|
|
|
|
|
context, Routers.minePersonInfoResetPasswordPage);
|
|
|
|
|
|
}),
|
2023-10-13 15:12:03 +08:00
|
|
|
|
Obx(() => CommonItem(
|
2023-07-27 15:26:30 +08:00
|
|
|
|
leftTitel: TranslationLoader.lanKeys!.safetyProblem!.tr,
|
2023-10-13 09:20:28 +08:00
|
|
|
|
rightTitle: state.haveSafeAnswer.value == 0 ? "去设置" : "",
|
2023-07-27 15:26:30 +08:00
|
|
|
|
isHaveLine: true,
|
|
|
|
|
|
isHaveDirection: true,
|
|
|
|
|
|
action: () {
|
2023-10-11 18:24:52 +08:00
|
|
|
|
if (state.haveSafeAnswer.value == 0) {
|
|
|
|
|
|
Navigator.pushNamed(
|
|
|
|
|
|
context, Routers.minePersonInfoSetSafetyProblemPage)
|
|
|
|
|
|
.then((value) => logic.getUserInfoRequest());
|
|
|
|
|
|
} else {
|
|
|
|
|
|
Navigator.pushNamed(
|
|
|
|
|
|
context, Routers.minePersonInfoViewSafetyProblemPage);
|
|
|
|
|
|
}
|
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,
|
2023-10-09 18:45:10 +08:00
|
|
|
|
rightTitle: state.countryStr.value,
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future _openModalBottomSheet() async {
|
2023-10-11 18:24:52 +08:00
|
|
|
|
showModalBottomSheet(
|
2023-07-18 18:10:57 +08:00
|
|
|
|
context: context,
|
2023-10-11 18:24:52 +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 ['拍照', '从相册选择'],
|
|
|
|
|
|
chooseCallback: (value) {
|
|
|
|
|
|
int getSelectIndex = value;
|
|
|
|
|
|
if (getSelectIndex == 0) {
|
|
|
|
|
|
//拍照选项
|
|
|
|
|
|
selectCamera();
|
|
|
|
|
|
} else if (getSelectIndex == 1) {
|
|
|
|
|
|
selectImage();
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
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
|
|
|
|
|
|
|
|
|
|
///拍摄照片
|
|
|
|
|
|
selectCamera() async {
|
|
|
|
|
|
XFile? photo = await state.imagePicker.pickImage(
|
|
|
|
|
|
source: ImageSource.camera, preferredCameraDevice: CameraDevice.rear);
|
|
|
|
|
|
if (photo != null) {
|
|
|
|
|
|
state.image = photo;
|
2023-10-13 09:20:28 +08:00
|
|
|
|
// logic.getUpTokenRequest();
|
2023-10-11 18:24:52 +08:00
|
|
|
|
setState(() {});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///从相册选取
|
|
|
|
|
|
selectImage() async {
|
|
|
|
|
|
XFile? image = await state.imagePicker.pickImage(
|
|
|
|
|
|
source: ImageSource.gallery,
|
|
|
|
|
|
maxHeight: 250,
|
|
|
|
|
|
maxWidth: 250,
|
|
|
|
|
|
);
|
|
|
|
|
|
if (image != null) state.image = image;
|
|
|
|
|
|
setState(() {});
|
|
|
|
|
|
}
|
2023-07-18 18:10:57 +08:00
|
|
|
|
}
|