CW-227 Add Disable Exchange option to settings (#642)

* Add Disable Exchange option to settings

Omar Hatem committed Nov 22, 2022 at 04:18 UTC 9b32c9c95666093841621b4753b0de40e8a19f37
20 files changed +50 -20
lib/entities/preferences_key.dart
+1
@@ -11,6 +11,7 @@ class PreferencesKey {
11 static const shouldSaveRecipientAddressKey = 'save_recipient_address';
12 static const allowBiometricalAuthenticationKey =
13 'allow_biometrical_authentication';
14 + static const disableExchangeKey = 'disable_exchange';
15 static const currentTheme = 'current_theme';
16 static const isDarkThemeLegacy = 'dark_theme';
17 static const displayActionListModeKey = 'display_list_mode';
lib/src/screens/dashboard/dashboard_page.dart
+3 -1
@@ -315,6 +315,8 @@ class DashboardPage extends BasePage {
315 }
316
317 Future<void> _onClickExchangeButton(BuildContext context) async {
318 - await Navigator.of(context).pushNamed(Routes.exchange);
318 + if (walletViewModel.isEnabledExchangeAction) {
319 + await Navigator.of(context).pushNamed(Routes.exchange);
320 + }
321 }
322 }
lib/store/settings_store.dart
+8
@@ -30,6 +30,7 @@ abstract class SettingsStoreBase with Store {
30 required BalanceDisplayMode initialBalanceDisplayMode,
31 required bool initialSaveRecipientAddress,
32 required bool initialAllowBiometricalAuthentication,
33 + required bool initialExchangeEnabled,
34 required ThemeBase initialTheme,
35 required int initialPinLength,
36 required String initialLanguageCode,
@@ -47,6 +48,7 @@ abstract class SettingsStoreBase with Store {
48 balanceDisplayMode = initialBalanceDisplayMode,
49 shouldSaveRecipientAddress = initialSaveRecipientAddress,
50 allowBiometricalAuthentication = initialAllowBiometricalAuthentication,
51 + disableExchange = initialExchangeEnabled,
52 currentTheme = initialTheme,
53 pinCodeLength = initialPinLength,
54 languageCode = initialLanguageCode,
@@ -143,6 +145,9 @@ abstract class SettingsStoreBase with Store {
145 @observable
146 bool allowBiometricalAuthentication;
147
148 + @observable
149 + bool disableExchange;
150 +
151 @observable
152 ThemeBase currentTheme;
153
@@ -221,6 +226,8 @@ abstract class SettingsStoreBase with Store {
226 final allowBiometricalAuthentication = sharedPreferences
227 .getBool(PreferencesKey.allowBiometricalAuthenticationKey) ??
228 false;
229 + final disableExchange = sharedPreferences
230 + .getBool(PreferencesKey.disableExchangeKey) ?? false;
231 final legacyTheme =
232 (sharedPreferences.getBool(PreferencesKey.isDarkThemeLegacy) ?? false)
233 ? ThemeType.dark.index
@@ -284,6 +291,7 @@ abstract class SettingsStoreBase with Store {
291 initialBalanceDisplayMode: currentBalanceDisplayMode,
292 initialSaveRecipientAddress: shouldSaveRecipientAddress,
293 initialAllowBiometricalAuthentication: allowBiometricalAuthentication,
294 + initialExchangeEnabled: disableExchange,
295 initialTheme: savedTheme,
296 actionlistDisplayMode: actionListDisplayMode,
297 initialPinLength: pinLength,
lib/view_model/dashboard/dashboard_view_model.dart
+2 -4
@@ -53,7 +53,6 @@ abstract class DashboardViewModelBase with Store {
53 hasBuyAction = false,
54 isEnabledBuyAction = false,
55 hasExchangeAction = false,
56 - isEnabledExchangeAction = false,
56 isShowFirstYatIntroduction = false,
57 isShowSecondYatIntroduction = false,
58 isShowThirdYatIntroduction = false,
@@ -249,8 +248,8 @@ abstract class DashboardViewModelBase with Store {
248 void furtherShowYatPopup(bool shouldShow) =>
249 settingsStore.shouldShowYatPopup = shouldShow;
250
252 - @observable
253 - bool isEnabledExchangeAction;
251 + @computed
252 + bool get isEnabledExchangeAction => !settingsStore.disableExchange;
253
254 @observable
255 bool hasExchangeAction;
@@ -365,7 +364,6 @@ abstract class DashboardViewModelBase with Store {
364 }
365
366 void updateActions() {
368 - isEnabledExchangeAction = true;
367 hasExchangeAction = !isHaven;
368 isEnabledBuyAction = wallet.type != WalletType.haven
369 && wallet.type != WalletType.monero;
lib/view_model/settings/settings_view_model.dart
+6
@@ -208,6 +208,12 @@ abstract class SettingsViewModelBase with Store {
208 setAllowBiometricalAuthentication(value);
209 }
210 }),
211 + SwitcherListItem(
212 + title: S.current.disable_exchange,
213 + value: () => _settingsStore.disableExchange,
214 + onValueChange: (BuildContext context, bool value) {
215 + _settingsStore.disableExchange = value;
216 + }),
217 ChoicesListItem(
218 title: S.current.color_theme,
219 items: ThemeList.all,
res/values/strings_de.arb
+2 -1
@@ -651,5 +651,6 @@
651 "ignor": "Ignorieren",
652 "use_suggested": "Vorgeschlagen verwenden",
653 "do_not_share_warning_text" : "Teilen Sie diese nicht mit anderen, einschließlich des Supports.\n\nSie werden Ihr Geld stehlen!",
654 - "help": "hilfe"
654 + "help": "hilfe",
655 + "disable_exchange": "Exchange deaktivieren"
656 }
res/values/strings_en.arb
+2 -1
@@ -651,5 +651,6 @@
651 "ignor": "Ignore",
652 "use_suggested": "Use Suggested",
653 "do_not_share_warning_text" : "Do not share these with anyone else, including support.\n\nThey will steal your money!",
654 - "help": "help"
654 + "help": "help",
655 + "disable_exchange": "Disable exchange"
656 }
res/values/strings_es.arb
+2 -1
@@ -651,5 +651,6 @@
651 "ignor": "Pasar por alto",
652 "use_suggested": "Usar sugerido",
653 "do_not_share_warning_text" : "No comparta estos con nadie más, incluido el soporte.\n\n¡Te robarán tu dinero!",
654 - "help": "ayuda"
654 + "help": "ayuda",
655 + "disable_exchange": "Deshabilitar intercambio"
656 }
res/values/strings_fr.arb
+2 -1
@@ -649,5 +649,6 @@
649 "ignor": "Ignorer",
650 "use_suggested": "Utilisation suggérée",
651 "do_not_share_warning_text" : "Ne les partagez avec personne d'autre, y compris avec l'assistance.\n\nIls vont voler votre argent!",
652 - "help": "aider"
652 + "help": "aider",
653 + "disable_exchange": "Désactiver l'échange"
654 }
res/values/strings_hi.arb
+2 -1
@@ -651,5 +651,6 @@
651 "ignor": "नज़रअंदाज़ करना",
652 "use_suggested": "सुझाए गए का प्रयोग करें",
653 "do_not_share_warning_text" : "इन्हें समर्थन सहित किसी और के साथ साझा न करें।\n\nवे आपका पैसा चुरा लेंगे!",
654 - "help": "मदद करना"
654 + "help": "मदद करना",
655 + "disable_exchange": "एक्सचेंज अक्षम करें"
656 }
res/values/strings_hr.arb
+2 -1
@@ -651,5 +651,6 @@
651 "ignor": "Zanemariti",
652 "use_suggested": "Koristite predloženo",
653 "do_not_share_warning_text" : "Nemojte ih dijeliti ni s kim, uključujući podršku.\n\nUkrast će vam novac!",
654 - "help": "pomozite"
654 + "help": "pomozite",
655 + "disable_exchange": "Onemogući exchange"
656 }
res/values/strings_it.arb
+2 -1
@@ -651,5 +651,6 @@
651 "ignor": "Ignorare",
652 "use_suggested": "Usa suggerito",
653 "do_not_share_warning_text" : "Non condividerli con nessun altro, incluso il supporto.\n\nTi ruberanno i soldi!",
654 - "help": "aiuto"
654 + "help": "aiuto",
655 + "disable_exchange": "Disabilita scambio"
656 }
res/values/strings_ja.arb
+2 -1
@@ -651,5 +651,6 @@
651 "ignor": "無視",
652 "use_suggested": "推奨を使用",
653 "do_not_share_warning_text" : "サポートを含め、これらを他の誰とも共有しないでください。\n\n彼らはあなたのお金を盗みます!",
654 - "help": "ヘルプ"
654 + "help": "ヘルプ",
655 + "disable_exchange": "交換を無効にする"
656 }
res/values/strings_ko.arb
+2 -1
@@ -651,5 +651,6 @@
651 "ignor": "무시하다",
652 "use_suggested": "추천 사용",
653 "do_not_share_warning_text" : "지원을 포함하여 다른 사람과 이러한 정보를 공유하지 마십시오.\n\n그들은 당신의 돈을 훔칠 것입니다!",
654 - "help": "돕다"
654 + "help": "돕다",
655 + "disable_exchange": "교환 비활성화"
656 }
res/values/strings_nl.arb
+2 -1
@@ -651,5 +651,6 @@
651 "ignor": "Negeren",
652 "use_suggested": "Gebruik aanbevolen",
653 "do_not_share_warning_text" : "Deel deze met niemand anders, ook niet met support.\n\nZe zullen je geld stelen!",
654 - "help": "helpen"
654 + "help": "helpen",
655 + "disable_exchange": "Uitwisseling uitschakelen"
656 }
res/values/strings_pl.arb
+2 -1
@@ -651,5 +651,6 @@
651 "ignor": "Ignorować",
652 "use_suggested": "Użyj sugerowane",
653 "do_not_share_warning_text" : "Nie udostępniaj ich nikomu innemu, w tym wsparcia.\n\nUkradną twoje pieniądze!",
654 - "help": "pomoc"
654 + "help": "pomoc",
655 + "disable_exchange": "Wyłącz wymianę"
656 }
res/values/strings_pt.arb
+2 -1
@@ -651,5 +651,6 @@
651 "ignor": "Ignorar",
652 "use_suggested": "Uso sugerido",
653 "do_not_share_warning_text" : "Não os compartilhe com mais ninguém, incluindo suporte.\n\nEles vão roubar seu dinheiro!",
654 - "help": "ajuda"
654 + "help": "ajuda",
655 + "disable_exchange": "Desativar troca"
656 }
res/values/strings_ru.arb
+2 -1
@@ -651,5 +651,6 @@
651 "ignor": "Игнорировать",
652 "use_suggested": "Использовать предложенный",
653 "do_not_share_warning_text" : "Не делитесь ими с кем-либо еще, в том числе со службой поддержки.\n\nОни украдут ваши деньги!",
654 - "help": "помощь"
654 + "help": "помощь",
655 + "disable_exchange": "Отключить обмен"
656 }
res/values/strings_uk.arb
+2 -1
@@ -650,5 +650,6 @@
650 "ignor": "Ігнорувати",
651 "use_suggested": "Використати запропоноване",
652 "do_not_share_warning_text" : "Не повідомляйте їх нікому, включно зі службою підтримки.\n\nВони вкрадуть ваші гроші!",
653 - "help": "допомога"
653 + "help": "допомога",
654 + "disable_exchange": "Вимкнути exchange"
655 }
res/values/strings_zh.arb
+2 -1
@@ -649,5 +649,6 @@
649 "ignor": "忽视",
650 "use_suggested": "使用建议",
651 "do_not_share_warning_text" : "不要與其他任何人分享這些內容,包括支持。\n\n他們會偷你的錢!",
652 - "help": "帮助"
652 + "help": "帮助",
653 + "disable_exchange": "禁用交换"
654 }