mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 11:39:22 +00:00
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
This commit is contained in:
parent
26cde6a193
commit
2a1bdf69ef
10 changed files with 34 additions and 41 deletions
|
@ -37,7 +37,7 @@ if (appPropertiesFile.exists()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 33
|
compileSdkVersion 34
|
||||||
|
|
||||||
lintOptions {
|
lintOptions {
|
||||||
disable 'InvalidPackage'
|
disable 'InvalidPackage'
|
||||||
|
|
|
@ -71,8 +71,8 @@
|
||||||
android:name="flutterEmbedding"
|
android:name="flutterEmbedding"
|
||||||
android:value="2" />
|
android:value="2" />
|
||||||
<provider
|
<provider
|
||||||
android:name="com.pichillilorenzo.flutter_inappwebview.InAppWebViewFileProvider"
|
android:name="com.pichillilorenzo.flutter_inappwebview_android.InAppWebViewFileProvider"
|
||||||
android:authorities="${applicationId}.flutter_inappwebview.fileprovider"
|
android:authorities="${applicationId}.flutter_inappwebview_android.fileprovider"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:grantUriPermissions="true">
|
android:grantUriPermissions="true">
|
||||||
<meta-data
|
<meta-data
|
||||||
|
|
|
@ -1,13 +1,9 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:cw_bitcoin/bitcoin_amount_format.dart';
|
import 'package:cw_bitcoin/bitcoin_amount_format.dart';
|
||||||
import 'package:cw_core/balance.dart';
|
import 'package:cw_core/balance.dart';
|
||||||
|
|
||||||
class ElectrumBalance extends Balance {
|
class ElectrumBalance extends Balance {
|
||||||
const ElectrumBalance(
|
const ElectrumBalance({required this.confirmed, required this.unconfirmed, required this.frozen})
|
||||||
{required this.confirmed,
|
|
||||||
required this.unconfirmed,
|
|
||||||
required this.frozen})
|
|
||||||
: super(confirmed, unconfirmed);
|
: super(confirmed, unconfirmed);
|
||||||
|
|
||||||
static ElectrumBalance? fromJSON(String? jsonSource) {
|
static ElectrumBalance? fromJSON(String? jsonSource) {
|
||||||
|
@ -28,12 +24,10 @@ class ElectrumBalance extends Balance {
|
||||||
final int frozen;
|
final int frozen;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get formattedAvailableBalance =>
|
String get formattedAvailableBalance => bitcoinAmountToString(amount: confirmed - frozen);
|
||||||
bitcoinAmountToString(amount: confirmed - unconfirmed.abs() - frozen);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get formattedAdditionalBalance =>
|
String get formattedAdditionalBalance => bitcoinAmountToString(amount: unconfirmed);
|
||||||
bitcoinAmountToString(amount: unconfirmed);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get formattedUnAvailableBalance {
|
String get formattedUnAvailableBalance {
|
||||||
|
@ -41,6 +35,6 @@ class ElectrumBalance extends Balance {
|
||||||
return frozenFormatted == '0.0' ? '' : frozenFormatted;
|
return frozenFormatted == '0.0' ? '' : frozenFormatted;
|
||||||
}
|
}
|
||||||
|
|
||||||
String toJSON() => json.encode(
|
String toJSON() =>
|
||||||
{'confirmed': confirmed, 'unconfirmed': unconfirmed, 'frozen': frozen});
|
json.encode({'confirmed': confirmed, 'unconfirmed': unconfirmed, 'frozen': frozen});
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ class FiatCurrency extends EnumerableItem<String> with Serializable<String> impl
|
||||||
static List<FiatCurrency> get all => _all.values.toList();
|
static List<FiatCurrency> get all => _all.values.toList();
|
||||||
|
|
||||||
static List<FiatCurrency> get currenciesAvailableToBuyWith =>
|
static List<FiatCurrency> get currenciesAvailableToBuyWith =>
|
||||||
[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];
|
[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];
|
||||||
|
|
||||||
static const ars = FiatCurrency(symbol: 'ARS', countryCode: "arg", fullName: "Argentine Peso");
|
static const ars = FiatCurrency(symbol: 'ARS', countryCode: "arg", fullName: "Argentine Peso");
|
||||||
static const aud = FiatCurrency(symbol: 'AUD', countryCode: "aus", fullName: "Australian Dollar");
|
static const aud = FiatCurrency(symbol: 'AUD', countryCode: "aus", fullName: "Australian Dollar");
|
||||||
|
@ -60,6 +60,7 @@ class FiatCurrency extends EnumerableItem<String> with Serializable<String> impl
|
||||||
static const vef = FiatCurrency(symbol: 'VEF', countryCode: "ven", fullName: "Venezuelan Bolivar Bolívar");
|
static const vef = FiatCurrency(symbol: 'VEF', countryCode: "ven", fullName: "Venezuelan Bolivar Bolívar");
|
||||||
static const vnd = FiatCurrency(symbol: 'VND', countryCode: "vnm", fullName: "Vietnamese Dong đồng");
|
static const vnd = FiatCurrency(symbol: 'VND', countryCode: "vnm", fullName: "Vietnamese Dong đồng");
|
||||||
static const zar = FiatCurrency(symbol: 'ZAR', countryCode: "saf", fullName: "South African Rand");
|
static const zar = FiatCurrency(symbol: 'ZAR', countryCode: "saf", fullName: "South African Rand");
|
||||||
|
static const tur = FiatCurrency(symbol: 'TRY', countryCode: "tur", fullName: "Turkish Lira");
|
||||||
|
|
||||||
static final _all = {
|
static final _all = {
|
||||||
FiatCurrency.ars.raw: FiatCurrency.ars,
|
FiatCurrency.ars.raw: FiatCurrency.ars,
|
||||||
|
@ -109,7 +110,8 @@ class FiatCurrency extends EnumerableItem<String> with Serializable<String> impl
|
||||||
FiatCurrency.usd.raw: FiatCurrency.usd,
|
FiatCurrency.usd.raw: FiatCurrency.usd,
|
||||||
FiatCurrency.vef.raw: FiatCurrency.vef,
|
FiatCurrency.vef.raw: FiatCurrency.vef,
|
||||||
FiatCurrency.vnd.raw: FiatCurrency.vnd,
|
FiatCurrency.vnd.raw: FiatCurrency.vnd,
|
||||||
FiatCurrency.zar.raw: FiatCurrency.zar
|
FiatCurrency.zar.raw: FiatCurrency.zar,
|
||||||
|
FiatCurrency.tur.raw: FiatCurrency.tur,
|
||||||
};
|
};
|
||||||
|
|
||||||
static FiatCurrency deserialize({required String raw}) => _all[raw]!;
|
static FiatCurrency deserialize({required String raw}) => _all[raw]!;
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
|
||||||
import 'package:cake_wallet/buy/buy_provider.dart';
|
|
||||||
import 'package:cake_wallet/buy/moonpay/moonpay_provider.dart';
|
import 'package:cake_wallet/buy/moonpay/moonpay_provider.dart';
|
||||||
import 'package:cake_wallet/buy/wyre/wyre_buy_provider.dart';
|
import 'package:cake_wallet/buy/wyre/wyre_buy_provider.dart';
|
||||||
import 'package:cake_wallet/generated/i18n.dart';
|
import 'package:cake_wallet/generated/i18n.dart';
|
||||||
import 'package:cake_wallet/palette.dart';
|
|
||||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||||
import 'package:cake_wallet/store/dashboard/orders_store.dart';
|
import 'package:cake_wallet/store/dashboard/orders_store.dart';
|
||||||
import 'package:cake_wallet/view_model/buy/buy_view_model.dart';
|
import 'package:cake_wallet/view_model/buy/buy_view_model.dart';
|
||||||
|
@ -72,10 +69,10 @@ class BuyWebViewPageBodyState extends State<BuyWebViewPageBody> {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return InAppWebView(
|
return InAppWebView(
|
||||||
key: _webViewkey,
|
key: _webViewkey,
|
||||||
initialOptions: InAppWebViewGroupOptions(
|
initialSettings: InAppWebViewSettings(
|
||||||
crossPlatform: InAppWebViewOptions(transparentBackground: true),
|
transparentBackground: true,
|
||||||
),
|
),
|
||||||
initialUrlRequest: URLRequest(url: Uri.tryParse(widget.url ?? '')),
|
initialUrlRequest: URLRequest(url: WebUri(widget.url ?? '')),
|
||||||
onWebViewCreated: (InAppWebViewController controller) =>
|
onWebViewCreated: (InAppWebViewController controller) =>
|
||||||
setState(() => _webViewController = controller));
|
setState(() => _webViewController = controller));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import 'package:cake_wallet/buy/onramper/onramper_buy_provider.dart';
|
|
||||||
import 'package:cake_wallet/generated/i18n.dart';
|
|
||||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
||||||
|
@ -35,21 +33,21 @@ class WebViewPageBodyState extends State<WebViewPageBody> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return InAppWebView(
|
return InAppWebView(
|
||||||
initialOptions: InAppWebViewGroupOptions(
|
initialSettings: InAppWebViewSettings(
|
||||||
crossPlatform: InAppWebViewOptions(transparentBackground: true),
|
transparentBackground: true,
|
||||||
),
|
),
|
||||||
initialUrlRequest: URLRequest(url: widget.uri),
|
initialUrlRequest: URLRequest(url: WebUri.uri(widget.uri)),
|
||||||
androidOnPermissionRequest: (_, __, resources) async {
|
onPermissionRequest: (controller, request) async {
|
||||||
bool permissionGranted = await Permission.camera.status == PermissionStatus.granted;
|
bool permissionGranted = await Permission.camera.status == PermissionStatus.granted;
|
||||||
if (!permissionGranted) {
|
if (!permissionGranted) {
|
||||||
permissionGranted = await Permission.camera.request().isGranted;
|
permissionGranted = await Permission.camera.request().isGranted;
|
||||||
}
|
}
|
||||||
|
|
||||||
return PermissionRequestResponse(
|
return PermissionResponse(
|
||||||
resources: resources,
|
resources: request.resources,
|
||||||
action: permissionGranted
|
action: permissionGranted
|
||||||
? PermissionRequestResponseAction.GRANT
|
? PermissionResponseAction.GRANT
|
||||||
: PermissionRequestResponseAction.DENY,
|
: PermissionResponseAction.DENY,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -49,7 +49,7 @@ class TransactionsPage extends StatelessWidget {
|
||||||
onTap: () => Navigator.of(context).pushNamed(Routes.webViewPage, arguments: [
|
onTap: () => Navigator.of(context).pushNamed(Routes.webViewPage, arguments: [
|
||||||
'',
|
'',
|
||||||
Uri.parse(
|
Uri.parse(
|
||||||
'https://guides.cakewallet.com/docs/bugs-service-status/why_are_my_funds_not_appearing/')
|
'https://guides.cakewallet.com/docs/FAQ/why_are_my_funds_not_appearing/')
|
||||||
]),
|
]),
|
||||||
title: S.of(context).syncing_wallet_alert_title,
|
title: S.of(context).syncing_wallet_alert_title,
|
||||||
subTitle: S.of(context).syncing_wallet_alert_content,
|
subTitle: S.of(context).syncing_wallet_alert_content,
|
||||||
|
|
|
@ -22,17 +22,17 @@ class ChatwootWidgetState extends State<ChatwootWidget> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => InAppWebView(
|
Widget build(BuildContext context) => InAppWebView(
|
||||||
key: _webViewkey,
|
key: _webViewkey,
|
||||||
initialOptions: InAppWebViewGroupOptions(
|
initialSettings: InAppWebViewSettings(
|
||||||
crossPlatform: InAppWebViewOptions(transparentBackground: true),
|
transparentBackground: true,
|
||||||
),
|
),
|
||||||
initialUrlRequest: URLRequest(url: Uri.tryParse(widget.supportUrl)),
|
initialUrlRequest: URLRequest(url: WebUri(widget.supportUrl)),
|
||||||
onWebViewCreated: (InAppWebViewController controller) {
|
onWebViewCreated: (InAppWebViewController controller) {
|
||||||
controller.addWebMessageListener(
|
controller.addWebMessageListener(
|
||||||
WebMessageListener(
|
WebMessageListener(
|
||||||
jsObjectName: 'ReactNativeWebView',
|
jsObjectName: 'ReactNativeWebView',
|
||||||
onPostMessage: (String? message, Uri? sourceOrigin, bool isMainFrame,
|
onPostMessage: (WebMessage? message, WebUri? sourceOrigin, bool isMainFrame,
|
||||||
JavaScriptReplyProxy replyProxy) {
|
PlatformJavaScriptReplyProxy replyProxy) {
|
||||||
final shortenedMessage = message?.substring(16);
|
final shortenedMessage = message?.data.toString().substring(16);
|
||||||
if (shortenedMessage != null && isJsonString(shortenedMessage)) {
|
if (shortenedMessage != null && isJsonString(shortenedMessage)) {
|
||||||
final parsedMessage = jsonDecode(shortenedMessage);
|
final parsedMessage = jsonDecode(shortenedMessage);
|
||||||
final eventType = parsedMessage["event"];
|
final eventType = parsedMessage["event"];
|
||||||
|
|
|
@ -9,6 +9,7 @@ import connectivity_plus_macos
|
||||||
import cw_monero
|
import cw_monero
|
||||||
import device_info_plus
|
import device_info_plus
|
||||||
import devicelocale
|
import devicelocale
|
||||||
|
import flutter_inappwebview_macos
|
||||||
import flutter_secure_storage_macos
|
import flutter_secure_storage_macos
|
||||||
import in_app_review
|
import in_app_review
|
||||||
import package_info
|
import package_info
|
||||||
|
@ -24,6 +25,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||||
CwMoneroPlugin.register(with: registry.registrar(forPlugin: "CwMoneroPlugin"))
|
CwMoneroPlugin.register(with: registry.registrar(forPlugin: "CwMoneroPlugin"))
|
||||||
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
|
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
|
||||||
DevicelocalePlugin.register(with: registry.registrar(forPlugin: "DevicelocalePlugin"))
|
DevicelocalePlugin.register(with: registry.registrar(forPlugin: "DevicelocalePlugin"))
|
||||||
|
InAppWebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "InAppWebViewFlutterPlugin"))
|
||||||
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
|
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
|
||||||
InAppReviewPlugin.register(with: registry.registrar(forPlugin: "InAppReviewPlugin"))
|
InAppReviewPlugin.register(with: registry.registrar(forPlugin: "InAppReviewPlugin"))
|
||||||
FLTPackageInfoPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlugin"))
|
FLTPackageInfoPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlugin"))
|
||||||
|
|
|
@ -43,7 +43,7 @@ dependencies:
|
||||||
auto_size_text: ^3.0.0
|
auto_size_text: ^3.0.0
|
||||||
dotted_border: ^2.0.0+2
|
dotted_border: ^2.0.0+2
|
||||||
smooth_page_indicator: ^1.0.0+2
|
smooth_page_indicator: ^1.0.0+2
|
||||||
flutter_inappwebview: ^5.7.2+3
|
flutter_inappwebview: ^6.0.0
|
||||||
flutter_spinkit: ^5.1.0
|
flutter_spinkit: ^5.1.0
|
||||||
uni_links: ^0.5.1
|
uni_links: ^0.5.1
|
||||||
lottie: ^1.3.0
|
lottie: ^1.3.0
|
||||||
|
|
Loading…
Reference in a new issue