mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-18 05:51:34 +02:00
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into CW-237-enhance-error-catching-reporting
This commit is contained in:
@@ -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<BuyWebViewPageBody> {
|
||||
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<BuyWebViewPageBody> {
|
||||
_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<BuyWebViewPageBody> {
|
||||
|
||||
@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;
|
||||
|
||||
|
||||
@@ -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,
|
||||
'',
|
||||
<String, dynamic>{
|
||||
Uri get uri => Uri.https(baseUrl, '', <String, dynamic>{
|
||||
'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<OnRamperPageBody> {
|
||||
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,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@ class IoniaCreateAccountPage extends BasePage {
|
||||
final FocusNode _emailFocus;
|
||||
final TextEditingController _emailController;
|
||||
|
||||
static const privacyPolicyUrl = 'https://ionia.docsend.com/view/jaqsmbq9w7dzvnqf';
|
||||
static const termsAndConditionsUrl = 'https://ionia.docsend.com/view/hi9awnwxr6mqgiqj';
|
||||
static const privacyPolicyUrl = 'https://ionia.docsend.com/view/jhjvdn7qq7k3ukwt';
|
||||
static const termsAndConditionsUrl = 'https://ionia.docsend.com/view/uceirymz2ijacq5g';
|
||||
|
||||
@override
|
||||
Widget middle(BuildContext context) {
|
||||
|
||||
@@ -73,7 +73,7 @@ class ConnectionSyncPage extends BasePage {
|
||||
builder: (BuildContext context) {
|
||||
return AlertWithTwoActions(
|
||||
alertTitle: S.of(context).change_current_node_title,
|
||||
alertContent: S.of(context).change_current_node(node.uriRaw),
|
||||
alertContent: nodeListViewModel.getAlertContent(node.uriRaw),
|
||||
leftButtonText: S.of(context).cancel,
|
||||
rightButtonText: S.of(context).change,
|
||||
actionLeftButton: () => Navigator.of(context).pop(),
|
||||
|
||||
@@ -48,6 +48,8 @@ class CollapsibleSectionList extends SectionStandardList {
|
||||
child: ListTileTheme(
|
||||
contentPadding: EdgeInsets.only(right: 16,top:sectionIndex>0?26:0),
|
||||
child: ExpansionTile(
|
||||
textColor: themeColor,
|
||||
iconColor: themeColor,
|
||||
title: sectionTitleBuilder == null
|
||||
? Container()
|
||||
: Container(child: buildTitle(items, sectionIndex, context)),
|
||||
|
||||
Reference in New Issue
Block a user