From 98b6a23d4fcc196e7b5c314266b40cf0cdc8c7a1 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Tue, 9 Apr 2024 10:52:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E7=94=A8=E6=88=B7=E5=A4=B4=E5=83=8F?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=EF=BC=8C=E7=9B=B8=E5=86=8C=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E9=92=88=E5=AF=B9andriud33=E4=BB=A5=E4=B8=8B=E7=9A=84=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E5=85=BC=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../minePersonInfo_page.dart | 85 +++++++------------ 1 file changed, 32 insertions(+), 53 deletions(-) diff --git a/star_lock/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_page.dart b/star_lock/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_page.dart index ed5db138..419ba4fa 100644 --- a/star_lock/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_page.dart +++ b/star_lock/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_page.dart @@ -7,6 +7,7 @@ import 'package:get/get.dart'; import 'package:image_picker/image_picker.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:star_lock/app_settings/app_colors.dart'; +import 'package:star_lock/app_settings/app_settings.dart'; import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_logic.dart'; import 'package:star_lock/tools/appFirstEnterHandle.dart'; import 'package:star_lock/tools/custom_bottom_sheet.dart'; @@ -23,8 +24,7 @@ class MinePersonInfoPage extends StatefulWidget { State createState() => _MinePersonInfoPageState(); } -class _MinePersonInfoPageState extends State - with WidgetsBindingObserver { +class _MinePersonInfoPageState extends State with WidgetsBindingObserver { final logic = Get.put(MinePersonInfoLogic()); final state = Get.find().state; @@ -88,8 +88,7 @@ class _MinePersonInfoPageState extends State action: () async { //安卓平台下首次进入应用需向用户告知获取权限用途弹窗 if (Platform.isAndroid) { - AppFirstEnterHandle() - .getAppFirstEnter(context, isAgreeCamera); + AppFirstEnterHandle().getAppFirstEnter(context, isAgreeCamera); var getFlag = await Storage.getString(isAgreeCamera); if (getFlag == isAgreeCamera) { _openModalBottomSheet(); @@ -101,16 +100,13 @@ class _MinePersonInfoPageState extends State ), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.nickName!.tr, - rightTitle: state.mineInfoData.value.nickname != null - ? state.mineInfoData.value.nickname! - : "", + rightTitle: state.mineInfoData.value.nickname != null ? state.mineInfoData.value.nickname! : "", isHaveLine: true, isHaveDirection: true, action: () { - Navigator.pushNamed( - context, Routers.minePersonInfoEditNamePage, arguments: { - 'nickName': state.mineInfoData.value.nickname - }).then((value) => logic.getUserInfoRequest()); + Navigator.pushNamed(context, Routers.minePersonInfoEditNamePage, + arguments: {'nickName': state.mineInfoData.value.nickname}) + .then((value) => logic.getUserInfoRequest()); })), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.mobileNumber!.tr, @@ -122,16 +118,13 @@ class _MinePersonInfoPageState extends State 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()); + 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()); + Navigator.pushNamed(context, Routers.mineBindPhoneOrEmailPage, + arguments: {'mobile': state.mineInfoData.value.mobile!, 'isFrom': '1'}) + .then((value) => logic.getUserInfoRequest()); } })), Obx(() => CommonItem( @@ -144,18 +137,13 @@ class _MinePersonInfoPageState extends State 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()); + 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()); + Navigator.pushNamed(context, Routers.mineBindPhoneOrEmailPage, + arguments: {'isFrom': '2', 'email': state.mineInfoData.value.email!}) + .then((value) => logic.getUserInfoRequest()); } })), CommonItem( @@ -164,30 +152,24 @@ class _MinePersonInfoPageState extends State isHaveLine: true, isHaveDirection: true, action: () { - Navigator.pushNamed( - context, Routers.minePersonInfoResetPasswordPage); + Navigator.pushNamed(context, Routers.minePersonInfoResetPasswordPage); }), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.safetyProblem!.tr, - rightTitle: - state.mineInfoData.value.haveSafeAnswer == 0 ? "去设置" : "", + rightTitle: state.mineInfoData.value.haveSafeAnswer == 0 ? "去设置" : "", isHaveLine: true, isHaveDirection: true, action: () { if (state.mineInfoData.value.haveSafeAnswer == 0) { - Navigator.pushNamed( - context, Routers.minePersonInfoSetSafetyProblemPage) + Navigator.pushNamed(context, Routers.minePersonInfoSetSafetyProblemPage) .then((value) => logic.getUserInfoRequest()); } else { - Navigator.pushNamed( - context, Routers.minePersonInfoViewSafetyProblemPage); + Navigator.pushNamed(context, Routers.minePersonInfoViewSafetyProblemPage); } })), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.countryAndRegion!.tr, - rightTitle: state.mineInfoData.value.countryName != null - ? state.mineInfoData.value.countryName! - : "", + rightTitle: state.mineInfoData.value.countryName != null ? state.mineInfoData.value.countryName! : "", isHaveLine: false, isHaveDirection: false)), ], @@ -221,7 +203,9 @@ class _MinePersonInfoPageState extends State } Future _requestPhotoPermission() async { - var status = await Permission.photos.request(); + //针对andriud33以下的设备兼容 + bool isAndroid33 = AppPlatform.isAndroid && AppPlatform.getSdkIntValue() >= 33; + var status = isAndroid33 ? await Permission.photos.request() : await Permission.storage.request(); if (status.isGranted) { setState(() { state.hasPhotoPermission.value = true; // 如果权限被授予,更新状态变量 @@ -271,8 +255,7 @@ class _MinePersonInfoPageState extends State Future _openModalBottomSheet() async { showModalBottomSheet( context: context, - shape: RoundedRectangleBorder( - borderRadius: BorderRadiusDirectional.circular(10)), + shape: RoundedRectangleBorder(borderRadius: BorderRadiusDirectional.circular(10)), builder: (BuildContext context) { return AlertBottomWidget( topTitle: '', @@ -281,13 +264,9 @@ class _MinePersonInfoPageState extends State int getSelectIndex = value; if (getSelectIndex == 0) { //拍照选项 - state.hasCameraPermission.value == true - ? selectCamera() - : _requestCameraPermission(); + state.hasCameraPermission.value == true ? selectCamera() : _requestCameraPermission(); } else if (getSelectIndex == 1) { - state.hasPhotoPermission.value == true - ? selectImage() - : _requestPhotoPermission(); + state.hasPhotoPermission.value == true ? selectImage() : _requestPhotoPermission(); } }, ); @@ -296,8 +275,8 @@ class _MinePersonInfoPageState extends State ///拍摄照片 selectCamera() async { - XFile? photo = await state.imagePicker.pickImage( - source: ImageSource.camera, preferredCameraDevice: CameraDevice.rear); + XFile? photo = + await state.imagePicker.pickImage(source: ImageSource.camera, preferredCameraDevice: CameraDevice.rear); if (photo != null) { state.image = photo; // logic.getUpTokenRequest();