fix:用户头像上传,相册上传针对andriud33以下的设备兼容
This commit is contained in:
parent
2447cb43dc
commit
98b6a23d4f
@ -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<MinePersonInfoPage> createState() => _MinePersonInfoPageState();
|
||||
}
|
||||
|
||||
class _MinePersonInfoPageState extends State<MinePersonInfoPage>
|
||||
with WidgetsBindingObserver {
|
||||
class _MinePersonInfoPageState extends State<MinePersonInfoPage> with WidgetsBindingObserver {
|
||||
final logic = Get.put(MinePersonInfoLogic());
|
||||
final state = Get.find<MinePersonInfoLogic>().state;
|
||||
|
||||
@ -88,8 +88,7 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage>
|
||||
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<MinePersonInfoPage>
|
||||
),
|
||||
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<MinePersonInfoPage>
|
||||
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<MinePersonInfoPage>
|
||||
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<MinePersonInfoPage>
|
||||
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<MinePersonInfoPage>
|
||||
}
|
||||
|
||||
Future<void> _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<MinePersonInfoPage>
|
||||
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<MinePersonInfoPage>
|
||||
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<MinePersonInfoPage>
|
||||
|
||||
///拍摄照片
|
||||
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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user