diff --git a/lib/entities/main_actions.dart b/lib/entities/main_actions.dart index 4d8190a4a..3fd6aeaa9 100644 --- a/lib/entities/main_actions.dart +++ b/lib/entities/main_actions.dart @@ -1,6 +1,7 @@ import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/routes.dart'; import 'package:cake_wallet/src/widgets/alert_with_one_action.dart'; +import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart'; import 'package:cake_wallet/utils/show_pop_up.dart'; import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart'; import 'package:flutter/material.dart'; @@ -44,9 +45,13 @@ class MainActions { return; } - if (viewModel.isTorEnabled && viewModel.settingsStore.shouldShowTorBuyWarning) { + if (viewModel.isTorEnabled /*&& viewModel.settingsStore.shouldShowTorBuyWarning*/) { viewModel.settingsStore.shouldShowTorBuyWarning = false; - await _showErrorDialog(context, S.of(context).warning, S.of(context).tor_enabled_warning); + bool cont = await _showWarningDialog( + context, S.of(context).warning, S.of(context).tor_enabled_warning); + if (!cont) { + return; + } } final defaultBuyProvider = viewModel.defaultBuyProvider; @@ -105,9 +110,13 @@ class MainActions { return; } - if (viewModel.isTorEnabled && viewModel.settingsStore.shouldShowTorSellWarning) { + if (viewModel.isTorEnabled /*&& viewModel.settingsStore.shouldShowTorSellWarning*/) { viewModel.settingsStore.shouldShowTorSellWarning = false; - await _showErrorDialog(context, S.of(context).warning, S.of(context).tor_enabled_warning); + bool cont = await _showWarningDialog( + context, S.of(context).warning, S.of(context).tor_enabled_warning); + if (!cont) { + return; + } } final defaultSellProvider = viewModel.defaultSellProvider; @@ -135,4 +144,22 @@ class MainActions { }, ); } + + static Future _showWarningDialog( + BuildContext context, String title, String errorMessage) async { + bool? response = await showPopUp( + context: context, + builder: (BuildContext context) { + return AlertWithTwoActions( + alertTitle: title, + alertContent: errorMessage, + rightButtonText: S.of(context).ok, + actionRightButton: () => Navigator.of(context).pop(true), + leftButtonText: S.of(context).cancel, + actionLeftButton: () => Navigator.of(context).pop(false), + ); + }, + ); + return response ?? false; + } } diff --git a/lib/utils/proxy_wrapper.dart b/lib/utils/proxy_wrapper.dart index 0bd17916f..0160eceb5 100644 --- a/lib/utils/proxy_wrapper.dart +++ b/lib/utils/proxy_wrapper.dart @@ -96,7 +96,11 @@ class ProxyWrapper { torEnabled = false; } - if (torEnabled && torConnectionStatus == TorConnectionStatus.connecting) { + if (torEnabled) { + torConnectionMode = TorConnectionMode.torOnly; + } + + if (torEnabled && torConnectionStatus == TorConnectionStatus.connecting) { throw Exception("Tor is still connecting"); } @@ -168,7 +172,11 @@ class ProxyWrapper { torEnabled = false; } - if (torEnabled && torConnectionStatus == TorConnectionStatus.connecting) { + if (torEnabled) { + torConnectionMode = TorConnectionMode.torOnly; + } + + if (torEnabled && torConnectionStatus == TorConnectionStatus.connecting) { throw Exception("Tor is still connecting"); }