toggle useTor pref on text button click in wallet network settings view

and formatting
This commit is contained in:
sneurlax 2023-09-08 16:43:24 -05:00
parent 832bfc08f7
commit 95790faf52
3 changed files with 9 additions and 3 deletions

View file

@ -35,6 +35,7 @@ import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/prefs.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/animated_text.dart';
@ -101,6 +102,9 @@ class _WalletNetworkSettingsViewState
late final StreamSubscription<TorConnectionStatusChangedEvent>
_torConnectionStatusSubscription;
/// The Prefs instance.
final Prefs _prefs = Prefs.instance;
Future<void> _attemptRescan() async {
if (!Platform.isLinux) await Wakelock.enable();
@ -784,6 +788,8 @@ class _WalletNetworkSettingsViewState
GestureDetector(
onTap: () {
TorService.sharedInstance.stop();
// And toggle preference.
_prefs.useTor = false;
},
child: Text(
"Disconnect",
@ -794,6 +800,8 @@ class _WalletNetworkSettingsViewState
GestureDetector(
onTap: () {
TorService.sharedInstance.start();
// And toggle preference.
_prefs.useTor = true;
},
child: Text(
"Connect",

View file

@ -21,6 +21,7 @@ import 'package:stackwallet/services/event_bus/global_event_bus.dart';
import 'package:stackwallet/services/tor_service.dart';
import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/prefs.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/custom_buttons/draggable_switch_button.dart';
@ -29,8 +30,6 @@ import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
import 'package:stackwallet/widgets/rounded_white_container.dart';
import '../../../../utilities/prefs.dart';
class TorSettings extends ConsumerStatefulWidget {
const TorSettings({Key? key}) : super(key: key);

View file

@ -129,7 +129,6 @@ class _DesktopTorStatusButtonState extends ConsumerState<DesktopTorStatusButton>
// Clean up the subscription to the TorConnectionStatusChangedEvent.
_torConnectionStatusSubscription.cancel();
controller?.dispose();
animationController.dispose();
super.dispose();