diff --git a/lib/buy/dfx/dfx_buy_provider.dart b/lib/buy/dfx/dfx_buy_provider.dart index 2a7e2ab13..35098f0d5 100644 --- a/lib/buy/dfx/dfx_buy_provider.dart +++ b/lib/buy/dfx/dfx_buy_provider.dart @@ -5,7 +5,6 @@ import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/routes.dart'; import 'package:cake_wallet/src/screens/connect_device/connect_device_page.dart'; import 'package:cake_wallet/src/widgets/alert_with_one_action.dart'; -import 'package:cake_wallet/utils/device_info.dart'; import 'package:cake_wallet/utils/show_pop_up.dart'; import 'package:cake_wallet/view_model/hardware_wallet/ledger_view_model.dart'; import 'package:cw_core/wallet_base.dart'; @@ -167,11 +166,7 @@ class DFXBuyProvider extends BuyProvider { }); if (await canLaunchUrl(uri)) { - if (DeviceInfo.instance.isMobile) { - Navigator.of(context).pushNamed(Routes.webViewPage, arguments: [title, uri]); - } else { - await launchUrl(uri, mode: LaunchMode.externalApplication); - } + await launchUrl(uri, mode: LaunchMode.externalApplication); } else { throw Exception('Could not launch URL'); } diff --git a/lib/buy/moonpay/moonpay_provider.dart b/lib/buy/moonpay/moonpay_provider.dart index 59251e064..7508690cc 100644 --- a/lib/buy/moonpay/moonpay_provider.dart +++ b/lib/buy/moonpay/moonpay_provider.dart @@ -9,11 +9,9 @@ import 'package:cake_wallet/buy/order.dart'; import 'package:cake_wallet/exchange/trade_state.dart'; import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/palette.dart'; -import 'package:cake_wallet/routes.dart'; import 'package:cake_wallet/src/widgets/alert_with_one_action.dart'; import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/themes/theme_base.dart'; -import 'package:cake_wallet/utils/device_info.dart'; import 'package:cw_core/crypto_currency.dart'; import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/wallet_type.dart'; @@ -272,11 +270,7 @@ class MoonPayProvider extends BuyProvider { } if (await canLaunchUrl(uri)) { - if (DeviceInfo.instance.isMobile) { - Navigator.of(context).pushNamed(Routes.webViewPage, arguments: ['MoonPay', uri]); - } else { - await launchUrl(uri, mode: LaunchMode.externalApplication); - } + await launchUrl(uri, mode: LaunchMode.externalApplication); } else { throw Exception('Could not launch URL'); } diff --git a/lib/buy/onramper/onramper_buy_provider.dart b/lib/buy/onramper/onramper_buy_provider.dart index 1f1c86962..ee7aeb43f 100644 --- a/lib/buy/onramper/onramper_buy_provider.dart +++ b/lib/buy/onramper/onramper_buy_provider.dart @@ -1,10 +1,8 @@ import 'package:cake_wallet/.secrets.g.dart' as secrets; import 'package:cake_wallet/buy/buy_provider.dart'; import 'package:cake_wallet/generated/i18n.dart'; -import 'package:cake_wallet/routes.dart'; import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/themes/extensions/cake_text_theme.dart'; -import 'package:cake_wallet/utils/device_info.dart'; import 'package:cw_core/crypto_currency.dart'; import 'package:cw_core/wallet_base.dart'; import 'package:flutter/material.dart'; @@ -94,11 +92,6 @@ class OnRamperBuyProvider extends BuyProvider { Future launchProvider(BuildContext context, bool? isBuyAction) async { final uri = requestOnramperUrl(context, isBuyAction); - if (DeviceInfo.instance.isMobile) { - Navigator.of(context) - .pushNamed(Routes.webViewPage, arguments: [title, uri]); - } else { - await launchUrl(uri); - } + await launchUrl(uri, mode: LaunchMode.externalApplication); } } diff --git a/lib/src/screens/dashboard/pages/transactions_page.dart b/lib/src/screens/dashboard/pages/transactions_page.dart index e5c94415f..033f10911 100644 --- a/lib/src/screens/dashboard/pages/transactions_page.dart +++ b/lib/src/screens/dashboard/pages/transactions_page.dart @@ -2,7 +2,6 @@ import 'package:cake_wallet/src/screens/dashboard/widgets/anonpay_transaction_ro import 'package:cake_wallet/src/screens/dashboard/widgets/order_row.dart'; import 'package:cake_wallet/themes/extensions/placeholder_theme.dart'; import 'package:cake_wallet/src/widgets/dashboard_card_widget.dart'; -import 'package:cake_wallet/utils/device_info.dart'; import 'package:cake_wallet/utils/responsive_layout_util.dart'; import 'package:cake_wallet/view_model/dashboard/anonpay_transaction_list_item.dart'; import 'package:cake_wallet/view_model/dashboard/order_list_item.dart'; @@ -52,11 +51,7 @@ class TransactionsPage extends StatelessWidget { try { final uri = Uri.parse( "https://guides.cakewallet.com/docs/FAQ/why_are_my_funds_not_appearing/"); - if (DeviceInfo.instance.isMobile) { - Navigator.of(context).pushNamed(Routes.webViewPage, arguments: ['', uri]); - } else { - launchUrl(uri); - } + launchUrl(uri, mode: LaunchMode.externalApplication); } catch (_) {} }, title: S.of(context).syncing_wallet_alert_title, diff --git a/lib/src/screens/disclaimer/disclaimer_page.dart b/lib/src/screens/disclaimer/disclaimer_page.dart index 3805f6240..f82a9efbe 100644 --- a/lib/src/screens/disclaimer/disclaimer_page.dart +++ b/lib/src/screens/disclaimer/disclaimer_page.dart @@ -46,10 +46,6 @@ class DisclaimerBodyState extends State { bool _checked = false; String _fileText = ''; - Future launchUrl(String url) async { - if (await canLaunch(url)) await launch(url); - } - Future getFileLines() async { _fileText = await rootBundle.loadString( isMoneroOnly @@ -152,7 +148,11 @@ class DisclaimerBodyState extends State { children: [ Expanded( child: GestureDetector( - onTap: () => launchUrl(changenowUrl), + onTap: () async { + final uri = Uri.parse(changenowUrl); + if (await canLaunchUrl(uri)) + await launchUrl(uri, mode: LaunchMode.externalApplication); + }, child: Text( changenowUrl, textAlign: TextAlign.left, diff --git a/lib/src/screens/ionia/auth/ionia_create_account_page.dart b/lib/src/screens/ionia/auth/ionia_create_account_page.dart index e6dc83c3c..4762216c1 100644 --- a/lib/src/screens/ionia/auth/ionia_create_account_page.dart +++ b/lib/src/screens/ionia/auth/ionia_create_account_page.dart @@ -107,7 +107,9 @@ class IoniaCreateAccountPage extends BasePage { ), recognizer: TapGestureRecognizer() ..onTap = () async { - if (await canLaunch(termsAndConditionsUrl)) await launch(termsAndConditionsUrl); + final uri = Uri.parse(termsAndConditionsUrl); + if (await canLaunchUrl(uri)) + await launchUrl(uri, mode: LaunchMode.externalApplication); }, ), TextSpan(text: ' ${S.of(context).and} '), @@ -119,7 +121,9 @@ class IoniaCreateAccountPage extends BasePage { ), recognizer: TapGestureRecognizer() ..onTap = () async { - if (await canLaunch(privacyPolicyUrl)) await launch(privacyPolicyUrl); + final uri = Uri.parse(privacyPolicyUrl); + if (await canLaunchUrl(uri)) + await launchUrl(uri, mode: LaunchMode.externalApplication); }), TextSpan(text: ' ${S.of(context).by_cake_pay}'), ], diff --git a/lib/src/screens/settings/widgets/settings_link_provider_cell.dart b/lib/src/screens/settings/widgets/settings_link_provider_cell.dart index 6e5d48a69..5b6d1881f 100644 --- a/lib/src/screens/settings/widgets/settings_link_provider_cell.dart +++ b/lib/src/screens/settings/widgets/settings_link_provider_cell.dart @@ -31,7 +31,8 @@ class SettingsLinkProviderCell extends StandardListRow { static void _launchUrl(String url) async { try { - await launch(url, forceSafariVC: false); + final uri = Uri.parse(url); + if (await canLaunchUrl(uri)) await launchUrl(uri, mode: LaunchMode.externalApplication); } catch (e) {} } } diff --git a/lib/src/screens/yat/yat_popup.dart b/lib/src/screens/yat/yat_popup.dart index 89a23d9c7..4ccd24259 100644 --- a/lib/src/screens/yat/yat_popup.dart +++ b/lib/src/screens/yat/yat_popup.dart @@ -161,27 +161,26 @@ class YatPopup extends StatelessWidget { onClose: onClose, onGet: () { var createNewYatUrl = YatLink.startFlowUrl; - final createNewYatUrlParameters = dashboardViewModel. - yatStore.defineQueryParameters(); - + final createNewYatUrlParameters = + dashboardViewModel.yatStore.defineQueryParameters(); + if (createNewYatUrlParameters.isNotEmpty) { createNewYatUrl += '?sub1=' + createNewYatUrlParameters; } - launch(createNewYatUrl, forceSafariVC: false); + final uri = Uri.parse(createNewYatUrl); + launchUrl(uri, mode: LaunchMode.externalApplication); }, onConnect: () { String url = baseUrl + YatLink.signInSuffix; - final parameters = dashboardViewModel - .yatStore.defineQueryParameters(); + final parameters = dashboardViewModel.yatStore.defineQueryParameters(); if (parameters.isNotEmpty) { url += YatLink.queryParameter + parameters; } - launch(url, forceSafariVC: false); - } - )) - : Container() - ) + final uri = Uri.parse(url); + launchUrl(uri, mode: LaunchMode.externalApplication); + })) + : Container()) ], ); } diff --git a/lib/src/widgets/services_updates_widget.dart b/lib/src/widgets/services_updates_widget.dart index 5d56e967d..1babd23d0 100644 --- a/lib/src/widgets/services_updates_widget.dart +++ b/lib/src/widgets/services_updates_widget.dart @@ -103,7 +103,8 @@ class _ServicesUpdatesWidgetState extends State { child: PrimaryImageButton( onPressed: () { try { - launchUrl(Uri.parse("https://status.cakewallet.com/")); + launchUrl(Uri.parse("https://status.cakewallet.com/"), + mode: LaunchMode.externalApplication); } catch (_) {} }, image: Image.asset( diff --git a/lib/view_model/order_details_view_model.dart b/lib/view_model/order_details_view_model.dart index 412f1b962..1eab2f861 100644 --- a/lib/view_model/order_details_view_model.dart +++ b/lib/view_model/order_details_view_model.dart @@ -19,7 +19,7 @@ class OrderDetailsViewModel = OrderDetailsViewModelBase abstract class OrderDetailsViewModelBase with Store { OrderDetailsViewModelBase({required WalletBase wallet, required Order orderForDetails}) - : items = ObservableList(), + : items = ObservableList(), order = orderForDetails { if (order.provider != null) { switch (order.provider) { @@ -101,13 +101,13 @@ abstract class OrderDetailsViewModelBase with Store { TrackTradeListItem( title: S.current.track, value: buildURL, - onTap: () { + onTap: () async { try { - launch(buildURL); + final uri = Uri.parse(buildURL); + if (await canLaunchUrl(uri)) + await launchUrl(uri, mode: LaunchMode.externalApplication); } catch (e) {} - } - ) - ); + })); } } diff --git a/lib/view_model/trade_details_view_model.dart b/lib/view_model/trade_details_view_model.dart index c88008982..eed1b6c75 100644 --- a/lib/view_model/trade_details_view_model.dart +++ b/lib/view_model/trade_details_view_model.dart @@ -179,7 +179,7 @@ abstract class TradeDetailsViewModelBase with Store { void _launchUrl(String url) { final uri = Uri.parse(url); try { - launchUrl(uri); + launchUrl(uri, mode: LaunchMode.externalApplication); } catch (e) {} } } diff --git a/lib/view_model/transaction_details_view_model.dart b/lib/view_model/transaction_details_view_model.dart index 526ff0335..fb889e5b7 100644 --- a/lib/view_model/transaction_details_view_model.dart +++ b/lib/view_model/transaction_details_view_model.dart @@ -99,9 +99,10 @@ abstract class TransactionDetailsViewModelBase with Store { items.add(BlockExplorerListItem( title: S.current.view_in_block_explorer, value: _explorerDescription(type), - onTap: () { + onTap: () async { try { - launch(_explorerUrl(type, tx.id)); + final uri = Uri.parse(_explorerUrl(type, tx.id)); + if (await canLaunchUrl(uri)) await launchUrl(uri, mode: LaunchMode.externalApplication); } catch (e) {} })); diff --git a/lib/view_model/unspent_coins/unspent_coins_details_view_model.dart b/lib/view_model/unspent_coins/unspent_coins_details_view_model.dart index fd142dd33..16f59aeb9 100644 --- a/lib/view_model/unspent_coins/unspent_coins_details_view_model.dart +++ b/lib/view_model/unspent_coins/unspent_coins_details_view_model.dart @@ -56,7 +56,7 @@ abstract class UnspentCoinsDetailsViewModelBase with Store { onTap: () { try { final url = Uri.parse(_explorerUrl(_type, unspentCoinsItem.hash)); - return launchUrl(url); + return launchUrl(url, mode: LaunchMode.externalApplication); } catch (e) {} }, ));