Daisy 12ecefa5d8 1,修改手机号、邮箱逻辑完善及请求处理
2,新增修改绑定手机号/邮箱
3,新增获取安全信息列表接口
4,新增获取已设置的安全信息接口
5,新增设置安全信息接口
6,新增获取解绑手机号Token
7,新增获取解绑邮箱Token
2023-10-11 18:24:52 +08:00

196 lines
7.1 KiB
Dart
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 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:image_picker/image_picker.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/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
void initState() {
super.initState();
logic.getUserInfoRequest();
}
@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: [
CommonItem(
leftTitel: TranslationLoader.lanKeys!.avatar!.tr,
rightTitle: "",
allHeight: 100.h,
isHaveLine: true,
isHaveDirection: true,
isHaveRightWidget: true,
rightWidget: SizedBox(
width: 75.w,
height: 75.h,
child: state.image != null
? Image.file(state.image as File)
: Image.asset('images/controls_user.png'),
),
action: () {
_openModalBottomSheet();
},
),
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.nickName!.tr,
rightTitle: state.nickname.value,
isHaveLine: true,
isHaveDirection: true,
action: () {
Navigator.pushNamed(
context, Routers.minePersonInfoEditNamePage,
arguments: {'nickName': state.nickname.value})
.then((value) => logic.getUserInfoRequest());
})),
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.mobileNumber!.tr,
rightTitle: state.mobileStr.value.isNotEmpty
? state.mobileStr.value
: TranslationLoader.lanKeys!.goBind!.tr,
isHaveLine: true,
isHaveDirection: true,
action: () {
//有手机号 则去修改手机号 否则去绑定新的手机号 isFrom1 短信2 邮箱
if (state.mobileStr.value.isNotEmpty) {
Navigator.pushNamed(
context, Routers.mineUnbindPhoneOrEmailPage,
arguments: {
'mobile': state.mobileStr.value,
'isFrom': '1'
});
} else {
Navigator.pushNamed(
context, Routers.mineBindPhoneOrEmailPage, arguments: {
'mobile': state.mobileStr.value,
'isFrom': '1'
});
}
})),
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.email!.tr,
rightTitle: state.emailStr.value.isNotEmpty
? state.emailStr.value
: TranslationLoader.lanKeys!.goBind!.tr,
isHaveLine: true,
isHaveDirection: true,
action: () {
//有邮箱 则去修改邮箱 否则去绑定新的邮箱 isFrom1 短信2 邮箱
if (state.emailStr.value.isNotEmpty) {
Navigator.pushNamed(
context, Routers.mineUnbindPhoneOrEmailPage,
arguments: {
'isFrom': '2',
'email': state.emailStr.value
});
} else {
Navigator.pushNamed(
context, Routers.mineBindPhoneOrEmailPage, arguments: {
'isFrom': '2',
'email': state.emailStr.value
});
}
})),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.resetPasswords!.tr,
rightTitle: "",
isHaveLine: true,
isHaveDirection: true,
action: () {
Navigator.pushNamed(
context, Routers.minePersonInfoResetPasswordPage);
}),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.safetyProblem!.tr,
rightTitle: "",
isHaveLine: true,
isHaveDirection: true,
action: () {
if (state.haveSafeAnswer.value == 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.countryStr.value,
isHaveLine: false,
isHaveDirection: false)),
],
));
}
Future _openModalBottomSheet() async {
showModalBottomSheet(
context: context,
shape: RoundedRectangleBorder(
borderRadius: BorderRadiusDirectional.circular(10)),
builder: (BuildContext context) {
return AlertBottomWidget(
topTitle: '',
items: const ['拍照', '从相册选择'],
chooseCallback: (value) {
int getSelectIndex = value;
if (getSelectIndex == 0) {
//拍照选项
selectCamera();
} else if (getSelectIndex == 1) {
selectImage();
}
},
);
});
}
///拍摄照片
selectCamera() async {
XFile? photo = await state.imagePicker.pickImage(
source: ImageSource.camera, preferredCameraDevice: CameraDevice.rear);
if (photo != null) {
state.image = photo;
setState(() {});
}
}
///从相册选取
selectImage() async {
XFile? image = await state.imagePicker.pickImage(
source: ImageSource.gallery,
maxHeight: 250,
maxWidth: 250,
);
if (image != null) state.image = image;
setState(() {});
}
}