Commit 30de83bc by Mathias Cochet

Permission status added.

parent e38836b2
......@@ -37,6 +37,8 @@ class _PermissionState extends State<PermissionWidget> {
return Colors.red;
case PermissionStatus.granted:
return Colors.green;
case PermissionStatus.limited:
return Colors.orange;
default:
return Colors.grey;
}
......
......@@ -24,13 +24,24 @@
return;
}
if(@available(iOS 14, *)) {
[PHPhotoLibrary requestAuthorizationForAccessLevel:PHAccessLevelReadWrite handler:^(PHAuthorizationStatus authorizationStatus) {
completionHandler([PhotoPermissionStrategy determinePermissionStatus:authorizationStatus]);
}];
}else {
[PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus authorizationStatus) {
completionHandler([PhotoPermissionStrategy determinePermissionStatus:authorizationStatus]);
}];
}
}
+ (PermissionStatus)permissionStatus {
PHAuthorizationStatus status = [PHPhotoLibrary authorizationStatus];
PHAuthorizationStatus status;
if(@available(iOS 14, *)){
status = [PHPhotoLibrary authorizationStatusForAccessLevel:PHAccessLevelReadWrite];
}else {
status = [PHPhotoLibrary authorizationStatus];
}
return [PhotoPermissionStrategy determinePermissionStatus:status];
}
......
......@@ -23,8 +23,8 @@ Future<bool> openAppSettings() => _handler.openAppSettings();
/// Actions that can be executed on a permission.
extension PermissionActions on Permission {
/// The current status of this permission.
///
/// The Android-only [PermissionStatus.permanentlyDenied] status will only be
///
/// The Android-only [PermissionStatus.permanentlyDenied] status will only be
/// calculated if the active context is an Activity. If it isn't,
/// [PermissionStatus.denied] will be returned.
Future<PermissionStatus> get status => _handler.checkPermissionStatus(this);
......@@ -67,6 +67,10 @@ extension PermissionCheckShortcuts on Permission {
/// *Only supported on iOS.*
Future<bool> get isRestricted => status.isRestricted;
///User has authorized this application for limited photo library access.
/// *Only supported on iOS.(iOS14+)*
Future<bool> get isLimited => status.isLimited;
/// If the user denied this permission and selected to never again show a
/// request for it. The user may still change the permission's status in the
/// device settings.
......
......@@ -16,7 +16,10 @@ dependencies:
flutter:
sdk: flutter
meta: ^1.1.6
permission_handler_platform_interface: ^2.0.1
permission_handler_platform_interface:
git:
url: https://github.com/MathiasCochet/flutter-permission-handler.git
path: permission_handler_platform_interface
dev_dependencies:
effective_dart: ^1.2.1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment