mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 11:59:30 +00:00
add tor pref
This commit is contained in:
parent
5aea9d6a2a
commit
99dc1aef42
2 changed files with 29 additions and 3 deletions
|
@ -168,9 +168,10 @@ void main() async {
|
|||
await Hive.openBox<dynamic>(DB.boxNamePrefs);
|
||||
await Prefs.instance.init();
|
||||
|
||||
// TODO create tor pref in Prefs
|
||||
const useTor = true; // get from prefs
|
||||
if (useTor) {
|
||||
// TODO remove this!!!!
|
||||
Prefs.instance.useTor = true;
|
||||
|
||||
if (Prefs.instance.useTor) {
|
||||
await TorService.sharedInstance.start();
|
||||
}
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ class Prefs extends ChangeNotifier {
|
|||
_systemBrightnessDarkThemeId = await _getSystemBrightnessDarkTheme();
|
||||
await _setAmountUnits();
|
||||
await _setMaxDecimals();
|
||||
_useTor = await _getUseTor();
|
||||
|
||||
_initialized = true;
|
||||
}
|
||||
|
@ -869,4 +870,28 @@ class Prefs extends ChangeNotifier {
|
|||
_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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue