add tor pref

This commit is contained in:
julian 2023-08-07 11:06:44 -06:00
parent 5aea9d6a2a
commit 99dc1aef42
2 changed files with 29 additions and 3 deletions

View file

@ -168,9 +168,10 @@ void main() async {
await Hive.openBox<dynamic>(DB.boxNamePrefs); await Hive.openBox<dynamic>(DB.boxNamePrefs);
await Prefs.instance.init(); await Prefs.instance.init();
// TODO create tor pref in Prefs // TODO remove this!!!!
const useTor = true; // get from prefs Prefs.instance.useTor = true;
if (useTor) {
if (Prefs.instance.useTor) {
await TorService.sharedInstance.start(); await TorService.sharedInstance.start();
} }

View file

@ -60,6 +60,7 @@ class Prefs extends ChangeNotifier {
_systemBrightnessDarkThemeId = await _getSystemBrightnessDarkTheme(); _systemBrightnessDarkThemeId = await _getSystemBrightnessDarkTheme();
await _setAmountUnits(); await _setAmountUnits();
await _setMaxDecimals(); await _setMaxDecimals();
_useTor = await _getUseTor();
_initialized = true; _initialized = true;
} }
@ -869,4 +870,28 @@ class Prefs extends ChangeNotifier {
_amountDecimals[coin] = decimals; _amountDecimals[coin] = decimals;
} }
} }
// enabled tor
bool _useTor = false;
bool get useTor => _useTor;
set useTor(bool useTor) {
if (_useTor != useTor) {
DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs,
key: "useTor",
value: useTor,
);
_useTor = useTor;
notifyListeners();
}
}
Future<bool> _getUseTor() async {
return await DB.instance
.get<dynamic>(boxName: DB.boxNamePrefs, key: "useTor") as bool? ??
false;
}
} }