This commit is contained in:
fosse 2023-12-19 19:46:57 -05:00
parent 26dbea91d0
commit 78ed679864
3 changed files with 41 additions and 13 deletions

View file

@ -220,6 +220,7 @@ class BackupService {
final currentLanguageCode = data[PreferencesKey.currentLanguageCode] as String?;
final displayActionListMode = data[PreferencesKey.displayActionListModeKey] as int?;
final fiatApiMode = data[PreferencesKey.currentFiatApiModeKey] as int?;
final shouldStartTorOnLaunch = data[PreferencesKey.shouldStartTorOnLaunch] as bool?;
final currentPinLength = data[PreferencesKey.currentPinLength] as int?;
final currentTheme = data[PreferencesKey.currentTheme] as int?;
final exchangeStatus = data[PreferencesKey.exchangeStatusKey] as int?;
@ -315,6 +316,11 @@ class BackupService {
if (fiatApiMode != null)
await _sharedPreferences.setInt(PreferencesKey.currentFiatApiModeKey, fiatApiMode);
if (shouldStartTorOnLaunch != null)
await _sharedPreferences.setBool(
PreferencesKey.shouldStartTorOnLaunch, shouldStartTorOnLaunch);
if (autoGenerateSubaddressStatus != null)
await _sharedPreferences.setInt(
PreferencesKey.autoGenerateSubaddressStatusKey, autoGenerateSubaddressStatus);
@ -550,6 +556,8 @@ class BackupService {
_sharedPreferences.getInt(PreferencesKey.moneroTransactionPriority),
PreferencesKey.currentFiatApiModeKey:
_sharedPreferences.getInt(PreferencesKey.currentFiatApiModeKey),
PreferencesKey.shouldStartTorOnLaunch:
_sharedPreferences.getBool(PreferencesKey.shouldStartTorOnLaunch),
PreferencesKey.selectedCake2FAPreset:
_sharedPreferences.getInt(PreferencesKey.selectedCake2FAPreset),
PreferencesKey.shouldRequireTOTP2FAForAccessingWallet:

View file

@ -37,7 +37,7 @@ class _TorPageBodyState extends State<TorPageBody> {
Future<void> startTor() async {
setState(() {
connecting = true; // Update flag
connecting = true;
});
await Tor.init();
@ -47,7 +47,7 @@ class _TorPageBodyState extends State<TorPageBody> {
// Toggle started flag.
setState(() {
torEnabled = Tor.instance.enabled; // Update flag
torEnabled = Tor.instance.enabled;
connecting = false;
});
@ -160,6 +160,13 @@ class ConnectScreen extends StatelessWidget {
),
),
),
Text("Auto start Tor on app launch"),
Checkbox(
onChanged: (bool? value) {
print('value: $value');
},
value: null,
),
],
),
);

View file

@ -55,6 +55,7 @@ abstract class SettingsStoreBase with Store {
required bool initialDisableSell,
required BuyProviderType initialDefaultBuyProvider,
required FiatApiMode initialFiatMode,
required bool initialShouldStartTorOnLaunch,
required bool initialAllowBiometricalAuthentication,
required String initialTotpSecretKey,
required bool initialUseTOTP2FA,
@ -114,6 +115,7 @@ abstract class SettingsStoreBase with Store {
autoGenerateSubaddressStatus = initialAutoGenerateSubaddressStatus,
moneroSeedType = initialMoneroSeedType,
fiatApiMode = initialFiatMode,
shouldStartTorOnLaunch = initialShouldStartTorOnLaunch,
allowBiometricalAuthentication = initialAllowBiometricalAuthentication,
selectedCake2FAPreset = initialCake2FAPresetOptions,
totpSecretKey = initialTotpSecretKey,
@ -179,7 +181,9 @@ abstract class SettingsStoreBase with Store {
WalletType.values.forEach((walletType) {
final key = 'defaultBuyProvider_${walletType.toString()}';
final providerIndex = sharedPreferences.getInt(key);
defaultBuyProviders[walletType] = providerIndex != null ? BuyProviderType.values[providerIndex] : BuyProviderType.AskEachTime;
defaultBuyProviders[walletType] = providerIndex != null
? BuyProviderType.values[providerIndex]
: BuyProviderType.AskEachTime;
});
reaction(
@ -247,15 +251,13 @@ abstract class SettingsStoreBase with Store {
(bool disableSell) =>
sharedPreferences.setBool(PreferencesKey.disableSellKey, disableSell));
reaction(
(_) => defaultBuyProviders.asObservable(),
(ObservableMap<WalletType, BuyProviderType> providers) {
providers.forEach((walletType, provider) {
final key = 'defaultBuyProvider_${walletType.toString()}';
sharedPreferences.setInt(key, provider.index);
});
}
);
reaction((_) => defaultBuyProviders.asObservable(),
(ObservableMap<WalletType, BuyProviderType> providers) {
providers.forEach((walletType, provider) {
final key = 'defaultBuyProvider_${walletType.toString()}';
sharedPreferences.setInt(key, provider.index);
});
});
reaction(
(_) => autoGenerateSubaddressStatus,
@ -272,6 +274,11 @@ abstract class SettingsStoreBase with Store {
(FiatApiMode mode) =>
sharedPreferences.setInt(PreferencesKey.currentFiatApiModeKey, mode.serialize()));
reaction(
(_) => shouldStartTorOnLaunch,
(bool value) =>
sharedPreferences.setBool(PreferencesKey.shouldStartTorOnLaunch, value));
reaction((_) => currentTheme,
(ThemeBase theme) => sharedPreferences.setInt(PreferencesKey.currentTheme, theme.raw));
@ -486,6 +493,9 @@ abstract class SettingsStoreBase with Store {
@observable
FiatApiMode fiatApiMode;
@observable
bool shouldStartTorOnLaunch;
@observable
bool shouldSaveRecipientAddress;
@ -574,7 +584,8 @@ abstract class SettingsStoreBase with Store {
ObservableMap<String, bool> trocadorProviderStates = ObservableMap<String, bool>();
@observable
ObservableMap<WalletType, BuyProviderType> defaultBuyProviders = ObservableMap<WalletType, BuyProviderType>();
ObservableMap<WalletType, BuyProviderType> defaultBuyProviders =
ObservableMap<WalletType, BuyProviderType>();
@observable
SortBalanceBy sortBalanceBy;
@ -722,6 +733,7 @@ abstract class SettingsStoreBase with Store {
final currentFiatApiMode = FiatApiMode.deserialize(
raw: sharedPreferences.getInt(PreferencesKey.currentFiatApiModeKey) ??
FiatApiMode.enabled.raw);
final shouldStartTorOnLaunch = sharedPreferences.getBool(PreferencesKey.shouldStartTorOnLaunch) ?? false;
final allowBiometricalAuthentication =
sharedPreferences.getBool(PreferencesKey.allowBiometricalAuthenticationKey) ?? false;
final selectedCake2FAPreset = Cake2FAPresetsOptions.deserialize(
@ -899,6 +911,7 @@ abstract class SettingsStoreBase with Store {
initialDisableSell: disableSell,
initialDefaultBuyProvider: defaultBuyProvider,
initialFiatMode: currentFiatApiMode,
initialShouldStartTorOnLaunch: shouldStartTorOnLaunch,
initialAllowBiometricalAuthentication: allowBiometricalAuthentication,
initialCake2FAPresetOptions: selectedCake2FAPreset,
initialUseTOTP2FA: useTOTP2FA,