- Make getters to ease attribute access

- Add the old 'disable_fiat' translation
- rename getters to be more bool like names
This commit is contained in:
OmarHatem 2022-12-07 22:07:32 +02:00
parent 37ca795756
commit 55b37164dc
25 changed files with 51 additions and 56 deletions

View file

@ -20,8 +20,6 @@ import 'package:cake_wallet/exchange/trade.dart';
import 'package:encrypt/encrypt.dart' as encrypt;
import 'package:collection/collection.dart';
import 'fiat_api_mode.dart';
const newCakeWalletMoneroUri = 'xmr-node.cakewallet.com:18081';
const cakeWalletBitcoinElectrumUri = 'electrum.cakewallet.com:50002';
const cakeWalletLitecoinElectrumUri = 'ltc-electrum.cakewallet.com:50002';
@ -63,9 +61,6 @@ Future defaultSettingsMigration(
await sharedPreferences.setInt(
PreferencesKey.currentBalanceDisplayModeKey,
BalanceDisplayMode.availableBalance.raw);
await sharedPreferences.setInt(
PreferencesKey.currentFiatApiModeKey,
FiatApiMode.enabled.raw);
await sharedPreferences.setBool('save_recipient_address', true);
await resetToDefault(nodes);
await changeMoneroCurrentNodeToDefault(
@ -144,10 +139,6 @@ Future defaultSettingsMigration(
await addOnionNode(nodes);
break;
case 19:
await updateFiatApiModes(sharedPreferences);
break;
default:
break;
}
@ -358,14 +349,6 @@ Future<void> updateDisplayModes(SharedPreferences sharedPreferences) async {
PreferencesKey.currentBalanceDisplayModeKey, balanceDisplayMode);
}
Future<void> updateFiatApiModes(SharedPreferences sharedPreferences) async {
final currentFiatApiMode =
sharedPreferences.getInt(PreferencesKey.currentFiatApiModeKey) ?? -1;
final fiatApiMode = currentFiatApiMode < 1 ? 2 : 1;
await sharedPreferences.setInt(
PreferencesKey.currentFiatApiModeKey, fiatApiMode);
}
Future<void> generateBackupPassword(FlutterSecureStorage secureStorage) async {
final key = generateStoreKeyFor(key: SecretStoreKey.backupPassword);

View file

@ -58,7 +58,7 @@ class TransactionsPage extends StatelessWidget {
.format(transaction.date),
formattedAmount: item.formattedCryptoAmount,
formattedFiatAmount:
dashboardViewModel.balanceViewModel.disableFiat
dashboardViewModel.balanceViewModel.isFiatDisabled
? '' : item.formattedFiatAmount,
isPending: transaction.isPending));
}

View file

@ -74,12 +74,9 @@ class ExchangeTradePage extends BasePage {
}
class ExchangeTradeForm extends StatefulWidget {
ExchangeTradeForm(this.exchangeTradeViewModel)
: disableFiat =
exchangeTradeViewModel.sendViewModel.balanceViewModel.disableFiat;
ExchangeTradeForm(this.exchangeTradeViewModel);
final ExchangeTradeViewModel exchangeTradeViewModel;
final bool disableFiat;
@override
ExchangeTradeState createState() => ExchangeTradeState();

View file

@ -331,8 +331,8 @@ class SendCardState extends State<SendCard>
],
),
)),
if (!sendViewModel.balanceViewModel.disableFiat)
Padding(
if (!sendViewModel.isFiatDisabled)
Padding(
padding: const EdgeInsets.only(top: 20),
child: BaseTextFormField(
focusNode: fiatAmountFocus,
@ -438,7 +438,7 @@ class SendCardState extends State<SendCard>
Padding(
padding:
EdgeInsets.only(top: 5),
child: sendViewModel.balanceViewModel.disableFiat
child: sendViewModel.isFiatDisabled
? const SizedBox(height: 14)
: Text(output
.estimatedFeeFiatAmount

View file

@ -1,12 +1,9 @@
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/screens/settings/widgets/settings_choices_cell.dart';
import 'package:cake_wallet/src/screens/settings/widgets/settings_switcher_cell.dart';
import 'package:cake_wallet/view_model/settings/privacy_settings_view_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:cake_wallet/view_model/settings/choices_list_item.dart';
import 'package:cake_wallet/entities/fiat_api_mode.dart';
class PrivacyPage extends BasePage {
PrivacyPage(this._privacySettingsViewModel);
@ -25,8 +22,8 @@ class PrivacyPage extends BasePage {
mainAxisSize: MainAxisSize.min,
children: [
SettingsSwitcherCell(
title: S.current.fiat_api,
value: _privacySettingsViewModel.fiatApiMode,
title: S.current.disable_fiat,
value: _privacySettingsViewModel.isFiatDisabled,
onValueChange: (BuildContext context, bool value) {
_privacySettingsViewModel.setFiatMode(value);
}),

View file

@ -237,7 +237,7 @@ abstract class SettingsStoreBase with Store {
sharedPreferences.getBool(PreferencesKey.shouldSaveRecipientAddressKey) ?? false;
final currentFiatApiMode = FiatApiMode.deserialize(
raw: sharedPreferences
.getInt(PreferencesKey.currentFiatApiModeKey)!);
.getInt(PreferencesKey.currentFiatApiModeKey) ?? FiatApiMode.enabled.raw);
final allowBiometricalAuthentication = sharedPreferences
.getBool(PreferencesKey.allowBiometricalAuthenticationKey) ??
false;

View file

@ -72,7 +72,7 @@ abstract class BalanceViewModelBase with Store {
BalanceDisplayMode get savedDisplayMode => settingsStore.balanceDisplayMode;
@computed
bool get disableFiat => settingsStore.fiatApiMode == FiatApiMode.disabled;
bool get isFiatDisabled => settingsStore.fiatApiMode == FiatApiMode.disabled;
@computed
String get asset {
@ -183,8 +183,8 @@ abstract class BalanceViewModelBase with Store {
return MapEntry(key, BalanceRecord(
availableBalance: '---',
additionalBalance: '---',
fiatAdditionalBalance: disableFiat ? '' : '---',
fiatAvailableBalance: disableFiat ? '' : '---',
fiatAdditionalBalance: isFiatDisabled ? '' : '---',
fiatAvailableBalance: isFiatDisabled ? '' : '---',
asset: key,
formattedAssetTitle: _formatterAsset(key)));
}
@ -195,13 +195,13 @@ abstract class BalanceViewModelBase with Store {
// throw Exception('Price is null for: $key');
// }
final additionalFiatBalance = disableFiat ? '' : (fiatCurrency.toString()
final additionalFiatBalance = isFiatDisabled ? '' : (fiatCurrency.toString()
+ ' '
+ _getFiatBalance(
price: price,
cryptoAmount: value.formattedAdditionalBalance));
final availableFiatBalance = disableFiat ? '' : (fiatCurrency.toString()
final availableFiatBalance = isFiatDisabled ? '' : (fiatCurrency.toString()
+ ' '
+ _getFiatBalance(
price: price,

View file

@ -74,13 +74,13 @@ abstract class ExchangeTradeViewModelBase with Store {
@computed
String get pendingTransactionFiatAmountValueFormatted =>
sendViewModel.balanceViewModel.disableFiat
sendViewModel.isFiatDisabled
? '' : sendViewModel.pendingTransactionFiatAmount
+ ' ' + sendViewModel.fiat.title;
@computed
String get pendingTransactionFeeFiatAmountFormatted =>
sendViewModel.balanceViewModel.disableFiat
sendViewModel.isFiatDisabled
? '' : sendViewModel.pendingTransactionFeeFiatAmount
+ ' ' + sendViewModel.fiat.title;

View file

@ -142,14 +142,17 @@ abstract class SendViewModelBase with Store {
@computed
String get balance => balanceViewModel.availableBalance;
@computed
bool get isFiatDisabled => balanceViewModel.isFiatDisabled;
@computed
String get pendingTransactionFiatAmountFormatted =>
balanceViewModel.disableFiat ? '' : pendingTransactionFiatAmount +
isFiatDisabled ? '' : pendingTransactionFiatAmount +
' ' + fiat.title;
@computed
String get pendingTransactionFeeFiatAmountFormatted =>
balanceViewModel.disableFiat ? '' : pendingTransactionFeeFiatAmount +
isFiatDisabled ? '' : pendingTransactionFeeFiatAmount +
' ' + fiat.title;
@computed

View file

@ -18,7 +18,7 @@ abstract class PrivacySettingsViewModelBase with Store {
bool get shouldSaveRecipientAddress => _settingsStore.shouldSaveRecipientAddress;
@computed
bool get fiatApiMode => _settingsStore.fiatApiMode == FiatApiMode.disabled;
bool get isFiatDisabled => _settingsStore.fiatApiMode == FiatApiMode.disabled;
@action
void setShouldSaveRecipientAddress(bool value) => _settingsStore.shouldSaveRecipientAddress = value;

View file

@ -654,7 +654,6 @@
"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!",
"help": "hilfe",
"fiat_api": "Fiat API",
"disable_exchange": "Exchange deaktivieren",
"connection_sync": "Verbindung und Synchronisierung",
"security_and_backup": "Sicherheit und Datensicherung",
@ -663,6 +662,8 @@
"privacy": "Datenschutz",
"display_settings": "Anzeigeeinstellungen",
"other_settings": "Andere Einstellungen",
"disable_fiat": "Fiat deaktivieren",
"fiat_api": "Fiat API",
"disabled": "Deaktiviert",
"enabled": "Ermöglicht",
"tor_only": "Nur Tor"

View file

@ -654,7 +654,6 @@
"use_suggested": "Use Suggested",
"do_not_share_warning_text" : "Do not share these with anyone else, including support.\n\nThey will steal your money!",
"help": "help",
"fiat_api": "Fiat API",
"disable_exchange": "Disable exchange",
"connection_sync": "Connection and sync",
"security_and_backup": "Security and backup",
@ -663,6 +662,8 @@
"privacy": "Privacy",
"display_settings": "Display settings",
"other_settings": "Other settings",
"disable_fiat": "Disable fiat",
"fiat_api": "Fiat API",
"disabled": "Disabled",
"enabled": "Enabled",
"tor_only": "Tor only"

View file

@ -654,7 +654,6 @@
"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!",
"help": "ayuda",
"fiat_api": "Fiat API",
"disable_exchange": "Deshabilitar intercambio",
"connection_sync": "Conexión y sincronización",
"security_and_backup": "Seguridad y respaldo",
@ -663,6 +662,8 @@
"privacy": "Privacidad",
"display_settings": "Configuración de pantalla",
"other_settings": "Otras configuraciones",
"disable_fiat": "Deshabilitar fiat",
"fiat_api": "Fiat API",
"disabled": "Desactivado",
"enabled": "Activado",
"tor_only": "solo Tor"

View file

@ -652,7 +652,6 @@
"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!",
"help": "aider",
"fiat_api": "Fiat API",
"disable_exchange": "Désactiver l'échange",
"connection_sync": "Connexion et synchronisation",
"security_and_backup": "Sécurité et sauvegarde",
@ -661,6 +660,8 @@
"privacy": "Confidentialité",
"display_settings": "Paramètres d'affichage",
"other_settings": "Autres paramètres",
"disable_fiat": "Désactiver fiat",
"fiat_api": "Fiat API",
"disabled": "Handicapé",
"enabled": "Activé",
"tor_only": "Tor uniquement"

View file

@ -655,7 +655,6 @@
"do_not_share_warning_text" : "इन्हें समर्थन सहित किसी और के साथ साझा न करें।\n\nवे आपका पैसा चुरा लेंगे!",
"help": "मदद करना",
"disable_fiat": "िएट अक्षम करें",
"fiat_api": "फिएट पैसे API",
"connection_sync": "कनेक्शन और सिंक",
"security_and_backup": "सुरक्षा और बैकअप",
"create_backup": "बैकअप बनाएँ",
@ -663,6 +662,8 @@
"privacy": "गोपनीयता",
"display_settings": "प्रदर्शन सेटिंग्स",
"other_settings": "अन्य सेटिंग्स",
"disable_exchange": "एक्सचेंज अक्षम करें",
"fiat_api": "फिएट पैसे API",
"disabled": "अक्षम",
"enabled": "सक्रिय",
"tor_only": "Tor केवल"

View file

@ -654,7 +654,6 @@
"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!",
"help": "pomozite",
"fiat_api": "Fiat API",
"disable_exchange": "Onemogući exchange",
"connection_sync": "Povezivanje i sinkronizacija",
"security_and_backup": "Sigurnost i sigurnosna kopija",
@ -663,6 +662,8 @@
"privacy": "Privatnost",
"display_settings": "Postavke zaslona",
"other_settings": "Ostale postavke",
"disable_fiat": "Isključi, fiat",
"fiat_api": "Fiat API",
"disabled": "Onemogućeno",
"enabled": "Omogućeno",
"tor_only": "Samo Tor"

View file

@ -654,7 +654,6 @@
"use_suggested": "Usa suggerito",
"do_not_share_warning_text" : "Non condividerli con nessun altro, incluso il supporto.\n\nTi ruberanno i soldi!",
"help": "aiuto",
"fiat_api": "Fiat API",
"disable_exchange": "Disabilita scambio",
"connection_sync": "Connessione e sincronizzazione",
"security_and_backup": "Sicurezza e backup",
@ -663,6 +662,8 @@
"privacy": "Privacy",
"display_settings": "Impostazioni di visualizzazione",
"other_settings": "Altre impostazioni",
"disable_fiat": "Disabilita fiat",
"fiat_api": "Fiat API",
"disabled": "Disabilitato",
"enabled": "Abilitato",
"tor_only": "Solo Tor"

View file

@ -654,7 +654,6 @@
"use_suggested": "推奨を使用",
"do_not_share_warning_text" : "サポートを含め、これらを他の誰とも共有しないでください。\n\n彼らはあなたのお金を盗みます",
"help": "ヘルプ",
"fiat_api": "不換紙幣 API",
"disable_exchange": "交換を無効にする",
"connection_sync": "接続と同期",
"security_and_backup": "セキュリティとバックアップ",
@ -663,6 +662,8 @@
"privacy": "プライバシー",
"display_settings": "表示設定",
"other_settings": "その他の設定",
"disable_fiat": "フィアットを無効にする",
"fiat_api": "不換紙幣 API",
"disabled": "無効",
"enabled": "有効",
"tor_only": "Torのみ"

View file

@ -654,7 +654,6 @@
"use_suggested": "추천 사용",
"do_not_share_warning_text" : "지원을 포함하여 다른 사람과 이러한 정보를 공유하지 마십시오.\n\n그들은 당신의 돈을 훔칠 것입니다!",
"help": "돕다",
"fiat_api": "명목 화폐 API",
"disable_exchange": "교환 비활성화",
"connection_sync": "연결 및 동기화",
"security_and_backup": "보안 및 백업",
@ -663,6 +662,8 @@
"privacy": "프라이버시",
"display_settings": "디스플레이 설정",
"other_settings": "기타 설정",
"disable_fiat": "법정화폐 비활성화",
"fiat_api": "명목 화폐 API",
"disabled": "장애가 있는",
"enabled": "사용",
"tor_only": "Tor 뿐"

View file

@ -654,7 +654,6 @@
"use_suggested": "Gebruik aanbevolen",
"do_not_share_warning_text" : "Deel deze met niemand anders, ook niet met support.\n\nZe zullen je geld stelen!",
"help": "helpen",
"fiat_api": "Fiat API",
"disable_exchange": "Uitwisseling uitschakelen",
"connection_sync": "Verbinding en synchronisatie",
"security_and_backup": "Beveiliging en back-up",
@ -663,6 +662,8 @@
"privacy": "Privacy",
"display_settings": "Weergave-instellingen",
"other_settings": "Andere instellingen",
"disable_fiat": "Schakel Fiat uit",
"fiat_api": "Fiat API",
"disabled": "Gehandicapt",
"enabled": "Ingeschakeld",
"tor_only": "Alleen Tor"

View file

@ -654,7 +654,6 @@
"use_suggested": "Użyj sugerowane",
"do_not_share_warning_text" : "Nie udostępniaj ich nikomu innemu, w tym wsparcia.\n\nUkradną twoje pieniądze!",
"help": "pomoc",
"fiat_api": "API Fiata",
"disable_exchange": "Wyłącz wymianę",
"connection_sync": "Połączenie i synchronizacja",
"security_and_backup": "Bezpieczeństwo i kopia zapasowa",
@ -663,6 +662,8 @@
"privacy": "Prywatność",
"display_settings": "Ustawienia wyświetlania",
"other_settings": "Inne ustawienia",
"disable_fiat": "Wyłącz fiat",
"fiat_api": "API Fiata",
"disabled": "Wyłączone",
"enabled": "Włączony",
"tor_only": "Tylko Tor"

View file

@ -653,7 +653,6 @@
"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!",
"help": "ajuda",
"fiat_api": "API da Fiat",
"disable_exchange": "Desativar troca",
"connection_sync": "Conexão e sincronização",
"security_and_backup": "Segurança e backup",
@ -662,6 +661,8 @@
"privacy": "Privacidade",
"display_settings": "Configurações de exibição",
"other_settings": "Outras configurações",
"disable_fiat": "Desativar fiat",
"fiat_api": "API da Fiat",
"disabled": "Desabilitado",
"enabled": "Habilitado",
"tor_only": "Tor apenas"

View file

@ -654,7 +654,6 @@
"use_suggested": "Использовать предложенный",
"do_not_share_warning_text" : "Не делитесь ими с кем-либо еще, в том числе со службой поддержки.\n\nОни украдут ваши деньги!",
"help": "помощь",
"fiat_api": "Фиат API",
"disable_exchange": "Отключить обмен",
"connection_sync": "Подключение и синхронизация",
"security_and_backup": "Безопасность и резервное копирование",
@ -663,6 +662,8 @@
"privacy": "Конфиденциальность",
"display_settings": "Настройки отображения",
"other_settings": "Другие настройки",
"disable_fiat": "Отключить фиат",
"fiat_api": "Фиат API",
"disabled": "Отключено",
"enabled": "Включено",
"tor_only": "Только Tor"

View file

@ -653,7 +653,6 @@
"use_suggested": "Використати запропоноване",
"do_not_share_warning_text" : "Не повідомляйте їх нікому, включно зі службою підтримки.\n\nВони вкрадуть ваші гроші!",
"help": "допомога",
"fiat_api": "Фіат API",
"disable_exchange": "Вимкнути exchange",
"connection_sync": "Підключення та синхронізація",
"security_and_backup": "Безпека та резервне копіювання",
@ -662,6 +661,8 @@
"privacy": "Конфіденційність",
"display_settings": "Налаштування дисплея",
"other_settings": "Інші налаштування",
"disable_fiat": "Вимкнути фиат",
"fiat_api": "Фіат API",
"disabled": "Вимкнено",
"enabled": "Увімкнено",
"tor_only": "Тільки Tor"

View file

@ -652,7 +652,6 @@
"use_suggested": "使用建议",
"do_not_share_warning_text" : "不要與其他任何人分享這些內容,包括支持。\n\n他們會偷你的錢",
"help": "帮助",
"fiat_api": "法币API",
"disable_exchange": "禁用交换",
"connection_sync": "连接和同步",
"security_and_backup": "安全和备份",
@ -661,6 +660,8 @@
"privacy":"隐私",
"display_settings": "显示设置",
"other_settings": "其他设置",
"disable_fiat": "禁用法令",
"fiat_api": "法币API",
"disabled": "禁用",
"enabled": "启用",
"tor_only": "仅限 Tor"