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

* Add Disable Exchange option to settings
This commit is contained in:
Omar Hatem 2022-11-22 04:18:18 +02:00 committed by GitHub
parent bcf09b048c
commit 9b32c9c956
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 50 additions and 20 deletions

View file

@ -11,6 +11,7 @@ class PreferencesKey {
static const shouldSaveRecipientAddressKey = 'save_recipient_address'; static const shouldSaveRecipientAddressKey = 'save_recipient_address';
static const allowBiometricalAuthenticationKey = static const allowBiometricalAuthenticationKey =
'allow_biometrical_authentication'; 'allow_biometrical_authentication';
static const disableExchangeKey = 'disable_exchange';
static const currentTheme = 'current_theme'; static const currentTheme = 'current_theme';
static const isDarkThemeLegacy = 'dark_theme'; static const isDarkThemeLegacy = 'dark_theme';
static const displayActionListModeKey = 'display_list_mode'; static const displayActionListModeKey = 'display_list_mode';

View file

@ -315,6 +315,8 @@ class DashboardPage extends BasePage {
} }
Future<void> _onClickExchangeButton(BuildContext context) async { Future<void> _onClickExchangeButton(BuildContext context) async {
if (walletViewModel.isEnabledExchangeAction) {
await Navigator.of(context).pushNamed(Routes.exchange); await Navigator.of(context).pushNamed(Routes.exchange);
} }
}
} }

View file

@ -30,6 +30,7 @@ abstract class SettingsStoreBase with Store {
required BalanceDisplayMode initialBalanceDisplayMode, required BalanceDisplayMode initialBalanceDisplayMode,
required bool initialSaveRecipientAddress, required bool initialSaveRecipientAddress,
required bool initialAllowBiometricalAuthentication, required bool initialAllowBiometricalAuthentication,
required bool initialExchangeEnabled,
required ThemeBase initialTheme, required ThemeBase initialTheme,
required int initialPinLength, required int initialPinLength,
required String initialLanguageCode, required String initialLanguageCode,
@ -47,6 +48,7 @@ abstract class SettingsStoreBase with Store {
balanceDisplayMode = initialBalanceDisplayMode, balanceDisplayMode = initialBalanceDisplayMode,
shouldSaveRecipientAddress = initialSaveRecipientAddress, shouldSaveRecipientAddress = initialSaveRecipientAddress,
allowBiometricalAuthentication = initialAllowBiometricalAuthentication, allowBiometricalAuthentication = initialAllowBiometricalAuthentication,
disableExchange = initialExchangeEnabled,
currentTheme = initialTheme, currentTheme = initialTheme,
pinCodeLength = initialPinLength, pinCodeLength = initialPinLength,
languageCode = initialLanguageCode, languageCode = initialLanguageCode,
@ -143,6 +145,9 @@ abstract class SettingsStoreBase with Store {
@observable @observable
bool allowBiometricalAuthentication; bool allowBiometricalAuthentication;
@observable
bool disableExchange;
@observable @observable
ThemeBase currentTheme; ThemeBase currentTheme;
@ -221,6 +226,8 @@ abstract class SettingsStoreBase with Store {
final allowBiometricalAuthentication = sharedPreferences final allowBiometricalAuthentication = sharedPreferences
.getBool(PreferencesKey.allowBiometricalAuthenticationKey) ?? .getBool(PreferencesKey.allowBiometricalAuthenticationKey) ??
false; false;
final disableExchange = sharedPreferences
.getBool(PreferencesKey.disableExchangeKey) ?? false;
final legacyTheme = final legacyTheme =
(sharedPreferences.getBool(PreferencesKey.isDarkThemeLegacy) ?? false) (sharedPreferences.getBool(PreferencesKey.isDarkThemeLegacy) ?? false)
? ThemeType.dark.index ? ThemeType.dark.index
@ -284,6 +291,7 @@ abstract class SettingsStoreBase with Store {
initialBalanceDisplayMode: currentBalanceDisplayMode, initialBalanceDisplayMode: currentBalanceDisplayMode,
initialSaveRecipientAddress: shouldSaveRecipientAddress, initialSaveRecipientAddress: shouldSaveRecipientAddress,
initialAllowBiometricalAuthentication: allowBiometricalAuthentication, initialAllowBiometricalAuthentication: allowBiometricalAuthentication,
initialExchangeEnabled: disableExchange,
initialTheme: savedTheme, initialTheme: savedTheme,
actionlistDisplayMode: actionListDisplayMode, actionlistDisplayMode: actionListDisplayMode,
initialPinLength: pinLength, initialPinLength: pinLength,

View file

@ -53,7 +53,6 @@ abstract class DashboardViewModelBase with Store {
hasBuyAction = false, hasBuyAction = false,
isEnabledBuyAction = false, isEnabledBuyAction = false,
hasExchangeAction = false, hasExchangeAction = false,
isEnabledExchangeAction = false,
isShowFirstYatIntroduction = false, isShowFirstYatIntroduction = false,
isShowSecondYatIntroduction = false, isShowSecondYatIntroduction = false,
isShowThirdYatIntroduction = false, isShowThirdYatIntroduction = false,
@ -249,8 +248,8 @@ abstract class DashboardViewModelBase with Store {
void furtherShowYatPopup(bool shouldShow) => void furtherShowYatPopup(bool shouldShow) =>
settingsStore.shouldShowYatPopup = shouldShow; settingsStore.shouldShowYatPopup = shouldShow;
@observable @computed
bool isEnabledExchangeAction; bool get isEnabledExchangeAction => !settingsStore.disableExchange;
@observable @observable
bool hasExchangeAction; bool hasExchangeAction;
@ -365,7 +364,6 @@ abstract class DashboardViewModelBase with Store {
} }
void updateActions() { void updateActions() {
isEnabledExchangeAction = true;
hasExchangeAction = !isHaven; hasExchangeAction = !isHaven;
isEnabledBuyAction = wallet.type != WalletType.haven isEnabledBuyAction = wallet.type != WalletType.haven
&& wallet.type != WalletType.monero; && wallet.type != WalletType.monero;

View file

@ -208,6 +208,12 @@ abstract class SettingsViewModelBase with Store {
setAllowBiometricalAuthentication(value); setAllowBiometricalAuthentication(value);
} }
}), }),
SwitcherListItem(
title: S.current.disable_exchange,
value: () => _settingsStore.disableExchange,
onValueChange: (BuildContext context, bool value) {
_settingsStore.disableExchange = value;
}),
ChoicesListItem( ChoicesListItem(
title: S.current.color_theme, title: S.current.color_theme,
items: ThemeList.all, items: ThemeList.all,

View file

@ -651,5 +651,6 @@
"ignor": "Ignorieren", "ignor": "Ignorieren",
"use_suggested": "Vorgeschlagen verwenden", "use_suggested": "Vorgeschlagen verwenden",
"do_not_share_warning_text" : "Teilen Sie diese nicht mit anderen, einschließlich des Supports.\n\nSie werden Ihr Geld stehlen!", "do_not_share_warning_text" : "Teilen Sie diese nicht mit anderen, einschließlich des Supports.\n\nSie werden Ihr Geld stehlen!",
"help": "hilfe" "help": "hilfe",
"disable_exchange": "Exchange deaktivieren"
} }

View file

@ -651,5 +651,6 @@
"ignor": "Ignore", "ignor": "Ignore",
"use_suggested": "Use Suggested", "use_suggested": "Use Suggested",
"do_not_share_warning_text" : "Do not share these with anyone else, including support.\n\nThey will steal your money!", "do_not_share_warning_text" : "Do not share these with anyone else, including support.\n\nThey will steal your money!",
"help": "help" "help": "help",
"disable_exchange": "Disable exchange"
} }

View file

@ -651,5 +651,6 @@
"ignor": "Pasar por alto", "ignor": "Pasar por alto",
"use_suggested": "Usar sugerido", "use_suggested": "Usar sugerido",
"do_not_share_warning_text" : "No comparta estos con nadie más, incluido el soporte.\n\n¡Te robarán tu dinero!", "do_not_share_warning_text" : "No comparta estos con nadie más, incluido el soporte.\n\n¡Te robarán tu dinero!",
"help": "ayuda" "help": "ayuda",
"disable_exchange": "Deshabilitar intercambio"
} }

View file

@ -649,5 +649,6 @@
"ignor": "Ignorer", "ignor": "Ignorer",
"use_suggested": "Utilisation suggérée", "use_suggested": "Utilisation suggérée",
"do_not_share_warning_text" : "Ne les partagez avec personne d'autre, y compris avec l'assistance.\n\nIls vont voler votre argent!", "do_not_share_warning_text" : "Ne les partagez avec personne d'autre, y compris avec l'assistance.\n\nIls vont voler votre argent!",
"help": "aider" "help": "aider",
"disable_exchange": "Désactiver l'échange"
} }

View file

@ -651,5 +651,6 @@
"ignor": "नज़रअंदाज़ करना", "ignor": "नज़रअंदाज़ करना",
"use_suggested": "सुझाए गए का प्रयोग करें", "use_suggested": "सुझाए गए का प्रयोग करें",
"do_not_share_warning_text" : "इन्हें समर्थन सहित किसी और के साथ साझा न करें।\n\nवे आपका पैसा चुरा लेंगे!", "do_not_share_warning_text" : "इन्हें समर्थन सहित किसी और के साथ साझा न करें।\n\nवे आपका पैसा चुरा लेंगे!",
"help": "मदद करना" "help": "मदद करना",
"disable_exchange": "एक्सचेंज अक्षम करें"
} }

View file

@ -651,5 +651,6 @@
"ignor": "Zanemariti", "ignor": "Zanemariti",
"use_suggested": "Koristite predloženo", "use_suggested": "Koristite predloženo",
"do_not_share_warning_text" : "Nemojte ih dijeliti ni s kim, uključujući podršku.\n\nUkrast će vam novac!", "do_not_share_warning_text" : "Nemojte ih dijeliti ni s kim, uključujući podršku.\n\nUkrast će vam novac!",
"help": "pomozite" "help": "pomozite",
"disable_exchange": "Onemogući exchange"
} }

View file

@ -651,5 +651,6 @@
"ignor": "Ignorare", "ignor": "Ignorare",
"use_suggested": "Usa suggerito", "use_suggested": "Usa suggerito",
"do_not_share_warning_text" : "Non condividerli con nessun altro, incluso il supporto.\n\nTi ruberanno i soldi!", "do_not_share_warning_text" : "Non condividerli con nessun altro, incluso il supporto.\n\nTi ruberanno i soldi!",
"help": "aiuto" "help": "aiuto",
"disable_exchange": "Disabilita scambio"
} }

View file

@ -651,5 +651,6 @@
"ignor": "無視", "ignor": "無視",
"use_suggested": "推奨を使用", "use_suggested": "推奨を使用",
"do_not_share_warning_text" : "サポートを含め、これらを他の誰とも共有しないでください。\n\n彼らはあなたのお金を盗みます", "do_not_share_warning_text" : "サポートを含め、これらを他の誰とも共有しないでください。\n\n彼らはあなたのお金を盗みます",
"help": "ヘルプ" "help": "ヘルプ",
"disable_exchange": "交換を無効にする"
} }

View file

@ -651,5 +651,6 @@
"ignor": "무시하다", "ignor": "무시하다",
"use_suggested": "추천 사용", "use_suggested": "추천 사용",
"do_not_share_warning_text" : "지원을 포함하여 다른 사람과 이러한 정보를 공유하지 마십시오.\n\n그들은 당신의 돈을 훔칠 것입니다!", "do_not_share_warning_text" : "지원을 포함하여 다른 사람과 이러한 정보를 공유하지 마십시오.\n\n그들은 당신의 돈을 훔칠 것입니다!",
"help": "돕다" "help": "돕다",
"disable_exchange": "교환 비활성화"
} }

View file

@ -651,5 +651,6 @@
"ignor": "Negeren", "ignor": "Negeren",
"use_suggested": "Gebruik aanbevolen", "use_suggested": "Gebruik aanbevolen",
"do_not_share_warning_text" : "Deel deze met niemand anders, ook niet met support.\n\nZe zullen je geld stelen!", "do_not_share_warning_text" : "Deel deze met niemand anders, ook niet met support.\n\nZe zullen je geld stelen!",
"help": "helpen" "help": "helpen",
"disable_exchange": "Uitwisseling uitschakelen"
} }

View file

@ -651,5 +651,6 @@
"ignor": "Ignorować", "ignor": "Ignorować",
"use_suggested": "Użyj sugerowane", "use_suggested": "Użyj sugerowane",
"do_not_share_warning_text" : "Nie udostępniaj ich nikomu innemu, w tym wsparcia.\n\nUkradną twoje pieniądze!", "do_not_share_warning_text" : "Nie udostępniaj ich nikomu innemu, w tym wsparcia.\n\nUkradną twoje pieniądze!",
"help": "pomoc" "help": "pomoc",
"disable_exchange": "Wyłącz wymianę"
} }

View file

@ -651,5 +651,6 @@
"ignor": "Ignorar", "ignor": "Ignorar",
"use_suggested": "Uso sugerido", "use_suggested": "Uso sugerido",
"do_not_share_warning_text" : "Não os compartilhe com mais ninguém, incluindo suporte.\n\nEles vão roubar seu dinheiro!", "do_not_share_warning_text" : "Não os compartilhe com mais ninguém, incluindo suporte.\n\nEles vão roubar seu dinheiro!",
"help": "ajuda" "help": "ajuda",
"disable_exchange": "Desativar troca"
} }

View file

@ -651,5 +651,6 @@
"ignor": "Игнорировать", "ignor": "Игнорировать",
"use_suggested": "Использовать предложенный", "use_suggested": "Использовать предложенный",
"do_not_share_warning_text" : "Не делитесь ими с кем-либо еще, в том числе со службой поддержки.\n\nОни украдут ваши деньги!", "do_not_share_warning_text" : "Не делитесь ими с кем-либо еще, в том числе со службой поддержки.\n\nОни украдут ваши деньги!",
"help": "помощь" "help": "помощь",
"disable_exchange": "Отключить обмен"
} }

View file

@ -650,5 +650,6 @@
"ignor": "Ігнорувати", "ignor": "Ігнорувати",
"use_suggested": "Використати запропоноване", "use_suggested": "Використати запропоноване",
"do_not_share_warning_text" : "Не повідомляйте їх нікому, включно зі службою підтримки.\n\nВони вкрадуть ваші гроші!", "do_not_share_warning_text" : "Не повідомляйте їх нікому, включно зі службою підтримки.\n\nВони вкрадуть ваші гроші!",
"help": "допомога" "help": "допомога",
"disable_exchange": "Вимкнути exchange"
} }

View file

@ -649,5 +649,6 @@
"ignor": "忽视", "ignor": "忽视",
"use_suggested": "使用建议", "use_suggested": "使用建议",
"do_not_share_warning_text" : "不要與其他任何人分享這些內容,包括支持。\n\n他們會偷你的錢", "do_not_share_warning_text" : "不要與其他任何人分享這些內容,包括支持。\n\n他們會偷你的錢",
"help": "帮助" "help": "帮助",
"disable_exchange": "禁用交换"
} }