Cw 553 update inappwebview (#1252)
* Update inapp webview and update it's deprecated code * Add Turkish Lira Fix android in-app webview * Change FAQ url [skip ci] * Fix available balance display issue
Omar Hatem committed
Jan 8, 2024 at 16:03 UTC
2a1bdf69ef743d72bd57d6dff765b1b0dd5c6a2c
10 files changed
+34
-41
android/app/build.gradle
+1
-1
@@ -37,7 +37,7 @@ if (appPropertiesFile.exists()) {
37
}
38
39
android {
40
- compileSdkVersion 33
40
+ compileSdkVersion 34
41
42
lintOptions {
43
disable 'InvalidPackage'
android/app/src/main/AndroidManifestBase.xml
+2
-2
@@ -71,8 +71,8 @@
71
android:name="flutterEmbedding"
72
android:value="2" />
73
<provider
74
- android:name="com.pichillilorenzo.flutter_inappwebview.InAppWebViewFileProvider"
75
- android:authorities="${applicationId}.flutter_inappwebview.fileprovider"
74
+ android:name="com.pichillilorenzo.flutter_inappwebview_android.InAppWebViewFileProvider"
75
+ android:authorities="${applicationId}.flutter_inappwebview_android.fileprovider"
76
android:exported="false"
77
android:grantUriPermissions="true">
78
<meta-data
cw_bitcoin/lib/electrum_balance.dart
+5
-11
@@ -1,13 +1,9 @@
1
import 'dart:convert';
2
-import 'package:flutter/foundation.dart';
2
import 'package:cw_bitcoin/bitcoin_amount_format.dart';
3
import 'package:cw_core/balance.dart';
4
5
class ElectrumBalance extends Balance {
7
- const ElectrumBalance(
8
- {required this.confirmed,
9
- required this.unconfirmed,
10
- required this.frozen})
6
+ const ElectrumBalance({required this.confirmed, required this.unconfirmed, required this.frozen})
7
: super(confirmed, unconfirmed);
8
9
static ElectrumBalance? fromJSON(String? jsonSource) {
@@ -28,12 +24,10 @@ class ElectrumBalance extends Balance {
24
final int frozen;
25
26
@override
31
- String get formattedAvailableBalance =>
32
- bitcoinAmountToString(amount: confirmed - unconfirmed.abs() - frozen);
27
+ String get formattedAvailableBalance => bitcoinAmountToString(amount: confirmed - frozen);
28
29
@override
35
- String get formattedAdditionalBalance =>
36
- bitcoinAmountToString(amount: unconfirmed);
30
+ String get formattedAdditionalBalance => bitcoinAmountToString(amount: unconfirmed);
31
32
@override
33
String get formattedUnAvailableBalance {
@@ -41,6 +35,6 @@ class ElectrumBalance extends Balance {
35
return frozenFormatted == '0.0' ? '' : frozenFormatted;
36
}
37
44
- String toJSON() => json.encode(
45
- {'confirmed': confirmed, 'unconfirmed': unconfirmed, 'frozen': frozen});
38
+ String toJSON() =>
39
+ json.encode({'confirmed': confirmed, 'unconfirmed': unconfirmed, 'frozen': frozen});
40
}
lib/entities/fiat_currency.dart
+4
-2
@@ -10,7 +10,7 @@ class FiatCurrency extends EnumerableItem<String> with Serializable<String> impl
10
static List<FiatCurrency> get all => _all.values.toList();
11
12
static List<FiatCurrency> get currenciesAvailableToBuyWith =>
13
- [aud, bgn, brl, cad, chf, clp, cop, czk, dkk, egp, eur, gbp, gtq, hkd, hrk, huf, idr, ils, inr, isk, jpy, krw, mad, mxn, myr, ngn, nok, nzd, php, pkr, pln, ron, sek, sgd, thb, twd, usd, vnd, zar];
13
+ [aud, bgn, brl, cad, chf, clp, cop, czk, dkk, egp, eur, gbp, gtq, hkd, hrk, huf, idr, ils, inr, isk, jpy, krw, mad, mxn, myr, ngn, nok, nzd, php, pkr, pln, ron, sek, sgd, thb, twd, usd, vnd, zar, tur];
14
15
static const ars = FiatCurrency(symbol: 'ARS', countryCode: "arg", fullName: "Argentine Peso");
16
static const aud = FiatCurrency(symbol: 'AUD', countryCode: "aus", fullName: "Australian Dollar");
@@ -60,6 +60,7 @@ class FiatCurrency extends EnumerableItem<String> with Serializable<String> impl
60
static const vef = FiatCurrency(symbol: 'VEF', countryCode: "ven", fullName: "Venezuelan Bolivar Bolívar");
61
static const vnd = FiatCurrency(symbol: 'VND', countryCode: "vnm", fullName: "Vietnamese Dong đồng");
62
static const zar = FiatCurrency(symbol: 'ZAR', countryCode: "saf", fullName: "South African Rand");
63
+ static const tur = FiatCurrency(symbol: 'TRY', countryCode: "tur", fullName: "Turkish Lira");
64
65
static final _all = {
66
FiatCurrency.ars.raw: FiatCurrency.ars,
@@ -109,7 +110,8 @@ class FiatCurrency extends EnumerableItem<String> with Serializable<String> impl
110
FiatCurrency.usd.raw: FiatCurrency.usd,
111
FiatCurrency.vef.raw: FiatCurrency.vef,
112
FiatCurrency.vnd.raw: FiatCurrency.vnd,
112
- FiatCurrency.zar.raw: FiatCurrency.zar
113
+ FiatCurrency.zar.raw: FiatCurrency.zar,
114
+ FiatCurrency.tur.raw: FiatCurrency.tur,
115
};
116
117
static FiatCurrency deserialize({required String raw}) => _all[raw]!;
lib/src/screens/buy/buy_webview_page.dart
+3
-6
@@ -1,10 +1,7 @@
1
import 'dart:async';
2
-import 'dart:io';
3
-import 'package:cake_wallet/buy/buy_provider.dart';
2
import 'package:cake_wallet/buy/moonpay/moonpay_provider.dart';
3
import 'package:cake_wallet/buy/wyre/wyre_buy_provider.dart';
4
import 'package:cake_wallet/generated/i18n.dart';
7
-import 'package:cake_wallet/palette.dart';
5
import 'package:cake_wallet/src/screens/base_page.dart';
6
import 'package:cake_wallet/store/dashboard/orders_store.dart';
7
import 'package:cake_wallet/view_model/buy/buy_view_model.dart';
@@ -72,10 +69,10 @@ class BuyWebViewPageBodyState extends State<BuyWebViewPageBody> {
69
Widget build(BuildContext context) {
70
return InAppWebView(
71
key: _webViewkey,
75
- initialOptions: InAppWebViewGroupOptions(
76
- crossPlatform: InAppWebViewOptions(transparentBackground: true),
72
+ initialSettings: InAppWebViewSettings(
73
+ transparentBackground: true,
74
),
78
- initialUrlRequest: URLRequest(url: Uri.tryParse(widget.url ?? '')),
75
+ initialUrlRequest: URLRequest(url: WebUri(widget.url ?? '')),
76
onWebViewCreated: (InAppWebViewController controller) =>
77
setState(() => _webViewController = controller));
78
}
lib/src/screens/buy/webview_page.dart
+8
-10
@@ -1,5 +1,3 @@
1
-import 'package:cake_wallet/buy/onramper/onramper_buy_provider.dart';
2
-import 'package:cake_wallet/generated/i18n.dart';
1
import 'package:cake_wallet/src/screens/base_page.dart';
2
import 'package:flutter/material.dart';
3
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
@@ -35,21 +33,21 @@ class WebViewPageBodyState extends State<WebViewPageBody> {
33
@override
34
Widget build(BuildContext context) {
35
return InAppWebView(
38
- initialOptions: InAppWebViewGroupOptions(
39
- crossPlatform: InAppWebViewOptions(transparentBackground: true),
36
+ initialSettings: InAppWebViewSettings(
37
+ transparentBackground: true,
38
),
41
- initialUrlRequest: URLRequest(url: widget.uri),
42
- androidOnPermissionRequest: (_, __, resources) async {
39
+ initialUrlRequest: URLRequest(url: WebUri.uri(widget.uri)),
40
+ onPermissionRequest: (controller, request) async {
41
bool permissionGranted = await Permission.camera.status == PermissionStatus.granted;
42
if (!permissionGranted) {
43
permissionGranted = await Permission.camera.request().isGranted;
44
}
45
48
- return PermissionRequestResponse(
49
- resources: resources,
46
+ return PermissionResponse(
47
+ resources: request.resources,
48
action: permissionGranted
51
- ? PermissionRequestResponseAction.GRANT
52
- : PermissionRequestResponseAction.DENY,
49
+ ? PermissionResponseAction.GRANT
50
+ : PermissionResponseAction.DENY,
51
);
52
},
53
);
lib/src/screens/dashboard/pages/transactions_page.dart
+1
-1
@@ -49,7 +49,7 @@ class TransactionsPage extends StatelessWidget {
49
onTap: () => Navigator.of(context).pushNamed(Routes.webViewPage, arguments: [
50
'',
51
Uri.parse(
52
- 'https://guides.cakewallet.com/docs/bugs-service-status/why_are_my_funds_not_appearing/')
52
+ 'https://guides.cakewallet.com/docs/FAQ/why_are_my_funds_not_appearing/')
53
]),
54
title: S.of(context).syncing_wallet_alert_title,
55
subTitle: S.of(context).syncing_wallet_alert_content,
lib/src/screens/support_chat/widgets/chatwoot_widget.dart
+7
-7
@@ -22,17 +22,17 @@ class ChatwootWidgetState extends State<ChatwootWidget> {
22
@override
23
Widget build(BuildContext context) => InAppWebView(
24
key: _webViewkey,
25
- initialOptions: InAppWebViewGroupOptions(
26
- crossPlatform: InAppWebViewOptions(transparentBackground: true),
27
- ),
28
- initialUrlRequest: URLRequest(url: Uri.tryParse(widget.supportUrl)),
25
+ initialSettings: InAppWebViewSettings(
26
+ transparentBackground: true,
27
+ ),
28
+ initialUrlRequest: URLRequest(url: WebUri(widget.supportUrl)),
29
onWebViewCreated: (InAppWebViewController controller) {
30
controller.addWebMessageListener(
31
WebMessageListener(
32
jsObjectName: 'ReactNativeWebView',
33
- onPostMessage: (String? message, Uri? sourceOrigin, bool isMainFrame,
34
- JavaScriptReplyProxy replyProxy) {
35
- final shortenedMessage = message?.substring(16);
33
+ onPostMessage: (WebMessage? message, WebUri? sourceOrigin, bool isMainFrame,
34
+ PlatformJavaScriptReplyProxy replyProxy) {
35
+ final shortenedMessage = message?.data.toString().substring(16);
36
if (shortenedMessage != null && isJsonString(shortenedMessage)) {
37
final parsedMessage = jsonDecode(shortenedMessage);
38
final eventType = parsedMessage["event"];
macos/Flutter/GeneratedPluginRegistrant.swift
+2
@@ -9,6 +9,7 @@ import connectivity_plus_macos
9
import cw_monero
10
import device_info_plus
11
import devicelocale
12
+import flutter_inappwebview_macos
13
import flutter_secure_storage_macos
14
import in_app_review
15
import package_info
@@ -24,6 +25,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
25
CwMoneroPlugin.register(with: registry.registrar(forPlugin: "CwMoneroPlugin"))
26
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
27
DevicelocalePlugin.register(with: registry.registrar(forPlugin: "DevicelocalePlugin"))
28
+ InAppWebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "InAppWebViewFlutterPlugin"))
29
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
30
InAppReviewPlugin.register(with: registry.registrar(forPlugin: "InAppReviewPlugin"))
31
FLTPackageInfoPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlugin"))
pubspec_base.yaml
+1
-1
@@ -43,7 +43,7 @@ dependencies:
43
auto_size_text: ^3.0.0
44
dotted_border: ^2.0.0+2
45
smooth_page_indicator: ^1.0.0+2
46
- flutter_inappwebview: ^5.7.2+3
46
+ flutter_inappwebview: ^6.0.0
47
flutter_spinkit: ^5.1.0
48
uni_links: ^0.5.1
49
lottie: ^1.3.0