Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
permission_handler
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
songyanzhi
permission_handler
Commits
30de83bc
Commit
30de83bc
authored
Nov 25, 2020
by
Mathias Cochet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Permission status added.
parent
e38836b2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
4 deletions
+24
-4
permission_handler/example/lib/plugin_example/permission_widget.dart
+2
-0
permission_handler/ios/Classes/strategies/PhotoPermissionStrategy.m
+12
-1
permission_handler/lib/permission_handler.dart
+6
-2
permission_handler/pubspec.yaml
+4
-1
No files found.
permission_handler/example/lib/plugin_example/permission_widget.dart
View file @
30de83bc
...
...
@@ -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
;
}
...
...
permission_handler/ios/Classes/strategies/PhotoPermissionStrategy.m
View file @
30de83bc
...
...
@@ -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
];
}
...
...
permission_handler/lib/permission_handler.dart
View file @
30de83bc
...
...
@@ -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.
...
...
permission_handler/pubspec.yaml
View file @
30de83bc
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment