From d4c7004a3cd7785d5f452cbc96089d7d0712cb4e Mon Sep 17 00:00:00 2001 From: Serhii Date: Fri, 4 Nov 2022 13:58:04 +0200 Subject: [PATCH 01/20] add Disable fiat mode --- lib/entities/default_settings_migration.dart | 1 + lib/entities/preferences_key.dart | 1 + lib/reactions/fiat_rate_update.dart | 4 +++- .../dashboard/widgets/transactions_page.dart | 4 +++- .../exchange_trade/exchange_trade_page.dart | 11 +++++++--- lib/src/screens/send/send_page.dart | 14 ++++++------- lib/src/screens/send/widgets/send_card.dart | 6 ++++-- lib/src/screens/settings/settings.dart | 13 +++++++----- lib/store/settings_store.dart | 14 +++++++++++++ .../dashboard/balance_view_model.dart | 19 ++++++++++------- .../settings/settings_view_model.dart | 21 +++++++++++++++---- 11 files changed, 76 insertions(+), 32 deletions(-) diff --git a/lib/entities/default_settings_migration.dart b/lib/entities/default_settings_migration.dart index b2036c3f6..ff8ffc2ed 100644 --- a/lib/entities/default_settings_migration.dart +++ b/lib/entities/default_settings_migration.dart @@ -61,6 +61,7 @@ Future defaultSettingsMigration( await sharedPreferences.setInt( PreferencesKey.currentBalanceDisplayModeKey, BalanceDisplayMode.availableBalance.raw); + await sharedPreferences.setBool('disable_fiat', false); await sharedPreferences.setBool('save_recipient_address', true); await resetToDefault(nodes); await changeMoneroCurrentNodeToDefault( diff --git a/lib/entities/preferences_key.dart b/lib/entities/preferences_key.dart index 6cf7e5608..62c458fa0 100644 --- a/lib/entities/preferences_key.dart +++ b/lib/entities/preferences_key.dart @@ -9,6 +9,7 @@ class PreferencesKey { static const currentTransactionPriorityKeyLegacy = 'current_fee_priority'; static const currentBalanceDisplayModeKey = 'current_balance_display_mode'; static const shouldSaveRecipientAddressKey = 'save_recipient_address'; + static const shouldDisableFiatKey = 'disable_fiat'; static const allowBiometricalAuthenticationKey = 'allow_biometrical_authentication'; static const currentTheme = 'current_theme'; diff --git a/lib/reactions/fiat_rate_update.dart b/lib/reactions/fiat_rate_update.dart index 784a14e82..fb40a26e3 100644 --- a/lib/reactions/fiat_rate_update.dart +++ b/lib/reactions/fiat_rate_update.dart @@ -27,7 +27,9 @@ Future startFiatRateUpdate(AppStore appStore, SettingsStore settingsStore, if (appStore.wallet!.type == WalletType.haven) { await updateHavenRate(fiatConversionStore); } else { - fiatConversionStore.prices[appStore.wallet!.currency] = await FiatConversionService.fetchPrice( + fiatConversionStore.prices[appStore.wallet!.currency] = + settingsStore.shouldDisableFiat ? 0.0 + : await FiatConversionService.fetchPrice( appStore.wallet!.currency, settingsStore.fiatCurrency); } } catch(e) { diff --git a/lib/src/screens/dashboard/widgets/transactions_page.dart b/lib/src/screens/dashboard/widgets/transactions_page.dart index 8ab7c0efb..9e09bae8c 100644 --- a/lib/src/screens/dashboard/widgets/transactions_page.dart +++ b/lib/src/screens/dashboard/widgets/transactions_page.dart @@ -57,7 +57,9 @@ class TransactionsPage extends StatelessWidget { formattedDate: DateFormat('HH:mm') .format(transaction.date), formattedAmount: item.formattedCryptoAmount, - formattedFiatAmount: item.formattedFiatAmount, + formattedFiatAmount: + dashboardViewModel.balanceViewModel.disableFiat + ? '' : item.formattedFiatAmount, isPending: transaction.isPending)); } diff --git a/lib/src/screens/exchange_trade/exchange_trade_page.dart b/lib/src/screens/exchange_trade/exchange_trade_page.dart index aa3079197..4128fb9f2 100644 --- a/lib/src/screens/exchange_trade/exchange_trade_page.dart +++ b/lib/src/screens/exchange_trade/exchange_trade_page.dart @@ -74,9 +74,12 @@ class ExchangeTradePage extends BasePage { } class ExchangeTradeForm extends StatefulWidget { - ExchangeTradeForm(this.exchangeTradeViewModel); + ExchangeTradeForm(this.exchangeTradeViewModel) + : disableFiat = + exchangeTradeViewModel.sendViewModel.balanceViewModel.disableFiat; final ExchangeTradeViewModel exchangeTradeViewModel; + final bool disableFiat; @override ExchangeTradeState createState() => ExchangeTradeState(); @@ -378,9 +381,11 @@ class ExchangeTradeState extends State { }); }, actionLeftButton: () => Navigator.of(context).pop(), - feeFiatAmount: widget.exchangeTradeViewModel.sendViewModel.pendingTransactionFeeFiatAmount + feeFiatAmount: widget.disableFiat ? '' + : widget.exchangeTradeViewModel.sendViewModel.pendingTransactionFeeFiatAmount + ' ' + widget.exchangeTradeViewModel.sendViewModel.fiat.title, - fiatAmountValue: widget.exchangeTradeViewModel.sendViewModel + fiatAmountValue: widget.disableFiat ? '' + : widget.exchangeTradeViewModel.sendViewModel .pendingTransactionFiatAmount + ' ' + widget.exchangeTradeViewModel.sendViewModel.fiat.title, diff --git a/lib/src/screens/send/send_page.dart b/lib/src/screens/send/send_page.dart index e0cfff517..8815d8c58 100644 --- a/lib/src/screens/send/send_page.dart +++ b/lib/src/screens/send/send_page.dart @@ -386,16 +386,14 @@ class SendPage extends BasePage { amount: S.of(context).send_amount, amountValue: sendViewModel.pendingTransaction!.amountFormatted, - fiatAmountValue: - sendViewModel.pendingTransactionFiatAmount + - ' ' + - sendViewModel.fiat.title, + fiatAmountValue: sendViewModel.balanceViewModel.disableFiat + ? '' : sendViewModel.pendingTransactionFiatAmount + + ' ' + sendViewModel.fiat.title, fee: S.of(context).send_fee, feeValue: sendViewModel.pendingTransaction!.feeFormatted, - feeFiatAmount: - sendViewModel.pendingTransactionFeeFiatAmount + - ' ' + - sendViewModel.fiat.title, + feeFiatAmount: sendViewModel.balanceViewModel.disableFiat + ? '' : sendViewModel.pendingTransactionFeeFiatAmount + + ' ' + sendViewModel.fiat.title, outputs: sendViewModel.outputs, rightButtonText: S.of(context).ok, leftButtonText: S.of(context).cancel, diff --git a/lib/src/screens/send/widgets/send_card.dart b/lib/src/screens/send/widgets/send_card.dart index dc589923f..7e7194f88 100644 --- a/lib/src/screens/send/widgets/send_card.dart +++ b/lib/src/screens/send/widgets/send_card.dart @@ -332,6 +332,8 @@ class SendCardState extends State ], ), )), + sendViewModel.balanceViewModel.disableFiat ? + Container () : Padding( padding: const EdgeInsets.only(top: 20), child: BaseTextFormField( @@ -438,8 +440,8 @@ class SendCardState extends State Padding( padding: EdgeInsets.only(top: 5), - child: Text( - output + child: sendViewModel.balanceViewModel.disableFiat ? + Container () : Text(output .estimatedFeeFiatAmount + ' ' + sendViewModel diff --git a/lib/src/screens/settings/settings.dart b/lib/src/screens/settings/settings.dart index 3f6f41e7b..4a1f6bcb0 100644 --- a/lib/src/screens/settings/settings.dart +++ b/lib/src/screens/settings/settings.dart @@ -29,18 +29,20 @@ class SettingsPage extends BasePage { @override Widget body(BuildContext context) { // FIX-ME: Added `context` it was not used here before, maby bug ? - return SectionStandardList( + return Observer(builder: (_) { + final sections = settingsViewModel.getSections(); + return SectionStandardList( context: context, - sectionCount: settingsViewModel.sections.length, + sectionCount: sections.length, itemCounter: (int sectionIndex) { - if (sectionIndex < settingsViewModel.sections.length) { - return settingsViewModel.sections[sectionIndex].length; + if (sectionIndex < sections.length) { + return sections[sectionIndex].length; } return 0; }, itemBuilder: (_, sectionIndex, itemIndex) { - final item = settingsViewModel.sections[sectionIndex][itemIndex]; + final item = sections[sectionIndex][itemIndex]; if (item is PickerListItem) { return Observer(builder: (_) { @@ -94,5 +96,6 @@ class SettingsPage extends BasePage { return Container(); }); + }); } } diff --git a/lib/store/settings_store.dart b/lib/store/settings_store.dart index 2b3105a34..5afd2c107 100644 --- a/lib/store/settings_store.dart +++ b/lib/store/settings_store.dart @@ -29,6 +29,7 @@ abstract class SettingsStoreBase with Store { required FiatCurrency initialFiatCurrency, required BalanceDisplayMode initialBalanceDisplayMode, required bool initialSaveRecipientAddress, + required bool initialDisableFiat, required bool initialAllowBiometricalAuthentication, required ThemeBase initialTheme, required int initialPinLength, @@ -46,6 +47,7 @@ abstract class SettingsStoreBase with Store { fiatCurrency = initialFiatCurrency, balanceDisplayMode = initialBalanceDisplayMode, shouldSaveRecipientAddress = initialSaveRecipientAddress, + shouldDisableFiat = initialDisableFiat, allowBiometricalAuthentication = initialAllowBiometricalAuthentication, currentTheme = initialTheme, pinCodeLength = initialPinLength, @@ -87,6 +89,12 @@ abstract class SettingsStoreBase with Store { PreferencesKey.shouldSaveRecipientAddressKey, shouldSaveRecipientAddress)); + reaction( + (_) => shouldDisableFiat, + (bool shouldDisableFiat) => sharedPreferences.setBool( + PreferencesKey.shouldDisableFiatKey, + shouldDisableFiat)); + reaction( (_) => currentTheme, (ThemeBase theme) => @@ -140,6 +148,9 @@ abstract class SettingsStoreBase with Store { @observable bool shouldSaveRecipientAddress; + @observable + bool shouldDisableFiat; + @observable bool allowBiometricalAuthentication; @@ -218,6 +229,8 @@ abstract class SettingsStoreBase with Store { // FIX-ME: Check for which default value we should have here final shouldSaveRecipientAddress = sharedPreferences.getBool(PreferencesKey.shouldSaveRecipientAddressKey) ?? false; + final shouldDisableFiat = + sharedPreferences.getBool(PreferencesKey.shouldDisableFiatKey) ?? false; final allowBiometricalAuthentication = sharedPreferences .getBool(PreferencesKey.allowBiometricalAuthenticationKey) ?? false; @@ -283,6 +296,7 @@ abstract class SettingsStoreBase with Store { initialFiatCurrency: currentFiatCurrency, initialBalanceDisplayMode: currentBalanceDisplayMode, initialSaveRecipientAddress: shouldSaveRecipientAddress, + initialDisableFiat: shouldDisableFiat, initialAllowBiometricalAuthentication: allowBiometricalAuthentication, initialTheme: savedTheme, actionlistDisplayMode: actionListDisplayMode, diff --git a/lib/view_model/dashboard/balance_view_model.dart b/lib/view_model/dashboard/balance_view_model.dart index 75d107b89..40502bb84 100644 --- a/lib/view_model/dashboard/balance_view_model.dart +++ b/lib/view_model/dashboard/balance_view_model.dart @@ -71,6 +71,9 @@ abstract class BalanceViewModelBase with Store { @computed BalanceDisplayMode get savedDisplayMode => settingsStore.balanceDisplayMode; + @computed + bool get disableFiat => settingsStore.shouldDisableFiat; + @computed String get asset { final typeFormatted = walletTypeToString(appStore.wallet!.type); @@ -180,8 +183,8 @@ abstract class BalanceViewModelBase with Store { return MapEntry(key, BalanceRecord( availableBalance: '---', additionalBalance: '---', - fiatAdditionalBalance: '---', - fiatAvailableBalance: '---', + fiatAdditionalBalance: disableFiat ? '' : '---', + fiatAvailableBalance: disableFiat ? '' : '---', asset: key, formattedAssetTitle: _formatterAsset(key))); } @@ -192,17 +195,17 @@ abstract class BalanceViewModelBase with Store { // throw Exception('Price is null for: $key'); // } - final additionalFiatBalance = fiatCurrency.toString() - + ' ' + final additionalFiatBalance = disableFiat ? '' : (fiatCurrency.toString() + + ' ' + _getFiatBalance( price: price, - cryptoAmount: value.formattedAdditionalBalance); + cryptoAmount: value.formattedAdditionalBalance)); - final availableFiatBalance = fiatCurrency.toString() - + ' ' + final availableFiatBalance = disableFiat ? '' : (fiatCurrency.toString() + + ' ' + _getFiatBalance( price: price, - cryptoAmount: value.formattedAvailableBalance); + cryptoAmount: value.formattedAvailableBalance)); return MapEntry(key, BalanceRecord( availableBalance: value.formattedAvailableBalance, diff --git a/lib/view_model/settings/settings_view_model.dart b/lib/view_model/settings/settings_view_model.dart index 96b2e7bdd..23ea0fded 100644 --- a/lib/view_model/settings/settings_view_model.dart +++ b/lib/view_model/settings/settings_view_model.dart @@ -61,7 +61,6 @@ abstract class SettingsViewModelBase with Store { : itemHeaders = {}, _walletType = wallet.type, _biometricAuth = BiometricAuth(), - sections = >[], currentVersion = '' { PackageInfo.fromPlatform().then( (PackageInfo packageInfo) => currentVersion = packageInfo.version); @@ -98,7 +97,7 @@ abstract class SettingsViewModelBase with Store { //} - sections = [ + getSections = () => [ [ SwitcherListItem( title: S.current.settings_display_balance, @@ -111,7 +110,7 @@ abstract class SettingsViewModelBase with Store { } }, ), - if (!isHaven) + if (!isHaven && !shouldDisableFiat) PickerListItem( title: S.current.settings_currency, searchHintText: S.current.search_currency, @@ -183,6 +182,11 @@ abstract class SettingsViewModelBase with Store { return LanguageService.list[code]?.toLowerCase().contains(searchText) ?? false; }, ), + SwitcherListItem( + title: 'S.current.disable_fiat', + value: () => shouldDisableFiat, + onValueChange: (_, bool value) => + setShouldDisableFiat(value)), SwitcherListItem( title: S.current.settings_allow_biometrical_authentication, value: () => allowBiometricalAuthentication, @@ -208,6 +212,7 @@ abstract class SettingsViewModelBase with Store { setAllowBiometricalAuthentication(value); } }), + ChoicesListItem( title: S.current.color_theme, items: ThemeList.all, @@ -275,6 +280,10 @@ abstract class SettingsViewModelBase with Store { bool get shouldSaveRecipientAddress => _settingsStore.shouldSaveRecipientAddress; + @computed + bool get shouldDisableFiat => + _settingsStore.shouldDisableFiat; + @computed bool get allowBiometricalAuthentication => _settingsStore.allowBiometricalAuthentication; @@ -285,7 +294,7 @@ abstract class SettingsViewModelBase with Store { bool get isBitcoinBuyEnabled => _settingsStore.isBitcoinBuyEnabled; final Map itemHeaders; - List> sections; + late List> Function() getSections; final SettingsStore _settingsStore; final YatStore _yatStore; final WalletType _walletType; @@ -303,6 +312,10 @@ abstract class SettingsViewModelBase with Store { void setShouldSaveRecipientAddress(bool value) => _settingsStore.shouldSaveRecipientAddress = value; + @action + void setShouldDisableFiat(bool value) => + _settingsStore.shouldDisableFiat = value; + @action void setAllowBiometricalAuthentication(bool value) => _settingsStore.allowBiometricalAuthentication = value; From b5e74874cef3a2f63105baca116d69e16b95e3ca Mon Sep 17 00:00:00 2001 From: Serhii Date: Fri, 4 Nov 2022 14:11:06 +0200 Subject: [PATCH 02/20] update localization files --- res/values/strings_de.arb | 3 ++- res/values/strings_en.arb | 3 ++- res/values/strings_es.arb | 3 ++- res/values/strings_fr.arb | 3 ++- res/values/strings_hi.arb | 3 ++- res/values/strings_hr.arb | 3 ++- res/values/strings_it.arb | 3 ++- res/values/strings_ja.arb | 3 ++- res/values/strings_ko.arb | 3 ++- res/values/strings_nl.arb | 3 ++- res/values/strings_pl.arb | 3 ++- res/values/strings_pt.arb | 3 ++- res/values/strings_ru.arb | 3 ++- res/values/strings_uk.arb | 3 ++- res/values/strings_zh.arb | 3 ++- 15 files changed, 30 insertions(+), 15 deletions(-) diff --git a/res/values/strings_de.arb b/res/values/strings_de.arb index a580ab90a..e5d12d80b 100644 --- a/res/values/strings_de.arb +++ b/res/values/strings_de.arb @@ -651,5 +651,6 @@ "ignor": "Ignorieren", "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" + "help": "hilfe", + "disable_fiat": "Fiat deaktivieren" } diff --git a/res/values/strings_en.arb b/res/values/strings_en.arb index 877d09231..aa995606f 100644 --- a/res/values/strings_en.arb +++ b/res/values/strings_en.arb @@ -651,5 +651,6 @@ "ignor": "Ignore", "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" + "help": "help", + "disable_fiat": "Disable fiat" } diff --git a/res/values/strings_es.arb b/res/values/strings_es.arb index 505f3ffa8..843e7c9f9 100644 --- a/res/values/strings_es.arb +++ b/res/values/strings_es.arb @@ -651,5 +651,6 @@ "ignor": "Pasar por alto", "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" + "help": "ayuda", + "disable_fiat": "Deshabilitar fiat" } diff --git a/res/values/strings_fr.arb b/res/values/strings_fr.arb index 941016c0b..d4b36dc4d 100644 --- a/res/values/strings_fr.arb +++ b/res/values/strings_fr.arb @@ -649,5 +649,6 @@ "ignor": "Ignorer", "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" + "help": "aider", + "disable_fiat": "Désactiver fiat" } diff --git a/res/values/strings_hi.arb b/res/values/strings_hi.arb index 7faa06f7f..a94bfb628 100644 --- a/res/values/strings_hi.arb +++ b/res/values/strings_hi.arb @@ -651,5 +651,6 @@ "ignor": "नज़रअंदाज़ करना", "use_suggested": "सुझाए गए का प्रयोग करें", "do_not_share_warning_text" : "इन्हें समर्थन सहित किसी और के साथ साझा न करें।\n\nवे आपका पैसा चुरा लेंगे!", - "help": "मदद करना" + "help": "मदद करना", + "disable_fiat": "िएट अक्षम करें" } diff --git a/res/values/strings_hr.arb b/res/values/strings_hr.arb index 4fa77948a..dac4b5f23 100644 --- a/res/values/strings_hr.arb +++ b/res/values/strings_hr.arb @@ -651,5 +651,6 @@ "ignor": "Zanemariti", "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" + "help": "pomozite", + "disable_fiat": "Isključi, fiat" } diff --git a/res/values/strings_it.arb b/res/values/strings_it.arb index 9a42a588b..e14c4c7d4 100644 --- a/res/values/strings_it.arb +++ b/res/values/strings_it.arb @@ -651,5 +651,6 @@ "ignor": "Ignorare", "use_suggested": "Usa suggerito", "do_not_share_warning_text" : "Non condividerli con nessun altro, incluso il supporto.\n\nTi ruberanno i soldi!", - "help": "aiuto" + "help": "aiuto", + "disable_fiat": "Disabilita fiat" } diff --git a/res/values/strings_ja.arb b/res/values/strings_ja.arb index c1d0de4e3..62b12033a 100644 --- a/res/values/strings_ja.arb +++ b/res/values/strings_ja.arb @@ -651,5 +651,6 @@ "ignor": "無視", "use_suggested": "推奨を使用", "do_not_share_warning_text" : "サポートを含め、これらを他の誰とも共有しないでください。\n\n彼らはあなたのお金を盗みます!", - "help": "ヘルプ" + "help": "ヘルプ", + "disable_fiat": "フィアットを無効にする" } diff --git a/res/values/strings_ko.arb b/res/values/strings_ko.arb index 127aa949e..35f0520d4 100644 --- a/res/values/strings_ko.arb +++ b/res/values/strings_ko.arb @@ -651,5 +651,6 @@ "ignor": "무시하다", "use_suggested": "추천 사용", "do_not_share_warning_text" : "지원을 포함하여 다른 사람과 이러한 정보를 공유하지 마십시오.\n\n그들은 당신의 돈을 훔칠 것입니다!", - "help": "돕다" + "help": "돕다", + "disable_fiat": "법정화폐 비활성화" } diff --git a/res/values/strings_nl.arb b/res/values/strings_nl.arb index bc53337a8..d8ced1592 100644 --- a/res/values/strings_nl.arb +++ b/res/values/strings_nl.arb @@ -651,5 +651,6 @@ "ignor": "Negeren", "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" + "help": "helpen", + "disable_fiat": "법정화폐 비활성화" } diff --git a/res/values/strings_pl.arb b/res/values/strings_pl.arb index 454fe9717..59f7c227e 100644 --- a/res/values/strings_pl.arb +++ b/res/values/strings_pl.arb @@ -651,5 +651,6 @@ "ignor": "Ignorować", "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" + "help": "pomoc", + "disable_fiat": "Wyłącz fiat" } diff --git a/res/values/strings_pt.arb b/res/values/strings_pt.arb index 04a0a3ff2..defbf6ac1 100644 --- a/res/values/strings_pt.arb +++ b/res/values/strings_pt.arb @@ -651,5 +651,6 @@ "ignor": "Ignorar", "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" + "help": "ajuda", + "disable_fiat": "Desativar fiat" } diff --git a/res/values/strings_ru.arb b/res/values/strings_ru.arb index 632b0990c..9fa39b59b 100644 --- a/res/values/strings_ru.arb +++ b/res/values/strings_ru.arb @@ -651,5 +651,6 @@ "ignor": "Игнорировать", "use_suggested": "Использовать предложенный", "do_not_share_warning_text" : "Не делитесь ими с кем-либо еще, в том числе со службой поддержки.\n\nОни украдут ваши деньги!", - "help": "помощь" + "help": "помощь", + "disable_fiat": "Отключить фиат" } diff --git a/res/values/strings_uk.arb b/res/values/strings_uk.arb index 5e0f0d18a..9e16d6696 100644 --- a/res/values/strings_uk.arb +++ b/res/values/strings_uk.arb @@ -650,5 +650,6 @@ "ignor": "Ігнорувати", "use_suggested": "Використати запропоноване", "do_not_share_warning_text" : "Не повідомляйте їх нікому, включно зі службою підтримки.\n\nВони вкрадуть ваші гроші!", - "help": "допомога" + "help": "допомога", + "disable_fiat": "Вимкнути фиат" } diff --git a/res/values/strings_zh.arb b/res/values/strings_zh.arb index c46d07d59..40ab71cad 100644 --- a/res/values/strings_zh.arb +++ b/res/values/strings_zh.arb @@ -649,5 +649,6 @@ "ignor": "忽视", "use_suggested": "使用建议", "do_not_share_warning_text" : "不要與其他任何人分享這些內容,包括支持。\n\n他們會偷你的錢!", - "help": "帮助" + "help": "帮助", + "disable_fiat": "禁用法令" } From c99e5f6f317ebbedd504c4068418a193acecbe34 Mon Sep 17 00:00:00 2001 From: Serhii Date: Fri, 4 Nov 2022 14:28:41 +0200 Subject: [PATCH 03/20] fix localization --- lib/view_model/settings/settings_view_model.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/view_model/settings/settings_view_model.dart b/lib/view_model/settings/settings_view_model.dart index 23ea0fded..4d0e9221a 100644 --- a/lib/view_model/settings/settings_view_model.dart +++ b/lib/view_model/settings/settings_view_model.dart @@ -183,7 +183,7 @@ abstract class SettingsViewModelBase with Store { }, ), SwitcherListItem( - title: 'S.current.disable_fiat', + title: S.current.disable_fiat, value: () => shouldDisableFiat, onValueChange: (_, bool value) => setShouldDisableFiat(value)), From cf7c21946b4550d793158a753800857d5d859708 Mon Sep 17 00:00:00 2001 From: Justin Ehrenhofer Date: Thu, 10 Nov 2022 14:45:10 -0600 Subject: [PATCH 04/20] Improve warning wording Recommended in the Telegram testing group --- res/values/strings_de.arb | 2 +- res/values/strings_en.arb | 2 +- res/values/strings_es.arb | 2 +- res/values/strings_fr.arb | 2 +- res/values/strings_hi.arb | 2 +- res/values/strings_hr.arb | 2 +- res/values/strings_it.arb | 2 +- res/values/strings_ja.arb | 2 +- res/values/strings_ko.arb | 2 +- res/values/strings_nl.arb | 2 +- res/values/strings_pl.arb | 2 +- res/values/strings_pt.arb | 2 +- res/values/strings_ru.arb | 2 +- res/values/strings_uk.arb | 2 +- res/values/strings_zh.arb | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/res/values/strings_de.arb b/res/values/strings_de.arb index 685d817d5..dda932168 100644 --- a/res/values/strings_de.arb +++ b/res/values/strings_de.arb @@ -650,6 +650,6 @@ "low_fee_alert": "Sie verwenden derzeit eine niedrige Netzwerkgebührenpriorität. Dies kann zu langen Wartezeiten, unterschiedlichen Kursen oder stornierten Trades führen. Wir empfehlen, für ein besseres Erlebnis eine höhere Gebühr festzulegen.", "ignor": "Ignorieren", "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 Support.\n\nIhr Geld kann und wird gestohlen werden!", "help": "hilfe" } diff --git a/res/values/strings_en.arb b/res/values/strings_en.arb index 877d09231..464f9ee06 100644 --- a/res/values/strings_en.arb +++ b/res/values/strings_en.arb @@ -650,6 +650,6 @@ "low_fee_alert": "You currently are using a low network fee priority. This could cause long waits, different rates, or canceled trades. We recommend setting a higher fee for a better experience.", "ignor": "Ignore", "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\nYour funds can and will be stolen!", "help": "help" } diff --git a/res/values/strings_es.arb b/res/values/strings_es.arb index 505f3ffa8..45a2a6ae7 100644 --- a/res/values/strings_es.arb +++ b/res/values/strings_es.arb @@ -650,6 +650,6 @@ "low_fee_alert": "Actualmente está utilizando una prioridad de tarifa de red baja. Esto podría causar largas esperas, tarifas diferentes o transacciones canceladas. Recomendamos establecer una tarifa más alta para una mejor experiencia.", "ignor": "Pasar por alto", "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¡Sus fondos pueden ser y serán robados!", "help": "ayuda" } diff --git a/res/values/strings_fr.arb b/res/values/strings_fr.arb index 941016c0b..fda7904b9 100644 --- a/res/values/strings_fr.arb +++ b/res/values/strings_fr.arb @@ -648,6 +648,6 @@ "low_fee_alert": "Vous utilisez actuellement une priorité de frais de réseau peu élevés. Cela pourrait entraîner de longues attentes, des taux différents ou des transactions annulées. Nous vous recommandons de fixer des frais plus élevés pour une meilleure expérience.", "ignor": "Ignorer", "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\nVos fonds peuvent et seront volés!", "help": "aider" } diff --git a/res/values/strings_hi.arb b/res/values/strings_hi.arb index 7faa06f7f..5cd157c91 100644 --- a/res/values/strings_hi.arb +++ b/res/values/strings_hi.arb @@ -650,6 +650,6 @@ "low_fee_alert": "आप वर्तमान में कम नेटवर्क शुल्क प्राथमिकता का उपयोग कर रहे हैं। यह लंबे इंतजार, अलग-अलग दरों या रद्द किए गए ट्रेडों का कारण बन सकता है। हम बेहतर अनुभव के लिए अधिक शुल्क निर्धारित करने की सलाह देते हैं।", "ignor": "नज़रअंदाज़ करना", "use_suggested": "सुझाए गए का प्रयोग करें", - "do_not_share_warning_text" : "इन्हें समर्थन सहित किसी और के साथ साझा न करें।\n\nवे आपका पैसा चुरा लेंगे!", + "do_not_share_warning_text" : "समर्थन सहित, इन्हें किसी और के साथ साझा न करें।\n\nआपके धन की चोरी हो सकती है और होगी!", "help": "मदद करना" } diff --git a/res/values/strings_hr.arb b/res/values/strings_hr.arb index 4fa77948a..369e573d4 100644 --- a/res/values/strings_hr.arb +++ b/res/values/strings_hr.arb @@ -650,6 +650,6 @@ "low_fee_alert": "Trenutačno koristite niski prioritet mrežne naknade. To bi moglo uzrokovati duga čekanja, različite tečajeve ili otkazane trgovine. Preporučujemo postavljanje veće naknade za bolje iskustvo.", "ignor": "Zanemariti", "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\nVaša sredstva mogu i bit će ukradena!", "help": "pomozite" } diff --git a/res/values/strings_it.arb b/res/values/strings_it.arb index 9a42a588b..f1430aa5b 100644 --- a/res/values/strings_it.arb +++ b/res/values/strings_it.arb @@ -650,6 +650,6 @@ "low_fee_alert": "Attualmente stai utilizzando una priorità a tariffa di rete bassa. Ciò potrebbe causare lunghe attese, tariffe diverse o operazioni annullate. Ti consigliamo di impostare una tariffa più alta per un'esperienza migliore.", "ignor": "Ignorare", "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\nI tuoi fondi possono e saranno rubati!", "help": "aiuto" } diff --git a/res/values/strings_ja.arb b/res/values/strings_ja.arb index c1d0de4e3..56622a2b2 100644 --- a/res/values/strings_ja.arb +++ b/res/values/strings_ja.arb @@ -650,6 +650,6 @@ "low_fee_alert": "現在、低ネットワーク料金優先度を使用しています。これにより、長い待ち時間、異なるレート、またはキャンセルされた取引が発生する可能性があります。より良い体験のために、より高い料金を設定することをお勧めします。", "ignor": "無視", "use_suggested": "推奨を使用", - "do_not_share_warning_text" : "サポートを含め、これらを他の誰とも共有しないでください。\n\n彼らはあなたのお金を盗みます!", + "do_not_share_warning_text" : "サポートを含め、これらを他の誰とも共有しないでください。\n\nあなたの資金は盗まれる可能性があります!", "help": "ヘルプ" } diff --git a/res/values/strings_ko.arb b/res/values/strings_ko.arb index 127aa949e..ea7a722f9 100644 --- a/res/values/strings_ko.arb +++ b/res/values/strings_ko.arb @@ -650,6 +650,6 @@ "low_fee_alert": "현재 낮은 네트워크 요금 우선 순위를 사용하고 있습니다. 이로 인해 긴 대기 시간, 다른 요금 또는 취소된 거래가 발생할 수 있습니다. 더 나은 경험을 위해 더 높은 요금을 설정하는 것이 좋습니다.", "ignor": "무시하다", "use_suggested": "추천 사용", - "do_not_share_warning_text" : "지원을 포함하여 다른 사람과 이러한 정보를 공유하지 마십시오.\n\n그들은 당신의 돈을 훔칠 것입니다!", + "do_not_share_warning_text" : "지원을 포함하여 다른 사람과 이러한 정보를 공유하지 마십시오.\n\n귀하의 자금은 도난당할 수 있고 도난당할 수 있습니다!", "help": "돕다" } diff --git a/res/values/strings_nl.arb b/res/values/strings_nl.arb index fa748b552..a25087498 100644 --- a/res/values/strings_nl.arb +++ b/res/values/strings_nl.arb @@ -650,6 +650,6 @@ "low_fee_alert": "U gebruikt momenteel een lage prioriteit voor netwerkkosten. Dit kan lange wachttijden, andere tarieven of geannuleerde transacties veroorzaken. We raden aan een hogere vergoeding in te stellen voor een betere ervaring.", "ignor": "Negeren", "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\nUw geld kan en zal worden gestolen!", "help": "helpen" } diff --git a/res/values/strings_pl.arb b/res/values/strings_pl.arb index 454fe9717..d66c084e6 100644 --- a/res/values/strings_pl.arb +++ b/res/values/strings_pl.arb @@ -650,6 +650,6 @@ "low_fee_alert": "Obecnie korzystasz z niskiego priorytetu opłaty sieciowej. Może to spowodować długie oczekiwanie, różne stawki lub anulowane transakcje. Zalecamy ustawienie wyższej opłaty, aby zapewnić lepsze wrażenia.", "ignor": "Ignorować", "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 pomocy.\n\nTwoje środki mogą i zostaną skradzione!", "help": "pomoc" } diff --git a/res/values/strings_pt.arb b/res/values/strings_pt.arb index 04a0a3ff2..5db2e7a6a 100644 --- a/res/values/strings_pt.arb +++ b/res/values/strings_pt.arb @@ -650,6 +650,6 @@ "low_fee_alert": "No momento, você está usando uma prioridade de taxa de rede baixa. Isso pode causar longas esperas, taxas diferentes ou negociações canceladas. Recomendamos definir uma taxa mais alta para uma melhor experiência.", "ignor": "Ignorar", "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\nSeus fundos podem e serão roubados!", "help": "ajuda" } diff --git a/res/values/strings_ru.arb b/res/values/strings_ru.arb index 632b0990c..b454a4ffb 100644 --- a/res/values/strings_ru.arb +++ b/res/values/strings_ru.arb @@ -650,6 +650,6 @@ "low_fee_alert": "В настоящее время вы используете низкий приоритет платы за сеть. Это может привести к длительному ожиданию, изменению ставок или отмене сделок. Мы рекомендуем установить более высокую плату для лучшего опыта.", "ignor": "Игнорировать", "use_suggested": "Использовать предложенный", - "do_not_share_warning_text" : "Не делитесь ими с кем-либо еще, в том числе со службой поддержки.\n\nОни украдут ваши деньги!", + "do_not_share_warning_text" : "Не сообщайте их никому, включая техподдержку.\n\nВаши средства могут и будут украдены!", "help": "помощь" } diff --git a/res/values/strings_uk.arb b/res/values/strings_uk.arb index 5e0f0d18a..f8669f528 100644 --- a/res/values/strings_uk.arb +++ b/res/values/strings_uk.arb @@ -649,6 +649,6 @@ "low_fee_alert": "Зараз ви використовуєте низький пріоритет плати за мережу. Це може спричинити тривале очікування, інший курс або скасування угод. Ми рекомендуємо встановити вищу плату для кращого досвіду.", "ignor": "Ігнорувати", "use_suggested": "Використати запропоноване", - "do_not_share_warning_text" : "Не повідомляйте їх нікому, включно зі службою підтримки.\n\nВони вкрадуть ваші гроші!", + "do_not_share_warning_text" : "Не діліться цим нікому, включно зі службою підтримки.\n\nВаші кошти можуть і будуть вкрадені!", "help": "допомога" } diff --git a/res/values/strings_zh.arb b/res/values/strings_zh.arb index c46d07d59..c586315e4 100644 --- a/res/values/strings_zh.arb +++ b/res/values/strings_zh.arb @@ -648,6 +648,6 @@ "low_fee_alert": "您当前正在使用低网络费用优先级。这可能会导致长时间等待、不同的费率或取消交易。我们建议设置更高的费用以获得更好的体验。", "ignor": "忽视", "use_suggested": "使用建议", - "do_not_share_warning_text" : "不要與其他任何人分享這些內容,包括支持。\n\n他們會偷你的錢!", + "do_not_share_warning_text" : "请勿与其他任何人分享这些信息,包括支持人员。\n\n您的资金可能而且将会被盗!", "help": "帮助" } From 9ce8a1944befb200a2afc2ab19ca7467ac479954 Mon Sep 17 00:00:00 2001 From: Serhii Date: Mon, 14 Nov 2022 22:50:07 +0200 Subject: [PATCH 05/20] fix empty containers --- lib/src/screens/send/widgets/send_card.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/src/screens/send/widgets/send_card.dart b/lib/src/screens/send/widgets/send_card.dart index 7e7194f88..384f4f2cc 100644 --- a/lib/src/screens/send/widgets/send_card.dart +++ b/lib/src/screens/send/widgets/send_card.dart @@ -332,8 +332,7 @@ class SendCardState extends State ], ), )), - sendViewModel.balanceViewModel.disableFiat ? - Container () : + if (sendViewModel.balanceViewModel.disableFiat) Padding( padding: const EdgeInsets.only(top: 20), child: BaseTextFormField( @@ -440,8 +439,9 @@ class SendCardState extends State Padding( padding: EdgeInsets.only(top: 5), - child: sendViewModel.balanceViewModel.disableFiat ? - Container () : Text(output + child: sendViewModel.balanceViewModel.disableFiat + ? const SizedBox(height: 14) + : Text(output .estimatedFeeFiatAmount + ' ' + sendViewModel From 92328c41029405800f9b18249debef54fbe404ef Mon Sep 17 00:00:00 2001 From: Serhii Date: Tue, 22 Nov 2022 19:33:24 +0200 Subject: [PATCH 06/20] move logic to viewmodels --- .../screens/exchange_trade/exchange_trade_page.dart | 12 ++++-------- lib/src/screens/send/send_page.dart | 8 ++------ .../exchange/exchange_trade_view_model.dart | 12 ++++++++++++ lib/view_model/send/send_view_model.dart | 10 ++++++++++ 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/lib/src/screens/exchange_trade/exchange_trade_page.dart b/lib/src/screens/exchange_trade/exchange_trade_page.dart index 4128fb9f2..001c13ba9 100644 --- a/lib/src/screens/exchange_trade/exchange_trade_page.dart +++ b/lib/src/screens/exchange_trade/exchange_trade_page.dart @@ -381,14 +381,10 @@ class ExchangeTradeState extends State { }); }, actionLeftButton: () => Navigator.of(context).pop(), - feeFiatAmount: widget.disableFiat ? '' - : widget.exchangeTradeViewModel.sendViewModel.pendingTransactionFeeFiatAmount - + ' ' + widget.exchangeTradeViewModel.sendViewModel.fiat.title, - fiatAmountValue: widget.disableFiat ? '' - : widget.exchangeTradeViewModel.sendViewModel - .pendingTransactionFiatAmount + - ' ' + - widget.exchangeTradeViewModel.sendViewModel.fiat.title, + feeFiatAmount: widget.exchangeTradeViewModel + .pendingTransactionFeeFiatAmountFormatted, + fiatAmountValue: widget.exchangeTradeViewModel + .pendingTransactionFiatAmountValueFormatted, outputs: widget.exchangeTradeViewModel.sendViewModel .outputs); }); diff --git a/lib/src/screens/send/send_page.dart b/lib/src/screens/send/send_page.dart index 8815d8c58..b0891c6e5 100644 --- a/lib/src/screens/send/send_page.dart +++ b/lib/src/screens/send/send_page.dart @@ -386,14 +386,10 @@ class SendPage extends BasePage { amount: S.of(context).send_amount, amountValue: sendViewModel.pendingTransaction!.amountFormatted, - fiatAmountValue: sendViewModel.balanceViewModel.disableFiat - ? '' : sendViewModel.pendingTransactionFiatAmount + - ' ' + sendViewModel.fiat.title, + fiatAmountValue: sendViewModel.pendingTransactionFiatAmountFormatted, fee: S.of(context).send_fee, feeValue: sendViewModel.pendingTransaction!.feeFormatted, - feeFiatAmount: sendViewModel.balanceViewModel.disableFiat - ? '' : sendViewModel.pendingTransactionFeeFiatAmount + - ' ' + sendViewModel.fiat.title, + feeFiatAmount: sendViewModel.pendingTransactionFeeFiatAmountFormatted, outputs: sendViewModel.outputs, rightButtonText: S.of(context).ok, leftButtonText: S.of(context).cancel, diff --git a/lib/view_model/exchange/exchange_trade_view_model.dart b/lib/view_model/exchange/exchange_trade_view_model.dart index 796397429..133b4a228 100644 --- a/lib/view_model/exchange/exchange_trade_view_model.dart +++ b/lib/view_model/exchange/exchange_trade_view_model.dart @@ -72,6 +72,18 @@ abstract class ExchangeTradeViewModelBase with Store { ? '\n\n' + S.current.xrp_extra_info : ''; + @computed + String get pendingTransactionFiatAmountValueFormatted => + sendViewModel.balanceViewModel.disableFiat + ? '' : sendViewModel.pendingTransactionFiatAmount + + ' ' + sendViewModel.fiat.title; + + @computed + String get pendingTransactionFeeFiatAmountFormatted => + sendViewModel.balanceViewModel.disableFiat + ? '' : sendViewModel.pendingTransactionFeeFiatAmount + + ' ' + sendViewModel.fiat.title; + @observable ObservableList items; diff --git a/lib/view_model/send/send_view_model.dart b/lib/view_model/send/send_view_model.dart index cdef6faba..fbfba2313 100644 --- a/lib/view_model/send/send_view_model.dart +++ b/lib/view_model/send/send_view_model.dart @@ -139,6 +139,16 @@ abstract class SendViewModelBase with Store { @computed String get balance => balanceViewModel.availableBalance ?? '0.0'; + @computed + String get pendingTransactionFiatAmountFormatted => + balanceViewModel.disableFiat ? '' : pendingTransactionFiatAmount + + ' ' + fiat.title; + + @computed + String get pendingTransactionFeeFiatAmountFormatted => + balanceViewModel.disableFiat ? '' : pendingTransactionFeeFiatAmount + + ' ' + fiat.title; + @computed bool get isReadyForSend => _wallet.syncStatus is SyncedSyncStatus; From 117a8beec403cd31d6570a576fdb533b4d270619 Mon Sep 17 00:00:00 2001 From: Omar Hatem Date: Tue, 6 Dec 2022 19:40:39 +0200 Subject: [PATCH 07/20] Fix localization generation error --- res/values/strings_de.arb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values/strings_de.arb b/res/values/strings_de.arb index e90803444..dd88cc042 100644 --- a/res/values/strings_de.arb +++ b/res/values/strings_de.arb @@ -662,5 +662,5 @@ "privacy_settings": "Datenschutzeinstellungen", "privacy": "Datenschutz", "display_settings": "Anzeigeeinstellungen", - "other_settings": "Andere Einstellungen", + "other_settings": "Andere Einstellungen" } From f4148e0989a00081e20ed3f08154a98e5460a5ec Mon Sep 17 00:00:00 2001 From: Serhii Date: Wed, 7 Dec 2022 01:38:36 +0200 Subject: [PATCH 08/20] [skip ci] rework UI for disable fiat mode --- lib/core/backup_service.dart | 7 ++++ lib/entities/default_settings_migration.dart | 18 ++++++++- lib/entities/fiat_api_mode.dart | 39 +++++++++++++++++++ lib/entities/preferences_key.dart | 2 +- lib/src/screens/send/widgets/send_card.dart | 2 +- lib/src/screens/settings/privacy_page.dart | 13 ++++++- lib/store/settings_store.dart | 24 ++++++------ .../dashboard/balance_view_model.dart | 4 +- .../settings/privacy_settings_view_model.dart | 7 ++++ 9 files changed, 98 insertions(+), 18 deletions(-) create mode 100644 lib/entities/fiat_api_mode.dart diff --git a/lib/core/backup_service.dart b/lib/core/backup_service.dart index 999b67120..46868cf1a 100644 --- a/lib/core/backup_service.dart +++ b/lib/core/backup_service.dart @@ -214,6 +214,7 @@ class BackupService { final currentBitcoinElectrumSererId = data[PreferencesKey.currentBitcoinElectrumSererIdKey] as int?; final currentLanguageCode = data[PreferencesKey.currentLanguageCode] as String?; final displayActionListMode = data[PreferencesKey.displayActionListModeKey] as int?; + final fiatApiMode = data[PreferencesKey.currentFiatApiModeKey] as int?; final currentPinLength = data[PreferencesKey.currentPinLength] as int?; final currentTheme = data[PreferencesKey.currentTheme] as int?; final currentDefaultSettingsMigrationVersion = data[PreferencesKey.currentDefaultSettingsMigrationVersion] as int?; @@ -266,6 +267,10 @@ class BackupService { await _sharedPreferences.setInt(PreferencesKey.displayActionListModeKey, displayActionListMode); + if (fiatApiMode != null) + await _sharedPreferences.setInt(PreferencesKey.currentFiatApiModeKey, + fiatApiMode); + if (currentPinLength != null) await _sharedPreferences.setInt(PreferencesKey.currentPinLength, currentPinLength); @@ -427,6 +432,8 @@ class BackupService { _sharedPreferences.getInt(PreferencesKey.bitcoinTransactionPriority), PreferencesKey.moneroTransactionPriority: _sharedPreferences.getInt(PreferencesKey.moneroTransactionPriority), + PreferencesKey.currentFiatApiModeKey: + _sharedPreferences.getInt(PreferencesKey.currentFiatApiModeKey), }; return json.encode(preferences); diff --git a/lib/entities/default_settings_migration.dart b/lib/entities/default_settings_migration.dart index 40d26b93f..d65b4401d 100644 --- a/lib/entities/default_settings_migration.dart +++ b/lib/entities/default_settings_migration.dart @@ -20,6 +20,8 @@ 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'; @@ -61,7 +63,9 @@ Future defaultSettingsMigration( await sharedPreferences.setInt( PreferencesKey.currentBalanceDisplayModeKey, BalanceDisplayMode.availableBalance.raw); - await sharedPreferences.setBool('disable_fiat', false); + await sharedPreferences.setInt( + PreferencesKey.currentFiatApiModeKey, + FiatApiMode.enabled.raw); await sharedPreferences.setBool('save_recipient_address', true); await resetToDefault(nodes); await changeMoneroCurrentNodeToDefault( @@ -140,6 +144,10 @@ Future defaultSettingsMigration( await addOnionNode(nodes); break; + case 19: + await updateFiatApiModes(sharedPreferences); + break; + default: break; } @@ -350,6 +358,14 @@ Future updateDisplayModes(SharedPreferences sharedPreferences) async { PreferencesKey.currentBalanceDisplayModeKey, balanceDisplayMode); } +Future updateFiatApiModes(SharedPreferences sharedPreferences) async { + final currentFiatApiMode = + sharedPreferences.getInt(PreferencesKey.currentFiatApiModeKey) ?? -1; + final fiatApiMode = currentFiatApiMode < 1 ? 2 : 1; + await sharedPreferences.setInt( + PreferencesKey.currentFiatApiModeKey, fiatApiMode); +} + Future generateBackupPassword(FlutterSecureStorage secureStorage) async { final key = generateStoreKeyFor(key: SecretStoreKey.backupPassword); diff --git a/lib/entities/fiat_api_mode.dart b/lib/entities/fiat_api_mode.dart new file mode 100644 index 000000000..615784986 --- /dev/null +++ b/lib/entities/fiat_api_mode.dart @@ -0,0 +1,39 @@ +import 'package:cake_wallet/generated/i18n.dart'; +import 'package:cw_core/enumerable_item.dart'; + +class FiatApiMode extends EnumerableItem with Serializable { + const FiatApiMode({required String title, required int raw}) : super(title: title, raw: raw); + + static const all = [FiatApiMode.enabled, FiatApiMode.torOnly, FiatApiMode.disabled]; + + static const enabled = FiatApiMode(raw: 0, title: 'Enabled'); + static const torOnly = FiatApiMode(raw: 1, title: 'Tor only'); + static const disabled = FiatApiMode(raw: 2, title: 'Disabled'); + + static FiatApiMode deserialize({required int raw}) { + switch (raw) { + case 0: + return enabled; + case 1: + return torOnly; + case 2: + return disabled; + default: + throw Exception('Unexpected token: $raw for FiatApiMode deserialize'); + } + } + + @override + String toString() { + switch (this) { + case FiatApiMode.enabled: + return 'enable'; + case FiatApiMode.torOnly: + return 'torOnly'; + case FiatApiMode.disabled: + return 'disable'; + default: + return ''; + } + } +} diff --git a/lib/entities/preferences_key.dart b/lib/entities/preferences_key.dart index 0df7981bd..7d1d75000 100644 --- a/lib/entities/preferences_key.dart +++ b/lib/entities/preferences_key.dart @@ -9,7 +9,7 @@ class PreferencesKey { static const currentTransactionPriorityKeyLegacy = 'current_fee_priority'; static const currentBalanceDisplayModeKey = 'current_balance_display_mode'; static const shouldSaveRecipientAddressKey = 'save_recipient_address'; - static const shouldDisableFiatKey = 'disable_fiat'; + static const currentFiatApiModeKey = 'current_fiat_api_mode'; static const allowBiometricalAuthenticationKey = 'allow_biometrical_authentication'; static const disableExchangeKey = 'disable_exchange'; diff --git a/lib/src/screens/send/widgets/send_card.dart b/lib/src/screens/send/widgets/send_card.dart index 60da5a8ea..503494c92 100644 --- a/lib/src/screens/send/widgets/send_card.dart +++ b/lib/src/screens/send/widgets/send_card.dart @@ -331,7 +331,7 @@ class SendCardState extends State ], ), )), - if (sendViewModel.balanceViewModel.disableFiat) + if (!sendViewModel.balanceViewModel.disableFiat) Padding( padding: const EdgeInsets.only(top: 20), child: BaseTextFormField( diff --git a/lib/src/screens/settings/privacy_page.dart b/lib/src/screens/settings/privacy_page.dart index 128d864f4..34957fa4a 100644 --- a/lib/src/screens/settings/privacy_page.dart +++ b/lib/src/screens/settings/privacy_page.dart @@ -1,9 +1,12 @@ 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); @@ -18,10 +21,17 @@ class PrivacyPage extends BasePage { return Container( padding: EdgeInsets.only(top: 10), child: Observer(builder: (_) { - return Observer(builder: (_) { return Column( mainAxisSize: MainAxisSize.min, children: [ + SettingsChoicesCell( + ChoicesListItem( + title: 'Fiat api', + items: FiatApiMode.all, + selectedItem: _privacySettingsViewModel.fiatApiMode, + onItemSelected: (FiatApiMode mode) => _privacySettingsViewModel.setFiatMode(mode), + ), + ), SettingsSwitcherCell( title: S.current.disable_exchange, value: _privacySettingsViewModel.disableExchange, @@ -36,7 +46,6 @@ class PrivacyPage extends BasePage { }) ], ); - }); }), ); } diff --git a/lib/store/settings_store.dart b/lib/store/settings_store.dart index 1f49be479..419b03e49 100644 --- a/lib/store/settings_store.dart +++ b/lib/store/settings_store.dart @@ -17,8 +17,10 @@ import 'package:cake_wallet/entities/fiat_currency.dart'; import 'package:cw_core/node.dart'; import 'package:cake_wallet/monero/monero.dart'; import 'package:cake_wallet/entities/action_list_display_mode.dart'; +import 'package:cake_wallet/entities/fiat_api_mode.dart'; import 'package:cake_wallet/.secrets.g.dart' as secrets; + part 'settings_store.g.dart'; class SettingsStore = SettingsStoreBase with _$SettingsStore; @@ -29,7 +31,7 @@ abstract class SettingsStoreBase with Store { required FiatCurrency initialFiatCurrency, required BalanceDisplayMode initialBalanceDisplayMode, required bool initialSaveRecipientAddress, - required bool initialDisableFiat, + required FiatApiMode initialFiatMode, required bool initialAllowBiometricalAuthentication, required bool initialExchangeEnabled, required ThemeBase initialTheme, @@ -48,7 +50,7 @@ abstract class SettingsStoreBase with Store { fiatCurrency = initialFiatCurrency, balanceDisplayMode = initialBalanceDisplayMode, shouldSaveRecipientAddress = initialSaveRecipientAddress, - shouldDisableFiat = initialDisableFiat, + fiatApiMode = initialFiatMode, allowBiometricalAuthentication = initialAllowBiometricalAuthentication, disableExchange = initialExchangeEnabled, currentTheme = initialTheme, @@ -92,10 +94,9 @@ abstract class SettingsStoreBase with Store { shouldSaveRecipientAddress)); reaction( - (_) => shouldDisableFiat, - (bool shouldDisableFiat) => sharedPreferences.setBool( - PreferencesKey.shouldDisableFiatKey, - shouldDisableFiat)); + (_) => fiatApiMode, + (FiatApiMode mode) => sharedPreferences.setInt( + PreferencesKey.currentFiatApiModeKey, mode.serialize())); reaction( (_) => currentTheme, @@ -148,10 +149,10 @@ abstract class SettingsStoreBase with Store { BalanceDisplayMode balanceDisplayMode; @observable - bool shouldSaveRecipientAddress; + FiatApiMode fiatApiMode; @observable - bool shouldDisableFiat; + bool shouldSaveRecipientAddress; @observable bool allowBiometricalAuthentication; @@ -234,8 +235,9 @@ abstract class SettingsStoreBase with Store { // FIX-ME: Check for which default value we should have here final shouldSaveRecipientAddress = sharedPreferences.getBool(PreferencesKey.shouldSaveRecipientAddressKey) ?? false; - final shouldDisableFiat = - sharedPreferences.getBool(PreferencesKey.shouldDisableFiatKey) ?? false; + final currentFiatApiMode = FiatApiMode.deserialize( + raw: sharedPreferences + .getInt(PreferencesKey.currentFiatApiModeKey)!); final allowBiometricalAuthentication = sharedPreferences .getBool(PreferencesKey.allowBiometricalAuthenticationKey) ?? false; @@ -303,7 +305,7 @@ abstract class SettingsStoreBase with Store { initialFiatCurrency: currentFiatCurrency, initialBalanceDisplayMode: currentBalanceDisplayMode, initialSaveRecipientAddress: shouldSaveRecipientAddress, - initialDisableFiat: shouldDisableFiat, + initialFiatMode: currentFiatApiMode, initialAllowBiometricalAuthentication: allowBiometricalAuthentication, initialExchangeEnabled: disableExchange, initialTheme: savedTheme, diff --git a/lib/view_model/dashboard/balance_view_model.dart b/lib/view_model/dashboard/balance_view_model.dart index 40502bb84..6728859da 100644 --- a/lib/view_model/dashboard/balance_view_model.dart +++ b/lib/view_model/dashboard/balance_view_model.dart @@ -1,3 +1,4 @@ +import 'package:cake_wallet/entities/fiat_api_mode.dart'; import 'package:cw_core/transaction_history.dart'; import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/balance.dart'; @@ -10,7 +11,6 @@ import 'package:cake_wallet/entities/calculate_fiat_amount.dart'; import 'package:cake_wallet/store/app_store.dart'; import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart'; -import 'package:flutter/cupertino.dart'; import 'package:mobx/mobx.dart'; part 'balance_view_model.g.dart'; @@ -72,7 +72,7 @@ abstract class BalanceViewModelBase with Store { BalanceDisplayMode get savedDisplayMode => settingsStore.balanceDisplayMode; @computed - bool get disableFiat => settingsStore.shouldDisableFiat; + bool get disableFiat => settingsStore.fiatApiMode == FiatApiMode.disabled; @computed String get asset { diff --git a/lib/view_model/settings/privacy_settings_view_model.dart b/lib/view_model/settings/privacy_settings_view_model.dart index 88311bf1f..2d8418d11 100644 --- a/lib/view_model/settings/privacy_settings_view_model.dart +++ b/lib/view_model/settings/privacy_settings_view_model.dart @@ -1,5 +1,6 @@ import 'package:cake_wallet/store/settings_store.dart'; import 'package:mobx/mobx.dart'; +import 'package:cake_wallet/entities/fiat_api_mode.dart'; part 'privacy_settings_view_model.g.dart'; @@ -16,9 +17,15 @@ abstract class PrivacySettingsViewModelBase with Store { @computed bool get shouldSaveRecipientAddress => _settingsStore.shouldSaveRecipientAddress; + @computed + FiatApiMode get fiatApiMode => _settingsStore.fiatApiMode; + @action void setShouldSaveRecipientAddress(bool value) => _settingsStore.shouldSaveRecipientAddress = value; @action void setEnableExchange(bool value) => _settingsStore.disableExchange = value; + + @action + void setFiatMode(FiatApiMode mode) => _settingsStore.fiatApiMode = mode; } From 228e157b3992db2efbba68fe5ef4f820422d5772 Mon Sep 17 00:00:00 2001 From: Serhii Date: Wed, 7 Dec 2022 14:04:14 +0200 Subject: [PATCH 09/20] [skip ci] Update localization --- lib/entities/fiat_api_mode.dart | 6 +++--- lib/reactions/fiat_rate_update.dart | 3 ++- lib/src/screens/settings/privacy_page.dart | 2 +- res/values/strings_de.arb | 7 +++++-- res/values/strings_en.arb | 7 +++++-- res/values/strings_es.arb | 7 +++++-- res/values/strings_fr.arb | 7 +++++-- res/values/strings_hi.arb | 7 +++++-- res/values/strings_hr.arb | 7 +++++-- res/values/strings_it.arb | 7 +++++-- res/values/strings_ja.arb | 7 +++++-- res/values/strings_ko.arb | 7 +++++-- res/values/strings_nl.arb | 7 +++++-- res/values/strings_pl.arb | 7 +++++-- res/values/strings_pt.arb | 7 +++++-- res/values/strings_ru.arb | 7 +++++-- res/values/strings_uk.arb | 7 +++++-- res/values/strings_zh.arb | 7 +++++-- 18 files changed, 81 insertions(+), 35 deletions(-) diff --git a/lib/entities/fiat_api_mode.dart b/lib/entities/fiat_api_mode.dart index 615784986..bb16ca5a4 100644 --- a/lib/entities/fiat_api_mode.dart +++ b/lib/entities/fiat_api_mode.dart @@ -27,11 +27,11 @@ class FiatApiMode extends EnumerableItem with Serializable { String toString() { switch (this) { case FiatApiMode.enabled: - return 'enable'; + return S.current.enabled; case FiatApiMode.torOnly: - return 'torOnly'; + return S.current.tor_only; case FiatApiMode.disabled: - return 'disable'; + return S.current.disabled; default: return ''; } diff --git a/lib/reactions/fiat_rate_update.dart b/lib/reactions/fiat_rate_update.dart index fb40a26e3..ff10a176c 100644 --- a/lib/reactions/fiat_rate_update.dart +++ b/lib/reactions/fiat_rate_update.dart @@ -1,5 +1,6 @@ import 'dart:async'; import 'package:cake_wallet/core/fiat_conversion_service.dart'; +import 'package:cake_wallet/entities/fiat_api_mode.dart'; import 'package:cake_wallet/entities/update_haven_rate.dart'; import 'package:cake_wallet/store/app_store.dart'; import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart'; @@ -28,7 +29,7 @@ Future startFiatRateUpdate(AppStore appStore, SettingsStore settingsStore, await updateHavenRate(fiatConversionStore); } else { fiatConversionStore.prices[appStore.wallet!.currency] = - settingsStore.shouldDisableFiat ? 0.0 + settingsStore.fiatApiMode == FiatApiMode.disabled ? 0.0 : await FiatConversionService.fetchPrice( appStore.wallet!.currency, settingsStore.fiatCurrency); } diff --git a/lib/src/screens/settings/privacy_page.dart b/lib/src/screens/settings/privacy_page.dart index 34957fa4a..a0fc280b9 100644 --- a/lib/src/screens/settings/privacy_page.dart +++ b/lib/src/screens/settings/privacy_page.dart @@ -26,7 +26,7 @@ class PrivacyPage extends BasePage { children: [ SettingsChoicesCell( ChoicesListItem( - title: 'Fiat api', + title: S.current.fiat_api, items: FiatApiMode.all, selectedItem: _privacySettingsViewModel.fiatApiMode, onItemSelected: (FiatApiMode mode) => _privacySettingsViewModel.setFiatMode(mode), diff --git a/res/values/strings_de.arb b/res/values/strings_de.arb index dd88cc042..ecbd3838e 100644 --- a/res/values/strings_de.arb +++ b/res/values/strings_de.arb @@ -654,7 +654,7 @@ "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", - "disable_fiat": "Fiat deaktivieren", + "fiat_api": "Fiat API", "disable_exchange": "Exchange deaktivieren", "connection_sync": "Verbindung und Synchronisierung", "security_and_backup": "Sicherheit und Datensicherung", @@ -662,5 +662,8 @@ "privacy_settings": "Datenschutzeinstellungen", "privacy": "Datenschutz", "display_settings": "Anzeigeeinstellungen", - "other_settings": "Andere Einstellungen" + "other_settings": "Andere Einstellungen", + "disabled": "Deaktiviert", + "enabled": "Ermöglicht", + "tor_only": "Nur Tor" } diff --git a/res/values/strings_en.arb b/res/values/strings_en.arb index 753ad18a9..c6d71a2b1 100644 --- a/res/values/strings_en.arb +++ b/res/values/strings_en.arb @@ -654,7 +654,7 @@ "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", - "disable_fiat": "Disable fiat", + "fiat_api": "Fiat API", "disable_exchange": "Disable exchange", "connection_sync": "Connection and sync", "security_and_backup": "Security and backup", @@ -662,5 +662,8 @@ "privacy_settings": "Privacy settings", "privacy": "Privacy", "display_settings": "Display settings", - "other_settings": "Other settings" + "other_settings": "Other settings", + "disabled": "Disabled", + "enabled": "Enabled", + "tor_only": "Tor only" } diff --git a/res/values/strings_es.arb b/res/values/strings_es.arb index 6efcb85a0..09878ede1 100644 --- a/res/values/strings_es.arb +++ b/res/values/strings_es.arb @@ -654,7 +654,7 @@ "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", - "disable_fiat": "Deshabilitar fiat", + "fiat_api": "Fiat API", "disable_exchange": "Deshabilitar intercambio", "connection_sync": "Conexión y sincronización", "security_and_backup": "Seguridad y respaldo", @@ -662,5 +662,8 @@ "privacy_settings": "Configuración de privacidad", "privacy": "Privacidad", "display_settings": "Configuración de pantalla", - "other_settings": "Otras configuraciones" + "other_settings": "Otras configuraciones", + "disabled": "Desactivado", + "enabled": "Activado", + "tor_only": "solo Tor" } diff --git a/res/values/strings_fr.arb b/res/values/strings_fr.arb index aefe68b96..66f60af81 100644 --- a/res/values/strings_fr.arb +++ b/res/values/strings_fr.arb @@ -652,7 +652,7 @@ "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", - "disable_fiat": "Désactiver fiat", + "fiat_api": "Fiat API", "disable_exchange": "Désactiver l'échange", "connection_sync": "Connexion et synchronisation", "security_and_backup": "Sécurité et sauvegarde", @@ -660,5 +660,8 @@ "privacy_settings": "Paramètres de confidentialité", "privacy": "Confidentialité", "display_settings": "Paramètres d'affichage", - "other_settings": "Autres paramètres" + "other_settings": "Autres paramètres", + "disabled": "Handicapé", + "enabled": "Activé", + "tor_only": "Tor uniquement" } diff --git a/res/values/strings_hi.arb b/res/values/strings_hi.arb index 52b46ee60..a25b649c3 100644 --- a/res/values/strings_hi.arb +++ b/res/values/strings_hi.arb @@ -655,12 +655,15 @@ "do_not_share_warning_text" : "इन्हें समर्थन सहित किसी और के साथ साझा न करें।\n\nवे आपका पैसा चुरा लेंगे!", "help": "मदद करना", "disable_fiat": "िएट अक्षम करें", - "disable_exchange": "एक्सचेंज अक्षम करें", + "fiat_api": "फिएट पैसे API", "connection_sync": "कनेक्शन और सिंक", "security_and_backup": "सुरक्षा और बैकअप", "create_backup": "बैकअप बनाएँ", "privacy_settings": "गोपनीयता सेटिंग्स", "privacy": "गोपनीयता", "display_settings": "प्रदर्शन सेटिंग्स", - "other_settings": "अन्य सेटिंग्स" + "other_settings": "अन्य सेटिंग्स", + "disabled": "अक्षम", + "enabled": "सक्रिय", + "tor_only": "Tor केवल" } diff --git a/res/values/strings_hr.arb b/res/values/strings_hr.arb index f2181bca0..e7e0ff1e4 100644 --- a/res/values/strings_hr.arb +++ b/res/values/strings_hr.arb @@ -654,7 +654,7 @@ "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", - "disable_fiat": "Isključi, fiat", + "fiat_api": "Fiat API", "disable_exchange": "Onemogući exchange", "connection_sync": "Povezivanje i sinkronizacija", "security_and_backup": "Sigurnost i sigurnosna kopija", @@ -662,5 +662,8 @@ "privacy_settings": "Postavke privatnosti", "privacy": "Privatnost", "display_settings": "Postavke zaslona", - "other_settings": "Ostale postavke" + "other_settings": "Ostale postavke", + "disabled": "Onemogućeno", + "enabled": "Omogućeno", + "tor_only": "Samo Tor" } diff --git a/res/values/strings_it.arb b/res/values/strings_it.arb index 1ec0a9d81..80a0ea1fd 100644 --- a/res/values/strings_it.arb +++ b/res/values/strings_it.arb @@ -654,7 +654,7 @@ "use_suggested": "Usa suggerito", "do_not_share_warning_text" : "Non condividerli con nessun altro, incluso il supporto.\n\nTi ruberanno i soldi!", "help": "aiuto", - "disable_fiat": "Disabilita fiat", + "fiat_api": "Fiat API", "disable_exchange": "Disabilita scambio", "connection_sync": "Connessione e sincronizzazione", "security_and_backup": "Sicurezza e backup", @@ -662,5 +662,8 @@ "privacy_settings": "Impostazioni privacy", "privacy": "Privacy", "display_settings": "Impostazioni di visualizzazione", - "other_settings": "Altre impostazioni" + "other_settings": "Altre impostazioni", + "disabled": "Disabilitato", + "enabled": "Abilitato", + "tor_only": "Solo Tor" } diff --git a/res/values/strings_ja.arb b/res/values/strings_ja.arb index 6fde3fc91..b38066916 100644 --- a/res/values/strings_ja.arb +++ b/res/values/strings_ja.arb @@ -654,7 +654,7 @@ "use_suggested": "推奨を使用", "do_not_share_warning_text" : "サポートを含め、これらを他の誰とも共有しないでください。\n\n彼らはあなたのお金を盗みます!", "help": "ヘルプ", - "disable_fiat": "フィアットを無効にする", + "fiat_api": "不換紙幣 API", "disable_exchange": "交換を無効にする", "connection_sync": "接続と同期", "security_and_backup": "セキュリティとバックアップ", @@ -662,5 +662,8 @@ "privacy_settings": "プライバシー設定", "privacy": "プライバシー", "display_settings": "表示設定", - "other_settings": "その他の設定" + "other_settings": "その他の設定", + "disabled": "無効", + "enabled": "有効", + "tor_only": "Torのみ" } diff --git a/res/values/strings_ko.arb b/res/values/strings_ko.arb index 4f2e7da5e..e4915cbb0 100644 --- a/res/values/strings_ko.arb +++ b/res/values/strings_ko.arb @@ -654,7 +654,7 @@ "use_suggested": "추천 사용", "do_not_share_warning_text" : "지원을 포함하여 다른 사람과 이러한 정보를 공유하지 마십시오.\n\n그들은 당신의 돈을 훔칠 것입니다!", "help": "돕다", - "disable_fiat": "법정화폐 비활성화", + "fiat_api": "명목 화폐 API", "disable_exchange": "교환 비활성화", "connection_sync": "연결 및 동기화", "security_and_backup": "보안 및 백업", @@ -662,5 +662,8 @@ "privacy_settings": "개인정보 설정", "privacy": "프라이버시", "display_settings": "디스플레이 설정", - "other_settings": "기타 설정" + "other_settings": "기타 설정", + "disabled": "장애가 있는", + "enabled": "사용", + "tor_only": "Tor 뿐" } diff --git a/res/values/strings_nl.arb b/res/values/strings_nl.arb index 25e0e1e7a..59a816602 100644 --- a/res/values/strings_nl.arb +++ b/res/values/strings_nl.arb @@ -654,7 +654,7 @@ "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", - "disable_fiat": "법정화폐 비활성화", + "fiat_api": "Fiat API", "disable_exchange": "Uitwisseling uitschakelen", "connection_sync": "Verbinding en synchronisatie", "security_and_backup": "Beveiliging en back-up", @@ -662,5 +662,8 @@ "privacy_settings": "Privacy-instellingen", "privacy": "Privacy", "display_settings": "Weergave-instellingen", - "other_settings": "Andere instellingen" + "other_settings": "Andere instellingen", + "disabled": "Gehandicapt", + "enabled": "Ingeschakeld", + "tor_only": "Alleen Tor" } diff --git a/res/values/strings_pl.arb b/res/values/strings_pl.arb index db3353bad..a2dc5c8fd 100644 --- a/res/values/strings_pl.arb +++ b/res/values/strings_pl.arb @@ -654,7 +654,7 @@ "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", - "disable_fiat": "Wyłącz fiat", + "fiat_api": "API Fiata", "disable_exchange": "Wyłącz wymianę", "connection_sync": "Połączenie i synchronizacja", "security_and_backup": "Bezpieczeństwo i kopia zapasowa", @@ -662,5 +662,8 @@ "privacy_settings": "Ustawienia prywatności", "privacy": "Prywatność", "display_settings": "Ustawienia wyświetlania", - "other_settings": "Inne ustawienia" + "other_settings": "Inne ustawienia", + "disabled": "Wyłączone", + "enabled": "Włączony", + "tor_only": "Tylko Tor" } diff --git a/res/values/strings_pt.arb b/res/values/strings_pt.arb index 692dd118a..f61ac5e67 100644 --- a/res/values/strings_pt.arb +++ b/res/values/strings_pt.arb @@ -653,7 +653,7 @@ "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", - "disable_fiat": "Desativar fiat", + "fiat_api": "API da Fiat", "disable_exchange": "Desativar troca", "connection_sync": "Conexão e sincronização", "security_and_backup": "Segurança e backup", @@ -661,5 +661,8 @@ "privacy_settings": "Configurações de privacidade", "privacy": "Privacidade", "display_settings": "Configurações de exibição", - "other_settings": "Outras configurações" + "other_settings": "Outras configurações", + "disabled": "Desabilitado", + "enabled": "Habilitado", + "tor_only": "Tor apenas" } diff --git a/res/values/strings_ru.arb b/res/values/strings_ru.arb index e6c10bd2b..c44e9af35 100644 --- a/res/values/strings_ru.arb +++ b/res/values/strings_ru.arb @@ -654,7 +654,7 @@ "use_suggested": "Использовать предложенный", "do_not_share_warning_text" : "Не делитесь ими с кем-либо еще, в том числе со службой поддержки.\n\nОни украдут ваши деньги!", "help": "помощь", - "disable_fiat": "Отключить фиат", + "fiat_api": "Фиат API", "disable_exchange": "Отключить обмен", "connection_sync": "Подключение и синхронизация", "security_and_backup": "Безопасность и резервное копирование", @@ -662,5 +662,8 @@ "privacy_settings": "Настройки конфиденциальности", "privacy": "Конфиденциальность", "display_settings": "Настройки отображения", - "other_settings": "Другие настройки" + "other_settings": "Другие настройки", + "disabled": "Отключено", + "enabled": "Включено", + "tor_only": "Только Tor" } diff --git a/res/values/strings_uk.arb b/res/values/strings_uk.arb index 3013dda6a..a766641d7 100644 --- a/res/values/strings_uk.arb +++ b/res/values/strings_uk.arb @@ -653,7 +653,7 @@ "use_suggested": "Використати запропоноване", "do_not_share_warning_text" : "Не повідомляйте їх нікому, включно зі службою підтримки.\n\nВони вкрадуть ваші гроші!", "help": "допомога", - "disable_fiat": "Вимкнути фиат", + "fiat_api": "Фіат API", "disable_exchange": "Вимкнути exchange", "connection_sync": "Підключення та синхронізація", "security_and_backup": "Безпека та резервне копіювання", @@ -661,6 +661,9 @@ "privacy_settings": "Налаштування конфіденційності", "privacy": "Конфіденційність", "display_settings": "Налаштування дисплея", - "other_settings": "Інші налаштування" + "other_settings": "Інші налаштування", + "disabled": "Вимкнено", + "enabled": "Увімкнено", + "tor_only": "Тільки Tor" } diff --git a/res/values/strings_zh.arb b/res/values/strings_zh.arb index a82a3ee9d..ae5ffbea5 100644 --- a/res/values/strings_zh.arb +++ b/res/values/strings_zh.arb @@ -652,7 +652,7 @@ "use_suggested": "使用建议", "do_not_share_warning_text" : "不要與其他任何人分享這些內容,包括支持。\n\n他們會偷你的錢!", "help": "帮助", - "disable_fiat": "禁用法令", + "fiat_api": "法币API", "disable_exchange": "禁用交换", "connection_sync": "连接和同步", "security_and_backup": "安全和备份", @@ -660,5 +660,8 @@ "privacy_settings": "隐私设置", "privacy":"隐私", "display_settings": "显示设置", - "other_settings": "其他设置" + "other_settings": "其他设置", + "disabled": "禁用", + "enabled": "启用", + "tor_only": "仅限 Tor" } From 37ca7957560c6b30efa717bd990152cd2aeda867 Mon Sep 17 00:00:00 2001 From: Serhii Date: Wed, 7 Dec 2022 15:31:33 +0200 Subject: [PATCH 10/20] [skip ci] change fiat api UI to swich mode --- lib/src/screens/settings/privacy_page.dart | 12 +++++------- .../settings/privacy_settings_view_model.dart | 11 +++++++++-- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/src/screens/settings/privacy_page.dart b/lib/src/screens/settings/privacy_page.dart index a0fc280b9..c779eb316 100644 --- a/lib/src/screens/settings/privacy_page.dart +++ b/lib/src/screens/settings/privacy_page.dart @@ -24,14 +24,12 @@ class PrivacyPage extends BasePage { return Column( mainAxisSize: MainAxisSize.min, children: [ - SettingsChoicesCell( - ChoicesListItem( + SettingsSwitcherCell( title: S.current.fiat_api, - items: FiatApiMode.all, - selectedItem: _privacySettingsViewModel.fiatApiMode, - onItemSelected: (FiatApiMode mode) => _privacySettingsViewModel.setFiatMode(mode), - ), - ), + value: _privacySettingsViewModel.fiatApiMode, + onValueChange: (BuildContext context, bool value) { + _privacySettingsViewModel.setFiatMode(value); + }), SettingsSwitcherCell( title: S.current.disable_exchange, value: _privacySettingsViewModel.disableExchange, diff --git a/lib/view_model/settings/privacy_settings_view_model.dart b/lib/view_model/settings/privacy_settings_view_model.dart index 2d8418d11..b5c58a1b7 100644 --- a/lib/view_model/settings/privacy_settings_view_model.dart +++ b/lib/view_model/settings/privacy_settings_view_model.dart @@ -18,7 +18,7 @@ abstract class PrivacySettingsViewModelBase with Store { bool get shouldSaveRecipientAddress => _settingsStore.shouldSaveRecipientAddress; @computed - FiatApiMode get fiatApiMode => _settingsStore.fiatApiMode; + bool get fiatApiMode => _settingsStore.fiatApiMode == FiatApiMode.disabled; @action void setShouldSaveRecipientAddress(bool value) => _settingsStore.shouldSaveRecipientAddress = value; @@ -27,5 +27,12 @@ abstract class PrivacySettingsViewModelBase with Store { void setEnableExchange(bool value) => _settingsStore.disableExchange = value; @action - void setFiatMode(FiatApiMode mode) => _settingsStore.fiatApiMode = mode; + void setFiatMode(bool value) { + if (value) { + _settingsStore.fiatApiMode = FiatApiMode.disabled; + return; + } + _settingsStore.fiatApiMode = FiatApiMode.enabled; + } + } From 55b37164dc7149875f68dba11738debdc67d4291 Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Wed, 7 Dec 2022 22:07:32 +0200 Subject: [PATCH 11/20] - Make getters to ease attribute access - Add the old 'disable_fiat' translation - rename getters to be more bool like names --- lib/entities/default_settings_migration.dart | 17 ----------------- .../dashboard/widgets/transactions_page.dart | 2 +- .../exchange_trade/exchange_trade_page.dart | 5 +---- lib/src/screens/send/widgets/send_card.dart | 6 +++--- lib/src/screens/settings/privacy_page.dart | 7 ++----- lib/store/settings_store.dart | 2 +- .../dashboard/balance_view_model.dart | 10 +++++----- .../exchange/exchange_trade_view_model.dart | 4 ++-- lib/view_model/send/send_view_model.dart | 7 +++++-- .../settings/privacy_settings_view_model.dart | 2 +- res/values/strings_de.arb | 3 ++- res/values/strings_en.arb | 3 ++- res/values/strings_es.arb | 3 ++- res/values/strings_fr.arb | 3 ++- res/values/strings_hi.arb | 3 ++- res/values/strings_hr.arb | 3 ++- res/values/strings_it.arb | 3 ++- res/values/strings_ja.arb | 3 ++- res/values/strings_ko.arb | 3 ++- res/values/strings_nl.arb | 3 ++- res/values/strings_pl.arb | 3 ++- res/values/strings_pt.arb | 3 ++- res/values/strings_ru.arb | 3 ++- res/values/strings_uk.arb | 3 ++- res/values/strings_zh.arb | 3 ++- 25 files changed, 51 insertions(+), 56 deletions(-) diff --git a/lib/entities/default_settings_migration.dart b/lib/entities/default_settings_migration.dart index d65b4401d..9aff05500 100644 --- a/lib/entities/default_settings_migration.dart +++ b/lib/entities/default_settings_migration.dart @@ -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 updateDisplayModes(SharedPreferences sharedPreferences) async { PreferencesKey.currentBalanceDisplayModeKey, balanceDisplayMode); } -Future updateFiatApiModes(SharedPreferences sharedPreferences) async { - final currentFiatApiMode = - sharedPreferences.getInt(PreferencesKey.currentFiatApiModeKey) ?? -1; - final fiatApiMode = currentFiatApiMode < 1 ? 2 : 1; - await sharedPreferences.setInt( - PreferencesKey.currentFiatApiModeKey, fiatApiMode); -} - Future generateBackupPassword(FlutterSecureStorage secureStorage) async { final key = generateStoreKeyFor(key: SecretStoreKey.backupPassword); diff --git a/lib/src/screens/dashboard/widgets/transactions_page.dart b/lib/src/screens/dashboard/widgets/transactions_page.dart index 9e09bae8c..64f02c73c 100644 --- a/lib/src/screens/dashboard/widgets/transactions_page.dart +++ b/lib/src/screens/dashboard/widgets/transactions_page.dart @@ -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)); } diff --git a/lib/src/screens/exchange_trade/exchange_trade_page.dart b/lib/src/screens/exchange_trade/exchange_trade_page.dart index 001c13ba9..7c9fc1be7 100644 --- a/lib/src/screens/exchange_trade/exchange_trade_page.dart +++ b/lib/src/screens/exchange_trade/exchange_trade_page.dart @@ -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(); diff --git a/lib/src/screens/send/widgets/send_card.dart b/lib/src/screens/send/widgets/send_card.dart index 503494c92..261f5dde5 100644 --- a/lib/src/screens/send/widgets/send_card.dart +++ b/lib/src/screens/send/widgets/send_card.dart @@ -331,8 +331,8 @@ class SendCardState extends State ], ), )), - 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 Padding( padding: EdgeInsets.only(top: 5), - child: sendViewModel.balanceViewModel.disableFiat + child: sendViewModel.isFiatDisabled ? const SizedBox(height: 14) : Text(output .estimatedFeeFiatAmount diff --git a/lib/src/screens/settings/privacy_page.dart b/lib/src/screens/settings/privacy_page.dart index c779eb316..2f15cc225 100644 --- a/lib/src/screens/settings/privacy_page.dart +++ b/lib/src/screens/settings/privacy_page.dart @@ -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); }), diff --git a/lib/store/settings_store.dart b/lib/store/settings_store.dart index 419b03e49..237846495 100644 --- a/lib/store/settings_store.dart +++ b/lib/store/settings_store.dart @@ -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; diff --git a/lib/view_model/dashboard/balance_view_model.dart b/lib/view_model/dashboard/balance_view_model.dart index 6728859da..33fe01ba9 100644 --- a/lib/view_model/dashboard/balance_view_model.dart +++ b/lib/view_model/dashboard/balance_view_model.dart @@ -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, diff --git a/lib/view_model/exchange/exchange_trade_view_model.dart b/lib/view_model/exchange/exchange_trade_view_model.dart index 133b4a228..10ddf25e4 100644 --- a/lib/view_model/exchange/exchange_trade_view_model.dart +++ b/lib/view_model/exchange/exchange_trade_view_model.dart @@ -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; diff --git a/lib/view_model/send/send_view_model.dart b/lib/view_model/send/send_view_model.dart index 096f4e9f0..fd783cf6f 100644 --- a/lib/view_model/send/send_view_model.dart +++ b/lib/view_model/send/send_view_model.dart @@ -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 diff --git a/lib/view_model/settings/privacy_settings_view_model.dart b/lib/view_model/settings/privacy_settings_view_model.dart index b5c58a1b7..f8c3e5b50 100644 --- a/lib/view_model/settings/privacy_settings_view_model.dart +++ b/lib/view_model/settings/privacy_settings_view_model.dart @@ -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; diff --git a/res/values/strings_de.arb b/res/values/strings_de.arb index ecbd3838e..915e43e5d 100644 --- a/res/values/strings_de.arb +++ b/res/values/strings_de.arb @@ -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" diff --git a/res/values/strings_en.arb b/res/values/strings_en.arb index c6d71a2b1..a997b9f1f 100644 --- a/res/values/strings_en.arb +++ b/res/values/strings_en.arb @@ -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" diff --git a/res/values/strings_es.arb b/res/values/strings_es.arb index 09878ede1..959b2a9a2 100644 --- a/res/values/strings_es.arb +++ b/res/values/strings_es.arb @@ -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" diff --git a/res/values/strings_fr.arb b/res/values/strings_fr.arb index 66f60af81..d82cad2f9 100644 --- a/res/values/strings_fr.arb +++ b/res/values/strings_fr.arb @@ -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" diff --git a/res/values/strings_hi.arb b/res/values/strings_hi.arb index a25b649c3..42f408229 100644 --- a/res/values/strings_hi.arb +++ b/res/values/strings_hi.arb @@ -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 केवल" diff --git a/res/values/strings_hr.arb b/res/values/strings_hr.arb index e7e0ff1e4..0e026e97d 100644 --- a/res/values/strings_hr.arb +++ b/res/values/strings_hr.arb @@ -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" diff --git a/res/values/strings_it.arb b/res/values/strings_it.arb index 80a0ea1fd..db2a98658 100644 --- a/res/values/strings_it.arb +++ b/res/values/strings_it.arb @@ -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" diff --git a/res/values/strings_ja.arb b/res/values/strings_ja.arb index b38066916..21fe513e9 100644 --- a/res/values/strings_ja.arb +++ b/res/values/strings_ja.arb @@ -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のみ" diff --git a/res/values/strings_ko.arb b/res/values/strings_ko.arb index e4915cbb0..38f001df0 100644 --- a/res/values/strings_ko.arb +++ b/res/values/strings_ko.arb @@ -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 뿐" diff --git a/res/values/strings_nl.arb b/res/values/strings_nl.arb index 59a816602..6283518f6 100644 --- a/res/values/strings_nl.arb +++ b/res/values/strings_nl.arb @@ -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" diff --git a/res/values/strings_pl.arb b/res/values/strings_pl.arb index a2dc5c8fd..e768d7d4d 100644 --- a/res/values/strings_pl.arb +++ b/res/values/strings_pl.arb @@ -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" diff --git a/res/values/strings_pt.arb b/res/values/strings_pt.arb index f61ac5e67..bd9c5e474 100644 --- a/res/values/strings_pt.arb +++ b/res/values/strings_pt.arb @@ -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" diff --git a/res/values/strings_ru.arb b/res/values/strings_ru.arb index c44e9af35..8e1e0f21c 100644 --- a/res/values/strings_ru.arb +++ b/res/values/strings_ru.arb @@ -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" diff --git a/res/values/strings_uk.arb b/res/values/strings_uk.arb index a766641d7..1f72c1052 100644 --- a/res/values/strings_uk.arb +++ b/res/values/strings_uk.arb @@ -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" diff --git a/res/values/strings_zh.arb b/res/values/strings_zh.arb index ae5ffbea5..12655af5a 100644 --- a/res/values/strings_zh.arb +++ b/res/values/strings_zh.arb @@ -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" From dac0b02c7dabaaacb59d853fb8d23fe19eaace88 Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Thu, 8 Dec 2022 00:11:09 +0200 Subject: [PATCH 12/20] Disable updating fiat rate if the option is disabled [skip ci] --- lib/reactions/on_current_fiat_change.dart | 3 ++- lib/reactions/on_current_wallet_change.dart | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/reactions/on_current_fiat_change.dart b/lib/reactions/on_current_fiat_change.dart index 86a5ee881..5170c4576 100644 --- a/lib/reactions/on_current_fiat_change.dart +++ b/lib/reactions/on_current_fiat_change.dart @@ -1,3 +1,4 @@ +import 'package:cake_wallet/entities/fiat_api_mode.dart'; import 'package:mobx/mobx.dart'; import 'package:cake_wallet/core/fiat_conversion_service.dart'; import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart'; @@ -12,7 +13,7 @@ void startCurrentFiatChangeReaction(AppStore appStore, _onCurrentFiatCurrencyChangeDisposer?.reaction.dispose(); _onCurrentFiatCurrencyChangeDisposer = reaction( (_) => settingsStore.fiatCurrency, (FiatCurrency fiatCurrency) async { - if (appStore.wallet == null) { + if (appStore.wallet == null || settingsStore.fiatApiMode == FiatApiMode.disabled) { return; } diff --git a/lib/reactions/on_current_wallet_change.dart b/lib/reactions/on_current_wallet_change.dart index cce972368..270415820 100644 --- a/lib/reactions/on_current_wallet_change.dart +++ b/lib/reactions/on_current_wallet_change.dart @@ -1,3 +1,4 @@ +import 'package:cake_wallet/entities/fiat_api_mode.dart'; import 'package:cake_wallet/entities/fiat_currency.dart'; import 'package:cake_wallet/entities/update_haven_rate.dart'; import 'package:cw_core/transaction_history.dart'; @@ -87,7 +88,7 @@ void startCurrentWalletChangeReaction(AppStore appStore, TransactionHistoryBase, TransactionInfo>? wallet) async { try { - if (wallet == null) { + if (wallet == null || settingsStore.fiatApiMode == FiatApiMode.disabled) { return; } From d2fe7b26e001a82a560625a891bb01f88df89353 Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Thu, 8 Dec 2022 00:26:19 +0200 Subject: [PATCH 13/20] Remove unused fiat_rate_update.dart [skip ci] --- lib/reactions/fiat_rate_update.dart | 40 ----------------------------- 1 file changed, 40 deletions(-) delete mode 100644 lib/reactions/fiat_rate_update.dart diff --git a/lib/reactions/fiat_rate_update.dart b/lib/reactions/fiat_rate_update.dart deleted file mode 100644 index ff10a176c..000000000 --- a/lib/reactions/fiat_rate_update.dart +++ /dev/null @@ -1,40 +0,0 @@ -import 'dart:async'; -import 'package:cake_wallet/core/fiat_conversion_service.dart'; -import 'package:cake_wallet/entities/fiat_api_mode.dart'; -import 'package:cake_wallet/entities/update_haven_rate.dart'; -import 'package:cake_wallet/store/app_store.dart'; -import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart'; -import 'package:cake_wallet/store/settings_store.dart'; -import 'package:cw_core/wallet_type.dart'; - -Timer? _timer; - -Future startFiatRateUpdate(AppStore appStore, SettingsStore settingsStore, - FiatConversionStore fiatConversionStore) async { - if (_timer != null) { - return; - } - - if (appStore.wallet != null) { - fiatConversionStore.prices[appStore.wallet!.currency] = - await FiatConversionService.fetchPrice( - appStore.wallet!.currency, settingsStore.fiatCurrency); - } - - _timer = Timer.periodic( - Duration(seconds: 30), - (_) async { - try { - if (appStore.wallet!.type == WalletType.haven) { - await updateHavenRate(fiatConversionStore); - } else { - fiatConversionStore.prices[appStore.wallet!.currency] = - settingsStore.fiatApiMode == FiatApiMode.disabled ? 0.0 - : await FiatConversionService.fetchPrice( - appStore.wallet!.currency, settingsStore.fiatCurrency); - } - } catch(e) { - print(e); - } - }); -} From a1dd22232b93235dffa06d46fd81a9dba20353b9 Mon Sep 17 00:00:00 2001 From: Serhii Date: Thu, 8 Dec 2022 09:56:04 +0200 Subject: [PATCH 14/20] [skip ci] fix fiat settings display --- lib/src/screens/settings/display_settings_page.dart | 3 ++- lib/view_model/settings/display_settings_view_model.dart | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/src/screens/settings/display_settings_page.dart b/lib/src/screens/settings/display_settings_page.dart index cd413ff45..39123a7eb 100644 --- a/lib/src/screens/settings/display_settings_page.dart +++ b/lib/src/screens/settings/display_settings_page.dart @@ -34,7 +34,8 @@ class DisplaySettingsPage extends BasePage { onValueChange: (_, bool value) { _displaySettingsViewModel.setShouldDisplayBalance(value); }), - if (!isHaven) + //if (!isHaven) it does not work correctly + if(!_displaySettingsViewModel.disabledFiatApiMode) SettingsPickerCell( title: S.current.settings_currency, searchHintText: S.current.search_currency, diff --git a/lib/view_model/settings/display_settings_view_model.dart b/lib/view_model/settings/display_settings_view_model.dart index 4e73b3399..bac6d9994 100644 --- a/lib/view_model/settings/display_settings_view_model.dart +++ b/lib/view_model/settings/display_settings_view_model.dart @@ -3,6 +3,7 @@ import 'package:cake_wallet/entities/fiat_currency.dart'; import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/themes/theme_base.dart'; import 'package:mobx/mobx.dart'; +import 'package:cake_wallet/entities/fiat_api_mode.dart'; part 'display_settings_view_model.g.dart'; @@ -30,6 +31,9 @@ abstract class DisplaySettingsViewModelBase with Store { @computed ThemeBase get theme => _settingsStore.currentTheme; + @computed + bool get disabledFiatApiMode => _settingsStore.fiatApiMode == FiatApiMode.disabled; + @action void setBalanceDisplayMode(BalanceDisplayMode value) => _settingsStore.balanceDisplayMode = value; From 6395d6b2f76a33bab65323ee4f46faf1d6dd3d72 Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Thu, 8 Dec 2022 14:10:58 +0200 Subject: [PATCH 15/20] - Add Disable fiat API option to advanced privacy settings --- .../advanced_privacy_settings_view_model.dart | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/lib/view_model/advanced_privacy_settings_view_model.dart b/lib/view_model/advanced_privacy_settings_view_model.dart index ef9ab878f..f800e3418 100644 --- a/lib/view_model/advanced_privacy_settings_view_model.dart +++ b/lib/view_model/advanced_privacy_settings_view_model.dart @@ -1,3 +1,4 @@ +import 'package:cake_wallet/entities/fiat_api_mode.dart'; import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/view_model/settings/switcher_list_item.dart'; import 'package:cw_core/wallet_type.dart'; @@ -11,15 +12,13 @@ class AdvancedPrivacySettingsViewModel = AdvancedPrivacySettingsViewModelBase abstract class AdvancedPrivacySettingsViewModelBase with Store { AdvancedPrivacySettingsViewModelBase(this.type, this._settingsStore) - : _disableFiat = false, - _addCustomNode = false { + : _addCustomNode = false { settings = [ - // TODO: uncomment when Disable Fiat PR is merged - // SwitcherListItem( - // title: S.current.disable_fiat, - // value: () => _disableFiat, - // onValueChange: (_, bool value) => _disableFiat = value, - // ), + SwitcherListItem( + title: S.current.disable_fiat, + value: () => _settingsStore.fiatApiMode == FiatApiMode.disabled, + onValueChange: (_, bool value) => setFiatMode(value), + ), SwitcherListItem( title: S.current.disable_exchange, value: () => _settingsStore.disableExchange, @@ -37,9 +36,6 @@ abstract class AdvancedPrivacySettingsViewModelBase with Store { late List settings; - @observable - bool _disableFiat = false; - @observable bool _addCustomNode = false; @@ -48,4 +44,13 @@ abstract class AdvancedPrivacySettingsViewModelBase with Store { @computed bool get addCustomNode => _addCustomNode; + + @action + void setFiatMode(bool value) { + if (value) { + _settingsStore.fiatApiMode = FiatApiMode.disabled; + return; + } + _settingsStore.fiatApiMode = FiatApiMode.enabled; + } } From ce19be56a05d6cb8861e103f1c8778df6256656f Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Thu, 8 Dec 2022 17:23:17 +0200 Subject: [PATCH 16/20] - Fix haven and litecoin fee transaction priority issue - Revert removing fiat rate update and use it to update fiat rate periodically if Fiat API is not disabled --- lib/bitcoin/cw_bitcoin.dart | 4 ++ lib/entities/preferences_key.dart | 2 + lib/reactions/bootstrap.dart | 2 + lib/reactions/fiat_rate_update.dart | 40 +++++++++++++++ lib/store/settings_store.dart | 79 ++++++++++++++++++++--------- tool/configure.dart | 1 + 6 files changed, 104 insertions(+), 24 deletions(-) create mode 100644 lib/reactions/fiat_rate_update.dart diff --git a/lib/bitcoin/cw_bitcoin.dart b/lib/bitcoin/cw_bitcoin.dart index f224efde6..630ecf27f 100644 --- a/lib/bitcoin/cw_bitcoin.dart +++ b/lib/bitcoin/cw_bitcoin.dart @@ -51,6 +51,10 @@ class CWBitcoin extends Bitcoin { TransactionPriority deserializeBitcoinTransactionPriority(int raw) => BitcoinTransactionPriority.deserialize(raw: raw); + @override + TransactionPriority deserializeLitecoinTransactionPriority(int raw) + => LitecoinTransactionPriority.deserialize(raw: raw); + @override int getFeeRate(Object wallet, TransactionPriority priority) { final bitcoinWallet = wallet as ElectrumWallet; diff --git a/lib/entities/preferences_key.dart b/lib/entities/preferences_key.dart index 7d1d75000..6d9e93de6 100644 --- a/lib/entities/preferences_key.dart +++ b/lib/entities/preferences_key.dart @@ -22,6 +22,8 @@ class PreferencesKey { 'current_default_settings_migration_version'; static const moneroTransactionPriority = 'current_fee_priority_monero'; static const bitcoinTransactionPriority = 'current_fee_priority_bitcoin'; + static const havenTransactionPriority = 'current_fee_priority_haven'; + static const litecoinTransactionPriority = 'current_fee_priority_litecoin'; static const shouldShowReceiveWarning = 'should_show_receive_warning'; static const shouldShowYatPopup = 'should_show_yat_popup'; static const moneroWalletPasswordUpdateV1Base = 'monero_wallet_update_v1'; diff --git a/lib/reactions/bootstrap.dart b/lib/reactions/bootstrap.dart index a40a17088..4b65ed9d2 100644 --- a/lib/reactions/bootstrap.dart +++ b/lib/reactions/bootstrap.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'package:cake_wallet/reactions/fiat_rate_update.dart'; import 'package:cake_wallet/reactions/on_current_node_change.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/widgets.dart'; @@ -31,4 +32,5 @@ Future bootstrap(GlobalKey navigatorKey) async { appStore, settingsStore, fiatConversionStore); startCurrentFiatChangeReaction(appStore, settingsStore, fiatConversionStore); startOnCurrentNodeChangeReaction(appStore); + startFiatRateUpdate(appStore, settingsStore, fiatConversionStore); } diff --git a/lib/reactions/fiat_rate_update.dart b/lib/reactions/fiat_rate_update.dart new file mode 100644 index 000000000..99a3bc4ae --- /dev/null +++ b/lib/reactions/fiat_rate_update.dart @@ -0,0 +1,40 @@ +import 'dart:async'; +import 'package:cake_wallet/core/fiat_conversion_service.dart'; +import 'package:cake_wallet/entities/fiat_api_mode.dart'; +import 'package:cake_wallet/entities/update_haven_rate.dart'; +import 'package:cake_wallet/store/app_store.dart'; +import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart'; +import 'package:cake_wallet/store/settings_store.dart'; +import 'package:cw_core/wallet_type.dart'; + +Timer? _timer; + +Future startFiatRateUpdate( + AppStore appStore, SettingsStore settingsStore, FiatConversionStore fiatConversionStore) async { + if (_timer != null) { + return; + } + + if (appStore.wallet != null && settingsStore.fiatApiMode == FiatApiMode.enabled) { + fiatConversionStore.prices[appStore.wallet!.currency] = await FiatConversionService.fetchPrice( + appStore.wallet!.currency, settingsStore.fiatCurrency); + } + + _timer = Timer.periodic(Duration(seconds: 30), (_) async { + if (settingsStore.fiatApiMode == FiatApiMode.disabled) { + return; + } + + try { + if (appStore.wallet!.type == WalletType.haven) { + await updateHavenRate(fiatConversionStore); + } else { + fiatConversionStore.prices[appStore.wallet!.currency] = + await FiatConversionService.fetchPrice( + appStore.wallet!.currency, settingsStore.fiatCurrency); + } + } catch (e) { + print(e); + } + }); +} diff --git a/lib/store/settings_store.dart b/lib/store/settings_store.dart index 237846495..283fff1e0 100644 --- a/lib/store/settings_store.dart +++ b/lib/store/settings_store.dart @@ -44,7 +44,9 @@ abstract class SettingsStoreBase with Store { required this.isBitcoinBuyEnabled, required this.actionlistDisplayMode, TransactionPriority? initialBitcoinTransactionPriority, - TransactionPriority? initialMoneroTransactionPriority}) + TransactionPriority? initialMoneroTransactionPriority, + TransactionPriority? initialHavenTransactionPriority, + TransactionPriority? initialLitecoinTransactionPriority}) : nodes = ObservableMap.of(nodes), _sharedPreferences = sharedPreferences, fiatCurrency = initialFiatCurrency, @@ -67,6 +69,14 @@ abstract class SettingsStoreBase with Store { priority[WalletType.bitcoin] = initialBitcoinTransactionPriority; } + if (initialHavenTransactionPriority != null) { + priority[WalletType.haven] = initialHavenTransactionPriority; + } + + if (initialLitecoinTransactionPriority != null) { + priority[WalletType.litecoin] = initialLitecoinTransactionPriority; + } + reaction( (_) => fiatCurrency, (FiatCurrency fiatCurrency) => sharedPreferences.setString( @@ -78,11 +88,25 @@ abstract class SettingsStoreBase with Store { .setBool(PreferencesKey.shouldShowYatPopup, shouldShowYatPopup)); priority.observe((change) { - final key = change.key == WalletType.monero - ? PreferencesKey.moneroTransactionPriority - : PreferencesKey.bitcoinTransactionPriority; + final String? key; + switch (change.key) { + case WalletType.monero: + key = PreferencesKey.moneroTransactionPriority; + break; + case WalletType.bitcoin: + key = PreferencesKey.bitcoinTransactionPriority; + break; + case WalletType.litecoin: + key = PreferencesKey.litecoinTransactionPriority; + break; + case WalletType.haven: + key = PreferencesKey.havenTransactionPriority; + break; + default: + key = null; + } - if (change.newValue != null) { + if (change.newValue != null && key != null) { sharedPreferences.setInt(key, change.newValue!.serialize()); } }); @@ -202,33 +226,39 @@ abstract class SettingsStoreBase with Store { static Future load( {required Box nodeSource, required bool isBitcoinBuyEnabled, - TransactionPriority? initialMoneroTransactionPriority, - TransactionPriority? initialBitcoinTransactionPriority, FiatCurrency initialFiatCurrency = FiatCurrency.usd, BalanceDisplayMode initialBalanceDisplayMode = BalanceDisplayMode.availableBalance}) async { - if (initialBitcoinTransactionPriority == null) { - initialBitcoinTransactionPriority = bitcoin?.getMediumTransactionPriority(); - } - - if (initialMoneroTransactionPriority == null) { - initialMoneroTransactionPriority = monero?.getDefaultTransactionPriority(); - } final sharedPreferences = await getIt.getAsync(); final currentFiatCurrency = FiatCurrency.deserialize(raw: sharedPreferences.getString(PreferencesKey.currentFiatCurrencyKey)!); - final savedMoneroTransactionPriority = + + TransactionPriority? moneroTransactionPriority = monero?.deserializeMoneroTransactionPriority( raw: sharedPreferences .getInt(PreferencesKey.moneroTransactionPriority)!); - final savedBitcoinTransactionPriority = + TransactionPriority? bitcoinTransactionPriority = bitcoin?.deserializeBitcoinTransactionPriority(sharedPreferences .getInt(PreferencesKey.bitcoinTransactionPriority)!); - final moneroTransactionPriority = - savedMoneroTransactionPriority ?? initialMoneroTransactionPriority; - final bitcoinTransactionPriority = - savedBitcoinTransactionPriority ?? initialBitcoinTransactionPriority; + + TransactionPriority? havenTransactionPriority; + TransactionPriority? litecoinTransactionPriority; + + if (sharedPreferences.getInt(PreferencesKey.havenTransactionPriority) != null) { + havenTransactionPriority = monero?.deserializeMoneroTransactionPriority( + raw: sharedPreferences.getInt(PreferencesKey.havenTransactionPriority)!); + } + if (sharedPreferences.getInt(PreferencesKey.litecoinTransactionPriority) != null) { + litecoinTransactionPriority = bitcoin?.deserializeLitecoinTransactionPriority( + sharedPreferences.getInt(PreferencesKey.litecoinTransactionPriority)!); + } + + moneroTransactionPriority ??= monero?.getDefaultTransactionPriority(); + bitcoinTransactionPriority ??= bitcoin?.getMediumTransactionPriority(); + havenTransactionPriority ??= monero?.getDefaultTransactionPriority(); + litecoinTransactionPriority ??= bitcoin?.getLitecoinTransactionPriorityMedium(); + final currentBalanceDisplayMode = BalanceDisplayMode.deserialize( raw: sharedPreferences .getInt(PreferencesKey.currentBalanceDisplayModeKey)!); @@ -249,8 +279,7 @@ abstract class SettingsStoreBase with Store { : ThemeType.bright.index; final savedTheme = ThemeList.deserialize( raw: sharedPreferences.getInt(PreferencesKey.currentTheme) ?? - legacyTheme ?? - 0); + legacyTheme); final actionListDisplayMode = ObservableList(); actionListDisplayMode.addAll(deserializeActionlistDisplayModes( sharedPreferences.getInt(PreferencesKey.displayActionListModeKey) ?? @@ -296,7 +325,7 @@ abstract class SettingsStoreBase with Store { if (havenNode != null) { nodes[WalletType.haven] = havenNode; } - + return SettingsStore( sharedPreferences: sharedPreferences, nodes: nodes, @@ -314,6 +343,8 @@ abstract class SettingsStoreBase with Store { initialLanguageCode: savedLanguageCode, initialMoneroTransactionPriority: moneroTransactionPriority, initialBitcoinTransactionPriority: bitcoinTransactionPriority, + initialHavenTransactionPriority: havenTransactionPriority, + initialLitecoinTransactionPriority: litecoinTransactionPriority, shouldShowYatPopup: shouldShowYatPopup); } @@ -326,7 +357,7 @@ abstract class SettingsStoreBase with Store { // TransactionPriority? initialBitcoinTransactionPriority, // BalanceDisplayMode initialBalanceDisplayMode = // BalanceDisplayMode.availableBalance}) async { - + // if (initialBitcoinTransactionPriority == null) { // initialBitcoinTransactionPriority = bitcoin?.getMediumTransactionPriority(); // } diff --git a/tool/configure.dart b/tool/configure.dart index 0d3d175c4..5ae5a2111 100644 --- a/tool/configure.dart +++ b/tool/configure.dart @@ -75,6 +75,7 @@ abstract class Bitcoin { List getTransactionPriorities(); List getLitecoinTransactionPriorities(); TransactionPriority deserializeBitcoinTransactionPriority(int raw); + TransactionPriority deserializeLitecoinTransactionPriority(int raw); int getFeeRate(Object wallet, TransactionPriority priority); Future generateNewAddress(Object wallet); Object createBitcoinTransactionCredentials(List outputs, {required TransactionPriority priority, int? feeRate}); From ae1d2a3bec79d2f3ba394232fda84db7e06fd1c2 Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Thu, 8 Dec 2022 21:33:14 +0200 Subject: [PATCH 17/20] Add validation on node input in advanced privacy settings --- .../new_wallet/advanced_privacy_settings_page.dart | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/src/screens/new_wallet/advanced_privacy_settings_page.dart b/lib/src/screens/new_wallet/advanced_privacy_settings_page.dart index ff1c83f90..6c2f996df 100644 --- a/lib/src/screens/new_wallet/advanced_privacy_settings_page.dart +++ b/lib/src/screens/new_wallet/advanced_privacy_settings_page.dart @@ -78,7 +78,14 @@ class _AdvancedPrivacySettingsBodyState extends State Date: Fri, 9 Dec 2022 19:41:54 +0200 Subject: [PATCH 18/20] Separate update fiat rate in a function to enhance readability [skip ci] --- lib/reactions/fiat_rate_update.dart | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/reactions/fiat_rate_update.dart b/lib/reactions/fiat_rate_update.dart index 99a3bc4ae..70387be97 100644 --- a/lib/reactions/fiat_rate_update.dart +++ b/lib/reactions/fiat_rate_update.dart @@ -15,26 +15,28 @@ Future startFiatRateUpdate( return; } - if (appStore.wallet != null && settingsStore.fiatApiMode == FiatApiMode.enabled) { - fiatConversionStore.prices[appStore.wallet!.currency] = await FiatConversionService.fetchPrice( - appStore.wallet!.currency, settingsStore.fiatCurrency); - } + _updateFiatRate(appStore, settingsStore, fiatConversionStore); _timer = Timer.periodic(Duration(seconds: 30), (_) async { - if (settingsStore.fiatApiMode == FiatApiMode.disabled) { - return; - } - try { if (appStore.wallet!.type == WalletType.haven) { await updateHavenRate(fiatConversionStore); } else { - fiatConversionStore.prices[appStore.wallet!.currency] = - await FiatConversionService.fetchPrice( - appStore.wallet!.currency, settingsStore.fiatCurrency); + _updateFiatRate(appStore, settingsStore, fiatConversionStore); } } catch (e) { print(e); } }); } + +void _updateFiatRate( + AppStore appStore, + SettingsStore settingsStore, + FiatConversionStore fiatConversionStore, +) async { + if (appStore.wallet != null && settingsStore.fiatApiMode == FiatApiMode.enabled) { + fiatConversionStore.prices[appStore.wallet!.currency] = await FiatConversionService.fetchPrice( + appStore.wallet!.currency, settingsStore.fiatCurrency); + } +} From fde1ea74de2ece5f333c7c90b75075f181f5b2b4 Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Fri, 9 Dec 2022 19:55:23 +0200 Subject: [PATCH 19/20] Remove duplicate fetching for fiat rate [skip ci] --- lib/reactions/fiat_rate_update.dart | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/lib/reactions/fiat_rate_update.dart b/lib/reactions/fiat_rate_update.dart index 70387be97..04276b567 100644 --- a/lib/reactions/fiat_rate_update.dart +++ b/lib/reactions/fiat_rate_update.dart @@ -15,28 +15,18 @@ Future startFiatRateUpdate( return; } - _updateFiatRate(appStore, settingsStore, fiatConversionStore); - _timer = Timer.periodic(Duration(seconds: 30), (_) async { try { if (appStore.wallet!.type == WalletType.haven) { await updateHavenRate(fiatConversionStore); } else { - _updateFiatRate(appStore, settingsStore, fiatConversionStore); + if (appStore.wallet != null && settingsStore.fiatApiMode == FiatApiMode.enabled) { + fiatConversionStore.prices[appStore.wallet!.currency] = await FiatConversionService.fetchPrice( + appStore.wallet!.currency, settingsStore.fiatCurrency); + } } } catch (e) { print(e); } }); } - -void _updateFiatRate( - AppStore appStore, - SettingsStore settingsStore, - FiatConversionStore fiatConversionStore, -) async { - if (appStore.wallet != null && settingsStore.fiatApiMode == FiatApiMode.enabled) { - fiatConversionStore.prices[appStore.wallet!.currency] = await FiatConversionService.fetchPrice( - appStore.wallet!.currency, settingsStore.fiatCurrency); - } -} From 899e999d78d366b86cbc528c5f0f2f3df0fc2840 Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Fri, 9 Dec 2022 20:04:44 +0200 Subject: [PATCH 20/20] check nullability of wallet and disable fiat api state before updating rates [skip ci] --- lib/reactions/fiat_rate_update.dart | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/reactions/fiat_rate_update.dart b/lib/reactions/fiat_rate_update.dart index 04276b567..48c61d8ca 100644 --- a/lib/reactions/fiat_rate_update.dart +++ b/lib/reactions/fiat_rate_update.dart @@ -17,13 +17,16 @@ Future startFiatRateUpdate( _timer = Timer.periodic(Duration(seconds: 30), (_) async { try { + if (appStore.wallet == null || settingsStore.fiatApiMode == FiatApiMode.disabled) { + return; + } + if (appStore.wallet!.type == WalletType.haven) { await updateHavenRate(fiatConversionStore); } else { - if (appStore.wallet != null && settingsStore.fiatApiMode == FiatApiMode.enabled) { - fiatConversionStore.prices[appStore.wallet!.currency] = await FiatConversionService.fetchPrice( - appStore.wallet!.currency, settingsStore.fiatCurrency); - } + fiatConversionStore.prices[appStore.wallet!.currency] = + await FiatConversionService.fetchPrice( + appStore.wallet!.currency, settingsStore.fiatCurrency); } } catch (e) { print(e);