mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-16 17:27:37 +00:00
e092509264
* - Catch get balance network issues - Disable remove button when adding node * Update packages and android gradle version minor enhancements * Backup issue fix * update workflow java version * Remove useless permission check for saving file * minor enhancements * only delete secure storage key before overriding it on MacOS * Minor UI changes * Remove debug prints [skip ci] * Revert FR localization changes
39 lines
978 B
Dart
39 lines
978 B
Dart
import 'dart:io';
|
|
|
|
import 'package:cake_wallet/generated/i18n.dart';
|
|
import 'package:cake_wallet/utils/show_bar.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:permission_handler/permission_handler.dart';
|
|
|
|
class PermissionHandler {
|
|
static Future<bool> checkPermission(Permission permission, BuildContext context) async {
|
|
if (Platform.isIOS) {
|
|
return true;
|
|
}
|
|
final Map<Permission, String> _permissionMessages = {
|
|
Permission.camera: S.of(context).camera_permission_is_required,
|
|
};
|
|
|
|
var status = await permission.status;
|
|
|
|
if (status.isDenied) {
|
|
try {
|
|
status = await permission.request();
|
|
} catch (_) {}
|
|
}
|
|
|
|
if (status.isPermanentlyDenied || status.isDenied) {
|
|
String? message = _permissionMessages[permission];
|
|
if (message != null) {
|
|
showBar<void>(context, message);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
if (status.isGranted) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|