add FROST enabled pref

a bool
toggle from hidden settings menu
This commit is contained in:
sneurlax 2024-03-20 16:04:28 -05:00
parent 85cdb0cc09
commit 5e7c9ad65b
2 changed files with 53 additions and 1 deletions

View file

@ -10,6 +10,7 @@
import 'dart:async'; import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/flutter_svg.dart';
@ -215,7 +216,6 @@ class HiddenSettings extends StatelessWidget {
), ),
); );
}), }),
const SizedBox( const SizedBox(
height: 12, 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<StackColors>()!
.accentColorDark),
),
),
);
},
),
const SizedBox(
height: 12,
),
Consumer( Consumer(
builder: (_, ref, __) { builder: (_, ref, __) {
return GestureDetector( return GestureDetector(

View file

@ -68,6 +68,7 @@ class Prefs extends ChangeNotifier {
await _setMaxDecimals(); await _setMaxDecimals();
_useTor = await _getUseTor(); _useTor = await _getUseTor();
_fusionServerInfo = await _getFusionServerInfo(); _fusionServerInfo = await _getFusionServerInfo();
_frostEnabled = await _getFrostEnabled();
_initialized = true; _initialized = true;
} }
@ -1008,4 +1009,25 @@ class Prefs extends ChangeNotifier {
return actualMap; return actualMap;
} }
// FROST multisig
bool _frostEnabled = false;
bool get frostEnabled => _frostEnabled;
set frostEnabled(bool frostEnabled) {
if (_frostEnabled != frostEnabled) {
DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs, key: "frostEnabled", value: frostEnabled);
_frostEnabled = frostEnabled;
notifyListeners();
}
}
Future<bool> _getFrostEnabled() async {
return await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs, key: "frostEnabled") as bool? ??
false;
}
} }