This commit is contained in:
魏少阳 2024-05-14 15:11:20 +08:00
commit 79b51b00dc
10 changed files with 268 additions and 175 deletions

View File

@ -125,6 +125,8 @@ PODS:
- Flutter - Flutter
- package_info_plus (0.4.5): - package_info_plus (0.4.5):
- Flutter - Flutter
- partial_media_permissions (0.0.1):
- Flutter
- path_provider_foundation (0.0.1): - path_provider_foundation (0.0.1):
- Flutter - Flutter
- FlutterMacOS - FlutterMacOS
@ -184,6 +186,7 @@ DEPENDENCIES:
- just_audio (from `.symlinks/plugins/just_audio/ios`) - just_audio (from `.symlinks/plugins/just_audio/ios`)
- network_info_plus (from `.symlinks/plugins/network_info_plus/ios`) - network_info_plus (from `.symlinks/plugins/network_info_plus/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`) - package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- partial_media_permissions (from `.symlinks/plugins/partial_media_permissions/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`) - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`) - permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`) - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
@ -274,6 +277,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/network_info_plus/ios" :path: ".symlinks/plugins/network_info_plus/ios"
package_info_plus: package_info_plus:
:path: ".symlinks/plugins/package_info_plus/ios" :path: ".symlinks/plugins/package_info_plus/ios"
partial_media_permissions:
:path: ".symlinks/plugins/partial_media_permissions/ios"
path_provider_foundation: path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/darwin" :path: ".symlinks/plugins/path_provider_foundation/darwin"
permission_handler_apple: permission_handler_apple:
@ -335,6 +340,7 @@ SPEC CHECKSUMS:
just_audio: baa7252489dbcf47a4c7cc9ca663e9661c99aafa just_audio: baa7252489dbcf47a4c7cc9ca663e9661c99aafa
network_info_plus: 6d0c3eb8367b8164fa3fb0c19875e3f59d49697f network_info_plus: 6d0c3eb8367b8164fa3fb0c19875e3f59d49697f
package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e
partial_media_permissions: 0fd34002b1dbfd5e8b4c60eb0d99e8e755a77f76
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2 permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2
ReachabilitySwift: 2128f3a8c9107e1ad33574c6e58e8285d460b149 ReachabilitySwift: 2128f3a8c9107e1ad33574c6e58e8285d460b149

View File

@ -233,7 +233,9 @@ class AuthorizedAdminLogic extends BaseGetXController {
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
// //
state.isRequireAuth.value = true; state.isRequireAuth.value = true;
state.isAuthentication.value = true;
} else { } else {
//432--
ShowTipView().showBuyTipWithContentAlert( ShowTipView().showBuyTipWithContentAlert(
titleStr: '实名认证为付费功能,请购买后再使用'.tr, titleStr: '实名认证为付费功能,请购买后再使用'.tr,
sureClick: () { sureClick: () {

View File

@ -471,11 +471,11 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage>
value: state.isAuthentication.value, value: state.isAuthentication.value,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
state.isAuthentication.value = !state.isAuthentication.value; if (logic.state.isAuthentication.value == false) {
if (state.isAuthentication.value == true) {
logic.keyCheckFace(); logic.keyCheckFace();
} else { } else {
state.isRequireAuth.value = false; logic.state.isAuthentication.value = false;
logic.state.isRequireAuth.value = false;
} }
}); });
}, },

View File

@ -190,7 +190,9 @@ class SendElectronicKeyViewLogic extends BaseGetXController {
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
// //
state.isRequireAuth.value = true; state.isRequireAuth.value = true;
state.isAuthentication.value = true;
} else { } else {
//432--
ShowTipView().showBuyTipWithContentAlert( ShowTipView().showBuyTipWithContentAlert(
titleStr: '实名认证为付费功能,请购买后再使用'.tr, titleStr: '实名认证为付费功能,请购买后再使用'.tr,
sureClick: () { sureClick: () {

View File

@ -285,6 +285,7 @@ class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
rightTitle: rightTitle:
"${logic.state.effectiveDateTime}-${logic.state.failureDateTime}", "${logic.state.effectiveDateTime}-${logic.state.failureDateTime}",
isHaveDirection: true, isHaveDirection: true,
isHaveLine: true,
action: () async { action: () async {
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, var result = await Get.toNamed(Routers.seletKeyCyclicDatePage,
arguments: { arguments: {
@ -552,11 +553,10 @@ class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
if (isRemote) { if (isRemote) {
logic.state.isRemoteUnlock.value = !logic.state.isRemoteUnlock.value; logic.state.isRemoteUnlock.value = !logic.state.isRemoteUnlock.value;
} else { } else {
logic.state.isAuthentication.value = if (logic.state.isAuthentication.value == false) {
!logic.state.isAuthentication.value;
if (logic.state.isAuthentication.value == true) {
logic.keyCheckFace(); logic.keyCheckFace();
} else { } else {
logic.state.isAuthentication.value = false;
logic.state.isRequireAuth.value = false; logic.state.isRequireAuth.value = false;
} }
} }

View File

@ -121,11 +121,7 @@ class MinePersonInfoLogic extends BaseGetXController {
// 访 // 访
Future<void> _checkPhotoPermission() async { Future<void> _checkPhotoPermission() async {
bool isAndroid33 = var status = await PermissionDialog.requestPhotos();
AppPlatform.isAndroid && AppPlatform.getSdkIntValue() >= 33;
var status = isAndroid33
? await PermissionDialog.request(Permission.photos)
: await PermissionDialog.request(Permission.storage);
if (status) { if (status) {
selectImage(); selectImage();
} }

View File

@ -1,4 +1,3 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:flutter_slidable/flutter_slidable.dart';
@ -23,8 +22,8 @@ class _ExpireFingerprintPageState extends State<ExpireFingerprintPage> {
final state = Get.find<ExpireFingerprintLogic>().state; final state = Get.find<ExpireFingerprintLogic>().state;
Future<void> getHttpData() async { Future<void> getHttpData() async {
logic.expirFingerprintListRequest().then((ExpireFingerprintEntity value){ logic.expirFingerprintListRequest().then((ExpireFingerprintEntity value) {
if(mounted) setState(() {}); if (mounted) setState(() {});
}); });
} }
@ -38,56 +37,62 @@ class _ExpireFingerprintPageState extends State<ExpireFingerprintPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return EasyRefreshTool( return EasyRefreshTool(
onRefresh: (){ onRefresh: () {
logic.pageNo = 1; logic.pageNo = 1;
getHttpData(); getHttpData();
}, },
onLoad: (){ onLoad: () {
getHttpData(); getHttpData();
}, },
child: Obx(() => _buildMainUI()) child: Obx(() => _buildMainUI()));
);
} }
Widget _buildMainUI() { Widget _buildMainUI() {
return state.dataList.isEmpty return state.dataList.isEmpty
? NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h) ? NoData(
noDataHeight: 1.sh -
ScreenUtil().statusBarHeight -
ScreenUtil().bottomBarHeight -
190.h -
64.h)
: SlidableAutoCloseBehavior( : SlidableAutoCloseBehavior(
child: ListView.separated( child: ListView.separated(
itemCount: state.dataList.length, itemCount: state.dataList.length,
itemBuilder: (c, index) { itemBuilder: (c, index) {
ExpireFingerprintItemEntity indexEntity = state.dataList[index]; ExpireFingerprintItemEntity indexEntity = state.dataList[index];
return Slidable( return Slidable(
key:ValueKey(indexEntity.uid), key: ValueKey(indexEntity.uid),
endActionPane: ActionPane( endActionPane: ActionPane(
extentRatio: 0.2, extentRatio: 0.2,
motion: const ScrollMotion(), motion: const ScrollMotion(),
children: [ children: [
SlidableAction( SlidableAction(
onPressed: (BuildContext context){ onPressed: (BuildContext context) {
ShowTipView().showIosTipWithContentDialog("确定删除卡吗?", (){ ShowTipView().showIosTipWithContentDialog("确定删除指纹吗?",
state.deletExpireFingerprintItemEntity = indexEntity; () {
logic.senderAddFingerprint(); state.deletExpireFingerprintItemEntity =
}); indexEntity;
}, logic.senderAddFingerprint();
backgroundColor: Colors.red, });
foregroundColor: Colors.white, },
label: '删除', backgroundColor: Colors.red,
padding: EdgeInsets.only(left: 5.w, right: 5.w), foregroundColor: Colors.white,
), label: '删除',
], padding: EdgeInsets.only(left: 5.w, right: 5.w),
),
],
),
child: _electronicKeyItem(indexEntity),
);
},
separatorBuilder: (BuildContext context, int index) {
return const Divider(
height: 1,
color: AppColors.greyLineColor,
);
},
), ),
child: _electronicKeyItem(indexEntity),
); );
},
separatorBuilder: (BuildContext context, int index) {
return const Divider(
height: 1,
color: AppColors.greyLineColor,
);
},
),
);
} }
Widget _electronicKeyItem(ExpireFingerprintItemEntity itemData) { Widget _electronicKeyItem(ExpireFingerprintItemEntity itemData) {
@ -156,8 +161,8 @@ class _ExpireFingerprintPageState extends State<ExpireFingerprintPage> {
), ),
Expanded( Expanded(
child: SizedBox( child: SizedBox(
width: 10.w, width: 10.w,
)), )),
Text( Text(
itemData.lockAlias ?? '', itemData.lockAlias ?? '',
style: TextStyle( style: TextStyle(
@ -216,8 +221,7 @@ class _ExpireFingerprintPageState extends State<ExpireFingerprintPage> {
), ),
child: Text( child: Text(
'${itemData.expireDate.toString()}', '${itemData.expireDate.toString()}',
style: TextStyle( style: TextStyle(color: Colors.white, fontSize: 13.sp),
color: Colors.white, fontSize: 13.sp),
), ),
); );
} else { } else {
@ -229,12 +233,10 @@ class _ExpireFingerprintPageState extends State<ExpireFingerprintPage> {
), ),
child: Text( child: Text(
'已过期', '已过期',
style: TextStyle( style: TextStyle(color: Colors.white, fontSize: 13.sp),
color: Colors.white, fontSize: 13.sp),
), ),
); );
} }
// } // }
} }
} }

View File

@ -1,4 +1,3 @@
import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/dateTool.dart'; import 'package:star_lock/tools/dateTool.dart';
@ -13,8 +12,9 @@ class ExpirePasswordLogic extends BaseGetXController {
// //
Future<ExpirePasswordEntity> expirePasswordListRequest() async { Future<ExpirePasswordEntity> expirePasswordListRequest() async {
ExpirePasswordEntity entity = await ApiRepository.to.expirePasswordList(pageNo.toString(), pageSize.toString()); ExpirePasswordEntity entity = await ApiRepository.to
if(entity.errorCode!.codeIsSuccessful){ .expirePasswordList(pageNo.toString(), pageSize.toString());
if (entity.errorCode!.codeIsSuccessful) {
if (pageNo == 1) { if (pageNo == 1) {
state.dataList.value = entity.data!.list!; state.dataList.value = entity.data!.list!;
pageNo++; pageNo++;
@ -29,11 +29,12 @@ class ExpirePasswordLogic extends BaseGetXController {
} }
// deleteType:1- 2- // deleteType:1- 2-
Future<void> deletePwdRequest(ExpirePasswordItemData expirePasswordItemData) async { Future<void> deletePwdRequest(
ExpirePasswordItemData expirePasswordItemData) async {
PasswordKeyEntity entity = await ApiRepository.to.deleteKeyboardPwd( PasswordKeyEntity entity = await ApiRepository.to.deleteKeyboardPwd(
lockId:expirePasswordItemData.lockId.toString(), lockId: expirePasswordItemData.lockId.toString(),
keyboardPwdId:expirePasswordItemData.pwdId.toString(), keyboardPwdId: expirePasswordItemData.pwdId.toString(),
deleteType:1); deleteType: 1);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
showToast("删除成功", something: () { showToast("删除成功", something: () {
pageNo = 1; pageNo = 1;
@ -46,12 +47,13 @@ class ExpirePasswordLogic extends BaseGetXController {
//使 //使
String getExpireDateStr(ExpirePasswordItemData itemData) { String getExpireDateStr(ExpirePasswordItemData itemData) {
String useDateStr = ''; String useDateStr = '';
if(itemData.keyboardPwdType == 4){ //* getKeyType 1 2 3 4 5 6 7 8 9 10 11 12 13 14
if (itemData.keyboardPwdType! > 4) {
useDateStr = '循环'; useDateStr = '循环';
}else{ } else {
useDateStr = '${DateTool().dateToYMDString(itemData.startDate.toString())}-${DateTool().dateToYMDString(itemData.endDate.toString())}'; useDateStr =
'${DateTool().dateToYMDString(itemData.startDate.toString())}-${DateTool().dateToYMDString(itemData.endDate.toString())}';
} }
return useDateStr; return useDateStr;
} }
} }

View File

@ -1,10 +1,10 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/appRouters.dart'; import 'package:star_lock/appRouters.dart';
import 'package:star_lock/app_settings/app_colors.dart'; import 'package:star_lock/app_settings/app_colors.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart';
import 'package:star_lock/tools/EasyRefreshTool.dart'; import 'package:star_lock/tools/EasyRefreshTool.dart';
import 'package:star_lock/tools/noData.dart'; import 'package:star_lock/tools/noData.dart';
@ -24,8 +24,8 @@ class _ExpirePasswordPageState extends State<ExpirePasswordPage> {
final state = Get.find<ExpirePasswordLogic>().state; final state = Get.find<ExpirePasswordLogic>().state;
Future<void> getHttpData() async { Future<void> getHttpData() async {
logic.expirePasswordListRequest().then((ExpirePasswordEntity value){ logic.expirePasswordListRequest().then((ExpirePasswordEntity value) {
if(mounted) setState(() {}); if (mounted) setState(() {});
}); });
} }
@ -39,67 +39,73 @@ class _ExpirePasswordPageState extends State<ExpirePasswordPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return EasyRefreshTool( return EasyRefreshTool(
onRefresh: (){ onRefresh: () {
logic.pageNo = 1; logic.pageNo = 1;
getHttpData(); getHttpData();
}, },
onLoad: (){ onLoad: () {
getHttpData(); getHttpData();
}, },
child: Obx(() => _buildMainUI()) child: Obx(() => _buildMainUI()));
);
} }
Widget _buildMainUI() { Widget _buildMainUI() {
return state.dataList.isEmpty return state.dataList.isEmpty
? NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h) ? NoData(
noDataHeight: 1.sh -
ScreenUtil().statusBarHeight -
ScreenUtil().bottomBarHeight -
190.h -
64.h)
: SlidableAutoCloseBehavior( : SlidableAutoCloseBehavior(
child: ListView.separated( child: ListView.separated(
itemCount: state.dataList.length, itemCount: state.dataList.length,
itemBuilder: (c, index) { itemBuilder: (c, index) {
ExpirePasswordItemData indexEntity = state.dataList[index]; ExpirePasswordItemData indexEntity = state.dataList[index];
return Slidable( return Slidable(
key:ValueKey(indexEntity.uid), key: ValueKey(indexEntity.uid),
endActionPane: ActionPane( endActionPane: ActionPane(
extentRatio: 0.2, extentRatio: 0.2,
motion: const ScrollMotion(), motion: const ScrollMotion(),
children: [ children: [
SlidableAction( SlidableAction(
onPressed: (BuildContext context){ onPressed: (BuildContext context) {
ShowTipView().showIosTipWithContentDialog("确定删除该密码吗?", (){ ShowTipView().showIosTipWithContentDialog("确定删除该密码吗?",
logic.deletePwdRequest(indexEntity); () {
}); logic.deletePwdRequest(indexEntity);
}, });
backgroundColor: Colors.red, },
foregroundColor: Colors.white, backgroundColor: Colors.red,
label: '删除', foregroundColor: Colors.white,
padding: EdgeInsets.only(left: 5.w, right: 5.w), label: '删除',
), padding: EdgeInsets.only(left: 5.w, right: 5.w),
], ),
],
),
child: _electronicKeyItem(indexEntity),
);
},
separatorBuilder: (BuildContext context, int index) {
return const Divider(
height: 1,
color: AppColors.greyLineColor,
);
},
), ),
child: _electronicKeyItem(indexEntity),
); );
},
separatorBuilder: (BuildContext context, int index) {
return const Divider(
height: 1,
color: AppColors.greyLineColor,
);
},
),
);
} }
Widget _electronicKeyItem(ExpirePasswordItemData itemData) { Widget _electronicKeyItem(ExpirePasswordItemData itemData) {
return GestureDetector( return GestureDetector(
onTap: () async { onTap: () async {
// if(itemData.keyboardPwdType! == 4){ // if (itemData.keyboardPwdType! > 4) {
// // // //
// var data = await Get.toNamed(Routers.electronicKeyPeriodValidityPage, arguments: { // var data = await Get.toNamed(Routers.electronicKeyPeriodValidityPage,
// "pushType": 0, // arguments: {
// "expireLockItem": itemData, // "pushType": 0,
// }); // "expirePasswordItem": itemData,
// if(data != null) { // });
// if (data != null) {
// // setState(() { // // setState(() {
// // state.starDate.value = data["starDate"]; // // state.starDate.value = data["starDate"];
// // state.endDate.value = data["endDate"]; // // state.endDate.value = data["endDate"];
@ -110,19 +116,20 @@ class _ExpirePasswordPageState extends State<ExpirePasswordPage> {
// logic.pageNo = 1; // logic.pageNo = 1;
// getHttpData(); // getHttpData();
// } // }
// }else{ // } else {
// var data = await Get.toNamed(Routers.electronicKeyDetailChangeDate, arguments: { // var backData = await Get.toNamed(
// "pushType": 0, // Routers.passwordKeyDetailChangeDatePage,
// "expireLockItem": itemData, // arguments: {
// }); // 'itemData': itemData,
// if(data != null) {
// setState(() { // });
// // state.starDate.value = data["beginTimeTimestamp"].toString(); // if (backData != null) {
// // state.endDate.value = data["endTimeTimestamp"].toString(); // itemData.startDate =
// // state.keyType.value = 2; // int.parse(backData["beginTimeTimestamp"]) * 1000;
// logic.pageNo = 1; // itemData.endDate = int.parse(backData["endTimeTimestamp"]) * 1000;
// getHttpData(); // //
// }); // itemData.keyboardPwdType = 3;
// setState(() {});
// } // }
// } // }
}, },
@ -156,8 +163,8 @@ class _ExpirePasswordPageState extends State<ExpirePasswordPage> {
), ),
Expanded( Expanded(
child: SizedBox( child: SizedBox(
width: 10.w, width: 10.w,
)), )),
Text( Text(
itemData.lockAlias ?? '', itemData.lockAlias ?? '',
style: TextStyle( style: TextStyle(
@ -193,48 +200,36 @@ class _ExpirePasswordPageState extends State<ExpirePasswordPage> {
} }
Widget getStatus(ExpirePasswordItemData itemData) { Widget getStatus(ExpirePasswordItemData itemData) {
// if (itemData.keyboardPwdStatus! == 1) { //keyboardPwdStatus 1 2
// return Container( return Row(
// padding: EdgeInsets.only(left: 5.w, right: 5.w), children: [
// decoration: BoxDecoration( Visibility(
// color: Colors.red, visible: itemData.expireDate! > 0 ? true : false,
// borderRadius: BorderRadius.circular(2.0), child: Container(
// ), padding: EdgeInsets.only(left: 5.w, right: 5.w),
// child: Text( decoration: BoxDecoration(
// '未生效', color: AppColors.expireTextBgColor,
// style: TextStyle( borderRadius: BorderRadius.circular(2.0),
// color: Colors.white, fontSize: 13.sp), ),
// ), child: Text(
// ); '${itemData.expireDate.toString()}',
// } else { style: TextStyle(color: Colors.white, fontSize: 13.sp),
if (itemData.expireDate! > 0) { ),
return Container( )),
padding: EdgeInsets.only(left: 5.w, right: 5.w), Visibility(
decoration: BoxDecoration( visible: itemData.keyboardPwdStatus! == 2 ? true : false,
color: AppColors.expireTextBgColor, child: Container(
borderRadius: BorderRadius.circular(2.0), padding: EdgeInsets.only(left: 5.w, right: 5.w),
), decoration: BoxDecoration(
child: Text( color: Colors.red,
'${itemData.expireDate.toString()}', borderRadius: BorderRadius.circular(2.0),
style: TextStyle( ),
color: Colors.white, fontSize: 13.sp), child: Text(
), '已过期'.tr,
); style: TextStyle(color: Colors.white, fontSize: 13.sp),
} else { ),
return Container( ))
padding: EdgeInsets.only(left: 5.w, right: 5.w), ],
decoration: BoxDecoration( );
color: Colors.red,
borderRadius: BorderRadius.circular(2.0),
),
child: Text(
'已过期',
style: TextStyle(
color: Colors.white, fontSize: 13.sp),
),
);
}
// }
} }
} }

View File

@ -83,6 +83,94 @@ class PermissionDialog {
return false; return false;
} }
//
static Future<bool> requestPhotos() async {
if (Get.context == null) {
return false;
}
bool isAndroid33 =
AppPlatform.isAndroid && AppPlatform.getSdkIntValue() >= 33;
//
List<Permission> requestPermission() {
List<Permission> permissions;
if (isAndroid33) {
permissions = [
Permission.mediaLibrary,
Permission.photos,
Permission.videos,
];
} else {
permissions = [
Permission.storage,
];
}
return permissions;
}
Future<bool> permissionStatus(List<Permission> permissions) async {
bool isGranted = true;
for (Permission permission in permissions) {
isGranted =
isGranted && (await permission.status) == PermissionStatus.granted;
}
if (isAndroid33) {
// android 33
isGranted =
(await Permission.mediaLibrary.status) == PermissionStatus.granted;
}
return isGranted;
}
bool application = true;
Permission permission = Permission.photos;
List<Permission> permissions = requestPermission();
dynamic cache = await Storage.getString(titles[permission]);
bool isGranted = await permissionStatus(permissions);
if (AppPlatform.isAndroid && !isGranted && cache is! String) {
application = await showCupertinoDialog(
context: Get.context!,
builder: (context) {
return PopScope(
canPop: false,
child: CupertinoAlertDialog(
title: Text('${'申请'.tr}${titles[permission] ?? ''}${'权限'.tr}'),
content: Text(contents[permission] ?? ''),
actions: [
CupertinoDialogAction(
child: Text('不允许'.tr),
onPressed: () {
Get.back(result: false);
},
),
CupertinoDialogAction(
child: Text('允许'.tr),
onPressed: () {
Get.back(result: true);
},
),
],
));
},
);
if (application) {
await Storage.setString(titles[permission], titles[permission]);
}
} else if (cache is String) {
bool isDenied = !(await permissionStatus(permissions));
if (isDenied) {
showSet(permission);
return false;
}
}
if (application) {
Map<Permission, PermissionStatus> statuses = await permissions.request();
bool isGranted = await permissionStatus(statuses.keys.toList());
return isGranted;
}
return false;
}
// //
static Future<bool> request(Permission permission, [String? content]) async { static Future<bool> request(Permission permission, [String? content]) async {
if (Get.context == null) { if (Get.context == null) {