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

View file

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