diff --git a/android/app/src/main/AndroidManifestBase.xml b/android/app/src/main/AndroidManifestBase.xml
index 9f6b65785..2dbedcba9 100644
--- a/android/app/src/main/AndroidManifestBase.xml
+++ b/android/app/src/main/AndroidManifestBase.xml
@@ -6,6 +6,7 @@
+
+
+
+
diff --git a/lib/src/screens/buy/buy_webview_page.dart b/lib/src/screens/buy/buy_webview_page.dart
index 7c0ca903f..b19a112fc 100644
--- a/lib/src/screens/buy/buy_webview_page.dart
+++ b/lib/src/screens/buy/buy_webview_page.dart
@@ -9,11 +9,10 @@ import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/store/dashboard/orders_store.dart';
import 'package:cake_wallet/view_model/buy/buy_view_model.dart';
import 'package:flutter/material.dart';
-import 'package:webview_flutter/webview_flutter.dart';
+import 'package:flutter_inappwebview/flutter_inappwebview.dart';
class BuyWebViewPage extends BasePage {
- BuyWebViewPage({required this.buyViewModel,
- required this.ordersStore, required this.url});
+ BuyWebViewPage({required this.buyViewModel, required this.ordersStore, required this.url});
final OrdersStore ordersStore;
final String url;
@@ -46,12 +45,12 @@ class BuyWebViewPageBody extends StatefulWidget {
class BuyWebViewPageBodyState extends State {
BuyWebViewPageBodyState()
- : _webViewkey = GlobalKey(),
- _isSaving = false,
- orderId = '';
+ : _webViewkey = GlobalKey(),
+ _isSaving = false,
+ orderId = '';
String orderId;
- WebViewController? _webViewController;
+ InAppWebViewController? _webViewController;
GlobalKey _webViewkey;
Timer? _timer;
bool _isSaving;
@@ -63,8 +62,6 @@ class BuyWebViewPageBodyState extends State {
_isSaving = false;
widget.ordersStore.orderId = '';
- if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView();
-
if (widget.buyViewModel.selectedProvider is WyreBuyProvider) {
_saveOrder(keyword: 'completed', splitSymbol: '/');
}
@@ -76,31 +73,31 @@ class BuyWebViewPageBodyState extends State {
@override
Widget build(BuildContext context) {
- return WebView(
+ return InAppWebView(
key: _webViewkey,
- initialUrl: widget.url,
- javascriptMode: JavascriptMode.unrestricted,
- onWebViewCreated: (WebViewController controller) =>
+ initialOptions: InAppWebViewGroupOptions(
+ crossPlatform: InAppWebViewOptions(transparentBackground: true),
+ ),
+ initialUrlRequest: URLRequest(url: Uri.tryParse(widget.url ?? '')),
+ onWebViewCreated: (InAppWebViewController controller) =>
setState(() => _webViewController = controller));
}
void _saveOrder({required String keyword, required String splitSymbol}) {
_timer?.cancel();
_timer = Timer.periodic(Duration(seconds: 1), (timer) async {
-
try {
if (_webViewController == null || _isSaving) {
return;
}
- final url = await _webViewController!.currentUrl();
-
+ final url = (await _webViewController!.getUrl())?.toString();
if (url == null) {
throw Exception('_saveOrder: Url is null');
}
- if (url!.contains(keyword)) {
- final urlParts = url!.split(splitSymbol);
+ if (url.contains(keyword)) {
+ final urlParts = url.split(splitSymbol);
orderId = urlParts.last;
widget.ordersStore.orderId = orderId;
diff --git a/lib/src/screens/buy/onramper_page.dart b/lib/src/screens/buy/onramper_page.dart
index b766fd388..4973cef0b 100644
--- a/lib/src/screens/buy/onramper_page.dart
+++ b/lib/src/screens/buy/onramper_page.dart
@@ -1,16 +1,14 @@
-import 'dart:io';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/store/settings_store.dart';
import 'package:cw_core/wallet_base.dart';
import 'package:flutter/material.dart';
-import 'package:webview_flutter/webview_flutter.dart';
import 'package:cake_wallet/.secrets.g.dart' as secrets;
+import 'package:flutter_inappwebview/flutter_inappwebview.dart';
+import 'package:permission_handler/permission_handler.dart';
class OnRamperPage extends BasePage {
- OnRamperPage({
- required this.settingsStore,
- required this.wallet});
+ OnRamperPage({required this.settingsStore, required this.wallet});
final SettingsStore settingsStore;
final WalletBase wallet;
@@ -25,22 +23,20 @@ class OnRamperPage extends BasePage {
settingsStore: settingsStore,
wallet: wallet,
darkMode: darkMode,
- backgroundColor: darkMode
- ? backgroundDarkColor
- : backgroundLightColor,
+ backgroundColor: darkMode ? backgroundDarkColor : backgroundLightColor,
supportSell: false,
supportSwap: false);
}
}
class OnRamperPageBody extends StatefulWidget {
- OnRamperPageBody({
- required this.settingsStore,
- required this.wallet,
- required this.darkMode,
- required this.supportSell,
- required this.supportSwap,
- required this.backgroundColor});
+ OnRamperPageBody(
+ {required this.settingsStore,
+ required this.wallet,
+ required this.darkMode,
+ required this.supportSell,
+ required this.supportSwap,
+ required this.backgroundColor});
static const baseUrl = 'widget.onramper.com';
final SettingsStore settingsStore;
@@ -50,18 +46,15 @@ class OnRamperPageBody extends StatefulWidget {
final bool supportSell;
final bool supportSwap;
- Uri get uri
- => Uri.https(
- baseUrl,
- '',
- {
+ Uri get uri => Uri.https(baseUrl, '', {
'apiKey': secrets.onramperApiKey,
'defaultCrypto': wallet.currency.title,
'defaultFiat': settingsStore.fiatCurrency.title,
'wallets': '${wallet.currency.title}:${wallet.walletAddresses.address}',
'darkMode': darkMode.toString(),
'supportSell': supportSell.toString(),
- 'supportSwap': supportSwap.toString()});
+ 'supportSwap': supportSwap.toString()
+ });
@override
OnRamperPageBodyState createState() => OnRamperPageBodyState();
@@ -70,17 +63,26 @@ class OnRamperPageBody extends StatefulWidget {
class OnRamperPageBodyState extends State {
OnRamperPageBodyState();
- @override
- void initState() {
- super.initState();
- if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView();
- }
-
@override
Widget build(BuildContext context) {
- return WebView(
- initialUrl: widget.uri.toString(),
- backgroundColor: widget.backgroundColor,
- javascriptMode: JavascriptMode.unrestricted);
+ return InAppWebView(
+ initialOptions: InAppWebViewGroupOptions(
+ crossPlatform: InAppWebViewOptions(transparentBackground: true),
+ ),
+ initialUrlRequest: URLRequest(url: widget.uri),
+ androidOnPermissionRequest: (_, __, resources) async {
+ bool permissionGranted = await Permission.camera.status == PermissionStatus.granted;
+ if (!permissionGranted) {
+ permissionGranted = await Permission.camera.request().isGranted;
+ }
+
+ return PermissionRequestResponse(
+ resources: resources,
+ action: permissionGranted
+ ? PermissionRequestResponseAction.GRANT
+ : PermissionRequestResponseAction.DENY,
+ );
+ },
+ );
}
}
diff --git a/pubspec_base.yaml b/pubspec_base.yaml
index 00e1a39b1..8c9b75379 100644
--- a/pubspec_base.yaml
+++ b/pubspec_base.yaml
@@ -38,7 +38,7 @@ dependencies:
auto_size_text: ^3.0.0
dotted_border: ^2.0.0+2
smooth_page_indicator: ^1.0.0+2
- webview_flutter: ^3.0.4
+ flutter_inappwebview: ^5.7.2+3
flutter_spinkit: ^5.1.0
uni_links: ^0.5.1
lottie: ^1.3.0