Update permission status

This commit is contained in:
Godwin Asuquo 2023-01-16 19:25:29 +01:00
parent 3d5bce903d
commit aced1ed147

View file

@ -8,9 +8,7 @@ import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
class OnRamperPage extends BasePage { class OnRamperPage extends BasePage {
OnRamperPage({ OnRamperPage({required this.settingsStore, required this.wallet});
required this.settingsStore,
required this.wallet});
final SettingsStore settingsStore; final SettingsStore settingsStore;
final WalletBase wallet; final WalletBase wallet;
@ -25,22 +23,20 @@ class OnRamperPage extends BasePage {
settingsStore: settingsStore, settingsStore: settingsStore,
wallet: wallet, wallet: wallet,
darkMode: darkMode, darkMode: darkMode,
backgroundColor: darkMode backgroundColor: darkMode ? backgroundDarkColor : backgroundLightColor,
? backgroundDarkColor
: backgroundLightColor,
supportSell: false, supportSell: false,
supportSwap: false); supportSwap: false);
} }
} }
class OnRamperPageBody extends StatefulWidget { class OnRamperPageBody extends StatefulWidget {
OnRamperPageBody({ OnRamperPageBody(
required this.settingsStore, {required this.settingsStore,
required this.wallet, required this.wallet,
required this.darkMode, required this.darkMode,
required this.supportSell, required this.supportSell,
required this.supportSwap, required this.supportSwap,
required this.backgroundColor}); required this.backgroundColor});
static const baseUrl = 'widget.onramper.com'; static const baseUrl = 'widget.onramper.com';
final SettingsStore settingsStore; final SettingsStore settingsStore;
@ -50,18 +46,15 @@ class OnRamperPageBody extends StatefulWidget {
final bool supportSell; final bool supportSell;
final bool supportSwap; final bool supportSwap;
Uri get uri Uri get uri => Uri.https(baseUrl, '', <String, dynamic>{
=> Uri.https(
baseUrl,
'',
<String, dynamic>{
'apiKey': secrets.onramperApiKey, 'apiKey': secrets.onramperApiKey,
'defaultCrypto': wallet.currency.title, 'defaultCrypto': wallet.currency.title,
'defaultFiat': settingsStore.fiatCurrency.title, 'defaultFiat': settingsStore.fiatCurrency.title,
'wallets': '${wallet.currency.title}:${wallet.walletAddresses.address}', 'wallets': '${wallet.currency.title}:${wallet.walletAddresses.address}',
'darkMode': darkMode.toString(), 'darkMode': darkMode.toString(),
'supportSell': supportSell.toString(), 'supportSell': supportSell.toString(),
'supportSwap': supportSwap.toString()}); 'supportSwap': supportSwap.toString()
});
@override @override
OnRamperPageBodyState createState() => OnRamperPageBodyState(); OnRamperPageBodyState createState() => OnRamperPageBodyState();
@ -82,14 +75,16 @@ class OnRamperPageBodyState extends State<OnRamperPageBody> {
), ),
), ),
androidOnPermissionRequest: (_, __, resources) async { androidOnPermissionRequest: (_, __, resources) async {
bool permissionNotGranted = await Permission.camera.status != PermissionStatus.granted;
if (await Permission.camera.status != PermissionStatus.granted){ if (permissionNotGranted) {
await Permission.camera.request(); permissionNotGranted = await Permission.camera.request().isGranted;
} }
return PermissionRequestResponse( return PermissionRequestResponse(
resources: resources, resources: resources,
action: PermissionRequestResponseAction.GRANT, action: permissionNotGranted
? PermissionRequestResponseAction.DENY
: PermissionRequestResponseAction.GRANT,
); );
}, },
); );