Skip to content

Commit

Permalink
Update photos permissions to make it work on iOS (#44)
Browse files Browse the repository at this point in the history
Co-authored-by: Lukas Brasseleur <[email protected]>
  • Loading branch information
LukasBrass and lbrasseleur authored Jul 4, 2021
1 parent 04d6bab commit 991efa2
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 14 deletions.
24 changes: 24 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ PODS:
- FirebaseCore (~> 8.0)
- GTMSessionFetcher/Core (~> 1.5)
- Flutter (1.0.0)
- FMDB (2.7.5):
- FMDB/standard (= 2.7.5)
- FMDB/standard (2.7.5)
- geocoding (1.0.5):
- Flutter
- geolocator (6.2.0):
Expand Down Expand Up @@ -190,6 +193,13 @@ PODS:
- Flutter
- PromisesObjC (1.2.12)
- Protobuf (3.17.0)
- share_plus (0.0.1):
- Flutter
- sqflite (0.0.2):
- Flutter
- FMDB (>= 2.7.5)
- url_launcher (0.0.1):
- Flutter

DEPENDENCIES:
- cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`)
Expand All @@ -209,6 +219,9 @@ DEPENDENCIES:
- location (from `.symlinks/plugins/location/ios`)
- path_provider (from `.symlinks/plugins/path_provider/ios`)
- permission_handler (from `.symlinks/plugins/permission_handler/ios`)
- share_plus (from `.symlinks/plugins/share_plus/ios`)
- sqflite (from `.symlinks/plugins/sqflite/ios`)
- url_launcher (from `.symlinks/plugins/url_launcher/ios`)

SPEC REPOS:
trunk:
Expand All @@ -223,6 +236,7 @@ SPEC REPOS:
- FirebasePerformance
- FirebaseRemoteConfig
- FirebaseStorage
- FMDB
- GoogleAppMeasurement
- GoogleDataTransport
- GoogleMaps
Expand Down Expand Up @@ -264,6 +278,12 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/path_provider/ios"
permission_handler:
:path: ".symlinks/plugins/permission_handler/ios"
share_plus:
:path: ".symlinks/plugins/share_plus/ios"
sqflite:
:path: ".symlinks/plugins/sqflite/ios"
url_launcher:
:path: ".symlinks/plugins/url_launcher/ios"

CHECKOUT OPTIONS:
FirebaseFirestore:
Expand All @@ -290,6 +310,7 @@ SPEC CHECKSUMS:
FirebaseRemoteConfig: 055f6b5ba1751547596ded5032c4d5c6054ca501
FirebaseStorage: 61bcd27880fa17362f68be67d3683d04bfd7b1c7
Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
geocoding: 32cfcdb16d38d907caaba65e2e42ad10d38bee58
geolocator: f5e3de65e241caba7ce3e8a618803387bda73384
google_maps_flutter: c7f9c73576de1fbe152a227bfd6e6c4ae8088619
Expand All @@ -305,6 +326,9 @@ SPEC CHECKSUMS:
permission_handler: ccb20a9fad0ee9b1314a52b70b76b473c5f8dab0
PromisesObjC: 3113f7f76903778cf4a0586bd1ab89329a0b7b97
Protobuf: 7327d4444215b5f18e560a97f879ff5503c4581c
share_plus: 056a1e8ac890df3e33cb503afffaf1e9b4fbae68
sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904
url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef

PODFILE CHECKSUM: 0880d904518c8ec01da1973bcb29304d327f6585

Expand Down
8 changes: 4 additions & 4 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = XFCSLTMJV2;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
Expand Down Expand Up @@ -511,7 +511,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = XFCSLTMJV2;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
Expand All @@ -538,7 +538,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = XFCSLTMJV2;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
Expand Down Expand Up @@ -582,4 +582,4 @@
/* End XCConfigurationList section */
};
rootObject = 97C146E61CF9000F007C117D /* Project object */;
}
}
1 change: 0 additions & 1 deletion lib/components/gamification_xpbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class GamificationXpBar extends StatelessWidget {
valueColor:
AlwaysStoppedAnimation<Color>(Theme.of(context).primaryColor),
minHeight: 20,
color: Colors.teal[200],
),
Align(
alignment: Alignment.center,
Expand Down
21 changes: 12 additions & 9 deletions lib/services/firebase/storage/storage_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,19 @@ class StorageService extends StorageInterface {
}
}

Future<PermissionStatus> _requesPhotoAccessPermission() async {
Future<bool> _requestPhotoAccessPermission() async {
if (Platform.isIOS) {
return true;
}

await Permission.photos.request();
return await Permission.photos.status;
return await Permission.photos.status.isGranted;
}

@override
Future uploadAndUpdateUserImage(AnUser user) async {
final permissionStatus = await _requesPhotoAccessPermission();

if (permissionStatus.isGranted) {
final permissionGranted = await _requestPhotoAccessPermission();
if (permissionGranted) {
final _picker = ImagePicker();
PickedFile? image = await _picker.getImage(source: ImageSource.gallery);

Expand Down Expand Up @@ -95,9 +98,9 @@ class StorageService extends StorageInterface {

@override
Future<File> selectImageFromGallery() async {
final permissionStatus = await _requesPhotoAccessPermission();
final permissionGranted = await _requestPhotoAccessPermission();

if (permissionStatus.isGranted) {
if (permissionGranted) {
final _picker = ImagePicker();
PickedFile? image = await _picker.getImage(source: ImageSource.gallery);
if (image != null)
Expand All @@ -119,9 +122,9 @@ class StorageService extends StorageInterface {
}

Future uploadAndUpdateAssociationBanner(Association association) async {
final permissionStatus = await _requesPhotoAccessPermission();
final permissionGranted = await _requestPhotoAccessPermission();

if (permissionStatus.isGranted) {
if (permissionGranted) {
final _picker = ImagePicker();
PickedFile? image = await _picker.getImage(source: ImageSource.gallery);

Expand Down

0 comments on commit 991efa2

Please sign in to comment.