Update permission status

Godwin Asuquo committed Jan 16, 2023 at 19:25 UTC aced1ed14719d4681b69601497a50bd6436d6cc3
1 file changed +18 -23
lib/src/screens/buy/onramper_page.dart
+18 -23
@@ -8,9 +8,7 @@ import 'package:flutter_inappwebview/flutter_inappwebview.dart';
8 import 'package:permission_handler/permission_handler.dart';
9
10 class OnRamperPage extends BasePage {
11 - OnRamperPage({
12 - required this.settingsStore,
13 - required this.wallet});
11 + OnRamperPage({required this.settingsStore, required this.wallet});
12
13 final SettingsStore settingsStore;
14 final WalletBase wallet;
@@ -25,22 +23,20 @@ class OnRamperPage extends BasePage {
23 settingsStore: settingsStore,
24 wallet: wallet,
25 darkMode: darkMode,
28 - backgroundColor: darkMode
29 - ? backgroundDarkColor
30 - : backgroundLightColor,
26 + backgroundColor: darkMode ? backgroundDarkColor : backgroundLightColor,
27 supportSell: false,
28 supportSwap: false);
29 }
30 }
31
32 class OnRamperPageBody extends StatefulWidget {
37 - OnRamperPageBody({
38 - required this.settingsStore,
39 - required this.wallet,
40 - required this.darkMode,
41 - required this.supportSell,
42 - required this.supportSwap,
43 - required this.backgroundColor});
33 + OnRamperPageBody(
34 + {required this.settingsStore,
35 + required this.wallet,
36 + required this.darkMode,
37 + required this.supportSell,
38 + required this.supportSwap,
39 + required this.backgroundColor});
40
41 static const baseUrl = 'widget.onramper.com';
42 final SettingsStore settingsStore;
@@ -50,18 +46,15 @@ class OnRamperPageBody extends StatefulWidget {
46 final bool supportSell;
47 final bool supportSwap;
48
53 - Uri get uri
54 - => Uri.https(
55 - baseUrl,
56 - '',
57 - <String, dynamic>{
49 + Uri get uri => Uri.https(baseUrl, '', <String, dynamic>{
50 'apiKey': secrets.onramperApiKey,
51 'defaultCrypto': wallet.currency.title,
52 'defaultFiat': settingsStore.fiatCurrency.title,
53 'wallets': '${wallet.currency.title}:${wallet.walletAddresses.address}',
54 'darkMode': darkMode.toString(),
55 'supportSell': supportSell.toString(),
64 - 'supportSwap': supportSwap.toString()});
56 + 'supportSwap': supportSwap.toString()
57 + });
58
59 @override
60 OnRamperPageBodyState createState() => OnRamperPageBodyState();
@@ -82,14 +75,16 @@ class OnRamperPageBodyState extends State<OnRamperPageBody> {
75 ),
76 ),
77 androidOnPermissionRequest: (_, __, resources) async {
85 -
86 - if (await Permission.camera.status != PermissionStatus.granted){
87 - await Permission.camera.request();
78 + bool permissionNotGranted = await Permission.camera.status != PermissionStatus.granted;
79 + if (permissionNotGranted) {
80 + permissionNotGranted = await Permission.camera.request().isGranted;
81 }
82
83 return PermissionRequestResponse(
84 resources: resources,
92 - action: PermissionRequestResponseAction.GRANT,
85 + action: permissionNotGranted
86 + ? PermissionRequestResponseAction.DENY
87 + : PermissionRequestResponseAction.GRANT,
88 );
89 },
90 );