From 53e401edb84bf89effa2cc60e3ef1a5b4913a1c8 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Wed, 17 Apr 2024 20:41:45 -0500 Subject: [PATCH] mobile Tor warning --- .../sub_widgets/wallet_list_item.dart | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/pages/wallets_view/sub_widgets/wallet_list_item.dart b/lib/pages/wallets_view/sub_widgets/wallet_list_item.dart index 194b8df10..2099b05e9 100644 --- a/lib/pages/wallets_view/sub_widgets/wallet_list_item.dart +++ b/lib/pages/wallets_view/sub_widgets/wallet_list_item.dart @@ -17,6 +17,7 @@ import 'package:flutter_svg/svg.dart'; import 'package:stackwallet/pages/wallet_view/wallet_view.dart'; import 'package:stackwallet/pages/wallets_view/wallets_overview.dart'; import 'package:stackwallet/providers/providers.dart'; +import 'package:stackwallet/supported_coins.dart'; import 'package:stackwallet/themes/coin_icon_provider.dart'; import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/utilities/amount/amount.dart'; @@ -26,6 +27,7 @@ import 'package:stackwallet/utilities/show_loading.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/cw_based_interface.dart'; +import 'package:stackwallet/widgets/dialogs/tor_warning_dialog.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart'; class WalletListItem extends ConsumerWidget { @@ -58,6 +60,25 @@ class WalletListItem extends ConsumerWidget { BorderRadius.circular(Constants.size.circularBorderRadius), ), onPressed: () async { + // Check if Tor is enabled... + if (ref.read(prefsChangeNotifierProvider).useTor) { + // ... and if the coin supports Tor. + final cryptocurrency = SupportedCoins.coins[coin]; + if (cryptocurrency != null && !cryptocurrency!.torSupport) { + // If not, show a Tor warning dialog. + final shouldContinue = await showDialog( + context: context, + builder: (_) => TorWarningDialog( + coin: coin, + ), + ) ?? + false; + if (!shouldContinue) { + return; + } + } + } + if (walletCount == 1 && coin != Coin.ethereum) { final wallet = ref .read(pWallets)