cake pay country picker (#1779)

* cake pay country picker

* UI changes

* hide picker after the country is set

* Revert "hide picker after the country is set"

This reverts commit cce358b94f55c22e0807b4d3641a13ebd299106c.

* show country picker initially

* flags

* minor ui fixes

* Update lib/view_model/cake_pay/cake_pay_cards_list_view_model.dart

---------

Co-authored-by: tuxpizza <tuxsudo@tux.pizza>
Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
Serhii
2024-11-07 07:50:48 +02:00
committed by GitHub
co-authored by tuxpizza Omar Hatem
parent c8cfc2cff1
commit 48457fdd6d
132 changed files with 601 additions and 78 deletions
+24 -1
View File
@@ -9,6 +9,7 @@ import 'package:cake_wallet/entities/auto_generate_subaddress_status.dart';
import 'package:cake_wallet/entities/background_tasks.dart';
import 'package:cake_wallet/entities/balance_display_mode.dart';
import 'package:cake_wallet/entities/cake_2fa_preset_options.dart';
import 'package:cake_wallet/entities/country.dart';
import 'package:cake_wallet/entities/exchange_api_mode.dart';
import 'package:cake_wallet/entities/fiat_api_mode.dart';
import 'package:cake_wallet/entities/fiat_currency.dart';
@@ -128,7 +129,8 @@ abstract class SettingsStoreBase with Store {
TransactionPriority? initialLitecoinTransactionPriority,
TransactionPriority? initialEthereumTransactionPriority,
TransactionPriority? initialPolygonTransactionPriority,
TransactionPriority? initialBitcoinCashTransactionPriority})
TransactionPriority? initialBitcoinCashTransactionPriority,
Country? initialCakePayCountry})
: nodes = ObservableMap<WalletType, Node>.of(nodes),
powNodes = ObservableMap<WalletType, Node>.of(powNodes),
_secureStorage = secureStorage,
@@ -213,6 +215,10 @@ abstract class SettingsStoreBase with Store {
priority[WalletType.bitcoinCash] = initialBitcoinCashTransactionPriority;
}
if (initialCakePayCountry != null) {
selectedCakePayCountry = initialCakePayCountry;
}
initializeTrocadorProviderStates();
WalletType.values.forEach((walletType) {
@@ -244,6 +250,15 @@ abstract class SettingsStoreBase with Store {
(FiatCurrency fiatCurrency) => sharedPreferences.setString(
PreferencesKey.currentFiatCurrencyKey, fiatCurrency.serialize()));
reaction(
(_) => selectedCakePayCountry,
(Country? country) {
if (country != null) {
sharedPreferences.setString(
PreferencesKey.currentCakePayCountry, country.raw);
}
});
reaction(
(_) => shouldShowYatPopup,
(bool shouldShowYatPopup) =>
@@ -625,6 +640,9 @@ abstract class SettingsStoreBase with Store {
@observable
FiatCurrency fiatCurrency;
@observable
Country? selectedCakePayCountry;
@observable
bool shouldShowYatPopup;
@@ -880,6 +898,10 @@ abstract class SettingsStoreBase with Store {
final backgroundTasks = getIt.get<BackgroundTasks>();
final currentFiatCurrency = FiatCurrency.deserialize(
raw: sharedPreferences.getString(PreferencesKey.currentFiatCurrencyKey)!);
final savedCakePayCountryRaw = sharedPreferences.getString(PreferencesKey.currentCakePayCountry);
final currentCakePayCountry = savedCakePayCountryRaw != null
? Country.deserialize(raw: savedCakePayCountryRaw)
: null;
TransactionPriority? moneroTransactionPriority = monero?.deserializeMoneroTransactionPriority(
raw: sharedPreferences.getInt(PreferencesKey.moneroTransactionPriority)!);
@@ -1225,6 +1247,7 @@ abstract class SettingsStoreBase with Store {
deviceName: deviceName,
isBitcoinBuyEnabled: isBitcoinBuyEnabled,
initialFiatCurrency: currentFiatCurrency,
initialCakePayCountry: currentCakePayCountry,
initialBalanceDisplayMode: currentBalanceDisplayMode,
initialSaveRecipientAddress: shouldSaveRecipientAddress,
initialAutoGenerateSubaddressStatus: autoGenerateSubaddressStatus,