mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-16 17:27:37 +00:00
hide picker after the country is set
This commit is contained in:
parent
b534e4871d
commit
cce358b94f
3 changed files with 44 additions and 26 deletions
|
@ -376,6 +376,10 @@ class Country extends EnumerableItem<String> with Serializable<String> {
|
|||
return _all.values.firstWhereOrNull((element) => element.raw == countryCode.toLowerCase());
|
||||
}
|
||||
|
||||
static Country? fromFullName(String fullName) {
|
||||
return _all.values.firstWhereOrNull((element) => element.fullName == fullName);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => other is Country && other.raw == raw;
|
||||
|
||||
|
|
|
@ -119,36 +119,39 @@ class CakePayCardsPage extends BasePage {
|
|||
_cardsListViewModel.getVendors();
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).extension<SyncIndicatorTheme>()!.syncedBackgroundColor,
|
||||
border: Border.all(color: Colors.transparent),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 5),
|
||||
child: Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 2),
|
||||
child: Row(
|
||||
children: [
|
||||
Image.asset(
|
||||
_cardsListViewModel.selectedCountry.iconPath,
|
||||
width: 24,
|
||||
height: 24,
|
||||
errorBuilder: (context, error, stackTrace) => Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).extension<SyncIndicatorTheme>()!.syncedBackgroundColor,
|
||||
border: Border.all(color: Colors.transparent),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 2),
|
||||
child: Row(
|
||||
children: [
|
||||
Image.asset(
|
||||
_cardsListViewModel.selectedCountry.iconPath,
|
||||
width: 24,
|
||||
height: 24,
|
||||
errorBuilder: (context, error, stackTrace) => Container(
|
||||
width: 24,
|
||||
height: 24,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 6),
|
||||
Text(
|
||||
_cardsListViewModel.selectedCountry.countryCode,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).extension<DashboardPageTheme>()!.textColor,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w700,
|
||||
SizedBox(width: 6),
|
||||
Text(
|
||||
_cardsListViewModel.selectedCountry.countryCode,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).extension<DashboardPageTheme>()!.textColor,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -169,7 +172,7 @@ class CakePayCardsPage extends BasePage {
|
|||
)),
|
||||
SizedBox(width: 5),
|
||||
filterButton,
|
||||
SizedBox(width: 5),
|
||||
if (_cardsListViewModel.showCountryPicker)
|
||||
_countryPicker
|
||||
])),
|
||||
SizedBox(height: 8),
|
||||
|
|
|
@ -5,6 +5,7 @@ import 'package:cake_wallet/entities/country.dart';
|
|||
import 'package:cake_wallet/entities/fiat_currency.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/store/settings_store.dart';
|
||||
import 'package:cake_wallet/view_model/dashboard/dropdown_filter_item.dart';
|
||||
import 'package:cake_wallet/view_model/dashboard/filter_item.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
|
||||
|
@ -70,6 +71,14 @@ abstract class CakePayCardsListViewModelBase with Store {
|
|||
caption: S.current.custom_value,
|
||||
onChanged: toggleCustomValueCards),
|
||||
],
|
||||
S.current.countries: [
|
||||
DropdownFilterItem(
|
||||
items: availableCountries.map((e) => e.title).toList(),
|
||||
caption: '',
|
||||
selectedItem: selectedCountry.title,
|
||||
onItemSelected: (String value) => setSelectedCountry(Country.fromFullName(value)!),
|
||||
),
|
||||
]
|
||||
};
|
||||
|
||||
String searchString;
|
||||
|
@ -121,6 +130,8 @@ abstract class CakePayCardsListViewModelBase with Store {
|
|||
Country get selectedCountry =>
|
||||
settingsStore.selectedCakePayCountry ?? _getInitialCountry(settingsStore.fiatCurrency);
|
||||
|
||||
bool get showCountryPicker => settingsStore.selectedCakePayCountry == null;
|
||||
|
||||
bool get hasFiltersChanged =>
|
||||
settingsStore.selectedCakePayCountry != _initialSelectedCountry ||
|
||||
displayPrepaidCards != _initialDisplayPrepaidCards ||
|
||||
|
|
Loading…
Reference in a new issue