From 5e7c9ad65bd4d6b544e8a6ec5e7ba58282ba353c Mon Sep 17 00:00:00 2001 From: sneurlax Date: Wed, 20 Mar 2024 16:04:28 -0500 Subject: [PATCH] add FROST enabled pref a bool toggle from hidden settings menu --- .../global_settings_view/hidden_settings.dart | 32 ++++++++++++++++++- lib/utilities/prefs.dart | 22 +++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/lib/pages/settings_views/global_settings_view/hidden_settings.dart b/lib/pages/settings_views/global_settings_view/hidden_settings.dart index 6cc47a0d4..ec96afde5 100644 --- a/lib/pages/settings_views/global_settings_view/hidden_settings.dart +++ b/lib/pages/settings_views/global_settings_view/hidden_settings.dart @@ -10,6 +10,7 @@ import 'dart:async'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; @@ -215,7 +216,6 @@ class HiddenSettings extends StatelessWidget { ), ); }), - const SizedBox( height: 12, ), @@ -252,6 +252,36 @@ class HiddenSettings extends StatelessWidget { } }, ), + Consumer( + builder: (_, ref, __) { + return GestureDetector( + onTap: () async { + ref + .read(prefsChangeNotifierProvider) + .frostEnabled = + !(ref + .read(prefsChangeNotifierProvider) + .frostEnabled); + if (kDebugMode) { + print( + "FROST enabled: ${ref.read(prefsChangeNotifierProvider).frostEnabled}"); + } + }, + child: RoundedWhiteContainer( + child: Text( + "Toggle FROST multisig", + style: STextStyles.button(context).copyWith( + color: Theme.of(context) + .extension()! + .accentColorDark), + ), + ), + ); + }, + ), + const SizedBox( + height: 12, + ), Consumer( builder: (_, ref, __) { return GestureDetector( diff --git a/lib/utilities/prefs.dart b/lib/utilities/prefs.dart index 07726bdf1..8fbbbf069 100644 --- a/lib/utilities/prefs.dart +++ b/lib/utilities/prefs.dart @@ -68,6 +68,7 @@ class Prefs extends ChangeNotifier { await _setMaxDecimals(); _useTor = await _getUseTor(); _fusionServerInfo = await _getFusionServerInfo(); + _frostEnabled = await _getFrostEnabled(); _initialized = true; } @@ -1008,4 +1009,25 @@ class Prefs extends ChangeNotifier { return actualMap; } + + // FROST multisig + + bool _frostEnabled = false; + + bool get frostEnabled => _frostEnabled; + + set frostEnabled(bool frostEnabled) { + if (_frostEnabled != frostEnabled) { + DB.instance.put( + boxName: DB.boxNamePrefs, key: "frostEnabled", value: frostEnabled); + _frostEnabled = frostEnabled; + notifyListeners(); + } + } + + Future _getFrostEnabled() async { + return await DB.instance.get( + boxName: DB.boxNamePrefs, key: "frostEnabled") as bool? ?? + false; + } }