From 1090f5caa20ddfe004e1adae3ffa5f4edc998f3c Mon Sep 17 00:00:00 2001 From: sneurlax Date: Tue, 16 Apr 2024 18:19:38 -0500 Subject: [PATCH] add warning dialog when clicking card of coin incompatible with Tor TODO fix spacing/style. --- lib/widgets/wallet_card.dart | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/lib/widgets/wallet_card.dart b/lib/widgets/wallet_card.dart index bc1c80aa4..31a29fb68 100644 --- a/lib/widgets/wallet_card.dart +++ b/lib/widgets/wallet_card.dart @@ -30,6 +30,7 @@ import 'package:stackwallet/wallets/wallet/wallet.dart'; import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/cw_based_interface.dart'; import 'package:stackwallet/widgets/conditional_parent.dart'; import 'package:stackwallet/widgets/desktop/primary_button.dart'; +import 'package:stackwallet/widgets/desktop/secondary_button.dart'; import 'package:stackwallet/widgets/dialogs/basic_dialog.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart'; import 'package:stackwallet/widgets/wallet_info_row/wallet_info_row.dart'; @@ -94,6 +95,37 @@ class SimpleWalletCard extends ConsumerWidget { final wallet = ref.read(pWallets).getWallet(walletId); + // If Tor enabled, show a warning if opening a wallet incompatible with Tor. + if (ref.read(prefsChangeNotifierProvider).useTor) { + if (!wallet.cryptoCurrency.torSupport) { + final shouldContinue = await showDialog( + context: context, + builder: (context) => BasicDialog( + title: "Warning! Tor not supported.", + message: "Stacky is not compatible with Tor." + "\n\nBy using it, you will leak your IP address. Are you sure you " + "want to continue?", + // A PrimaryButton widget: + leftButton: PrimaryButton( + label: "Cancel", + onPressed: () { + Navigator.of(context).pop(false); + }, + ), + rightButton: SecondaryButton( + label: "Continue", + onPressed: () { + Navigator.of(context).pop(true); + }, + ), + )) ?? + false; + if (!shouldContinue) { + return; + } + } + } + if (context.mounted) { final Future loadFuture; if (wallet is CwBasedInterface) {