mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-01 12:04:21 +01:00
Сake pay filter white screen bug (#491)
* increase touch area for filter button * rework card list view model * fix button color * fix formating
This commit is contained in:
@@ -1,58 +0,0 @@
|
||||
import 'package:cake_wallet/ionia/ionia_category.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
|
||||
part 'ionia_filter_view_model.g.dart';
|
||||
|
||||
class IoniaFilterViewModel = IoniaFilterViewModelBase with _$IoniaFilterViewModel;
|
||||
|
||||
abstract class IoniaFilterViewModelBase with Store {
|
||||
IoniaFilterViewModelBase() {
|
||||
selectedIndices = ObservableList<int>();
|
||||
ioniaCategories = IoniaCategory.allCategories;
|
||||
}
|
||||
|
||||
List<IoniaCategory> get selectedCategories => ioniaCategories.where(_isSelected).toList();
|
||||
|
||||
@observable
|
||||
ObservableList<int> selectedIndices;
|
||||
|
||||
@observable
|
||||
List<IoniaCategory> ioniaCategories;
|
||||
|
||||
@action
|
||||
void selectFilter(IoniaCategory ioniaCategory) {
|
||||
if (ioniaCategory == IoniaCategory.all && !selectedIndices.contains(0)) {
|
||||
selectedIndices.clear();
|
||||
selectedIndices.add(0);
|
||||
return;
|
||||
}
|
||||
if (selectedIndices.contains(ioniaCategory.index) && ioniaCategory.index != 0) {
|
||||
selectedIndices.remove(ioniaCategory.index);
|
||||
return;
|
||||
}
|
||||
selectedIndices.add(ioniaCategory.index);
|
||||
selectedIndices.remove(0);
|
||||
}
|
||||
|
||||
@action
|
||||
void onSearchFilter(String text) {
|
||||
if (text.isEmpty) {
|
||||
ioniaCategories = IoniaCategory.allCategories;
|
||||
} else {
|
||||
ioniaCategories = IoniaCategory.allCategories
|
||||
.where(
|
||||
(e) => e.title.toLowerCase().contains(text.toLowerCase()),
|
||||
)
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
void setSelectedCategories(List<IoniaCategory> selectedCategories) {
|
||||
selectedIndices = ObservableList.of(selectedCategories.map((e) => e.index));
|
||||
}
|
||||
|
||||
bool _isSelected(IoniaCategory ioniaCategory) {
|
||||
return selectedIndices.contains(ioniaCategory.index);
|
||||
}
|
||||
}
|
||||
@@ -12,14 +12,13 @@ class IoniaGiftCardsListViewModel = IoniaGiftCardsListViewModelBase with _$Ionia
|
||||
abstract class IoniaGiftCardsListViewModelBase with Store {
|
||||
IoniaGiftCardsListViewModelBase({
|
||||
@required this.ioniaService,
|
||||
}) :
|
||||
}) :
|
||||
cardState = IoniaNoCardState(),
|
||||
ioniaMerchants = [],
|
||||
ioniaCategories = IoniaCategory.allCategories,
|
||||
selectedIndices = ObservableList<IoniaCategory>.of([IoniaCategory.all]),
|
||||
scrollOffsetFromTop = 0.0 {
|
||||
selectedFilters = [];
|
||||
_getAuthStatus().then((value) => isLoggedIn = value);
|
||||
|
||||
_getMerchants();
|
||||
}
|
||||
|
||||
final IoniaService ioniaService;
|
||||
@@ -28,8 +27,6 @@ abstract class IoniaGiftCardsListViewModelBase with Store {
|
||||
|
||||
String searchString;
|
||||
|
||||
List<IoniaCategory> selectedFilters;
|
||||
|
||||
@observable
|
||||
double scrollOffsetFromTop;
|
||||
|
||||
@@ -48,6 +45,12 @@ abstract class IoniaGiftCardsListViewModelBase with Store {
|
||||
@observable
|
||||
bool isLoggedIn;
|
||||
|
||||
@observable
|
||||
List<IoniaCategory> ioniaCategories;
|
||||
|
||||
@observable
|
||||
ObservableList<IoniaCategory> selectedIndices;
|
||||
|
||||
Future<bool> _getAuthStatus() async {
|
||||
return await ioniaService.isLogined();
|
||||
}
|
||||
@@ -88,9 +91,10 @@ abstract class IoniaGiftCardsListViewModelBase with Store {
|
||||
}
|
||||
}
|
||||
|
||||
void _getMerchants() {
|
||||
|
||||
void getMerchants() {
|
||||
merchantState = IoniaLoadingMerchantState();
|
||||
ioniaService.getMerchantsByFilter(categories: selectedFilters).then((value) {
|
||||
ioniaService.getMerchantsByFilter(categories: selectedIndices).then((value) {
|
||||
value.sort((a, b) => a.legalName.toLowerCase().compareTo(b.legalName.toLowerCase()));
|
||||
ioniaMerchants = ioniaMerchantList = value;
|
||||
merchantState = IoniaLoadedMerchantState();
|
||||
@@ -99,9 +103,42 @@ abstract class IoniaGiftCardsListViewModelBase with Store {
|
||||
}
|
||||
|
||||
@action
|
||||
void setSelectedFilter(List<IoniaCategory> filters) {
|
||||
selectedFilters = filters;
|
||||
_getMerchants();
|
||||
void setSelectedFilter(IoniaCategory category) {
|
||||
if (category == IoniaCategory.all) {
|
||||
selectedIndices.clear();
|
||||
selectedIndices.add(category);
|
||||
return;
|
||||
}
|
||||
|
||||
if (category != IoniaCategory.all) {
|
||||
selectedIndices.remove(IoniaCategory.all);
|
||||
}
|
||||
|
||||
if (selectedIndices.contains(category)) {
|
||||
selectedIndices.remove(category);
|
||||
|
||||
if (selectedIndices.isEmpty) {
|
||||
selectedIndices.add(IoniaCategory.all);
|
||||
}
|
||||
return;
|
||||
}
|
||||
selectedIndices.add(category);
|
||||
}
|
||||
|
||||
@action
|
||||
void onSearchFilter(String text) {
|
||||
if (text.isEmpty) {
|
||||
ioniaCategories = IoniaCategory.allCategories;
|
||||
} else {
|
||||
ioniaCategories = IoniaCategory.allCategories
|
||||
.where((e) => e.title.toLowerCase().contains(text.toLowerCase()),)
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
void resetIoniaCategories() {
|
||||
ioniaCategories = IoniaCategory.allCategories;
|
||||
}
|
||||
|
||||
void setScrollOffsetFromTop(double scrollOffset) {
|
||||
|
||||
Reference in New Issue
Block a user