mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-17 01:37:40 +00:00
PR fixes
This commit is contained in:
parent
d893562dad
commit
ca79052914
5 changed files with 79 additions and 88 deletions
|
@ -82,7 +82,7 @@ class FilterWidget extends StatelessWidget {
|
|||
final content = item.onChanged != null
|
||||
? Observer(
|
||||
builder: (_) => StandardCheckbox(
|
||||
value: item.value.value,
|
||||
value: item.value(),
|
||||
caption: item.caption,
|
||||
gradientBackground: true,
|
||||
borderColor: Theme.of(context).dividerColor,
|
||||
|
|
|
@ -8,60 +8,61 @@ part'trade_filter_store.g.dart';
|
|||
class TradeFilterStore = TradeFilterStoreBase with _$TradeFilterStore;
|
||||
|
||||
abstract class TradeFilterStoreBase with Store {
|
||||
TradeFilterStoreBase();
|
||||
TradeFilterStoreBase() : displayXMRTO = true,
|
||||
displayChangeNow = true,
|
||||
displaySideShift = true,
|
||||
displayMorphToken = true,
|
||||
displaySimpleSwap = true;
|
||||
|
||||
Observable<bool> displayXMRTO = Observable(true);
|
||||
Observable<bool> displayAllTrades = Observable(true);
|
||||
Observable<bool> displayChangeNow = Observable(true);
|
||||
Observable<bool> displaySideShift = Observable(true);
|
||||
Observable<bool> displayMorphToken = Observable(true);
|
||||
Observable<bool> displaySimpleSwap = Observable(true);
|
||||
@observable
|
||||
bool displayXMRTO;
|
||||
|
||||
@observable
|
||||
bool displayChangeNow;
|
||||
|
||||
@observable
|
||||
bool displaySideShift;
|
||||
|
||||
@observable
|
||||
bool displayMorphToken;
|
||||
|
||||
@observable
|
||||
bool displaySimpleSwap;
|
||||
|
||||
@computed
|
||||
bool get displayAllTrades => displayChangeNow && displaySideShift && displaySimpleSwap;
|
||||
|
||||
@action
|
||||
void toggleDisplayExchange(ExchangeProviderDescription provider) {
|
||||
switch (provider) {
|
||||
case ExchangeProviderDescription.changeNow:
|
||||
displayAllTrades.value = false;
|
||||
displayChangeNow.value = !displayChangeNow.value;
|
||||
if (displayChangeNow.value && displaySideShift.value && displaySimpleSwap.value) {
|
||||
displayAllTrades.value = true;
|
||||
}
|
||||
displayChangeNow = !displayChangeNow;
|
||||
break;
|
||||
case ExchangeProviderDescription.sideShift:
|
||||
displayAllTrades.value = false;
|
||||
displaySideShift.value = !displaySideShift.value;
|
||||
if (displayChangeNow.value && displaySideShift.value && displaySimpleSwap.value) {
|
||||
displayAllTrades.value = true;
|
||||
}
|
||||
displaySideShift = !displaySideShift;
|
||||
break;
|
||||
case ExchangeProviderDescription.simpleSwap:
|
||||
displayAllTrades.value = false;
|
||||
displaySimpleSwap.value = !displaySimpleSwap.value;
|
||||
if (displayChangeNow.value && displaySideShift.value && displaySimpleSwap.value) {
|
||||
displayAllTrades.value = true;
|
||||
}
|
||||
displaySimpleSwap = !displaySimpleSwap;
|
||||
break;
|
||||
case ExchangeProviderDescription.xmrto:
|
||||
displayXMRTO.value = !displayXMRTO.value;
|
||||
displayXMRTO = !displayXMRTO;
|
||||
break;
|
||||
case ExchangeProviderDescription.morphToken:
|
||||
displayMorphToken.value = !displayMorphToken.value;
|
||||
displayMorphToken = !displayMorphToken;
|
||||
break;
|
||||
case ExchangeProviderDescription.all:
|
||||
displayAllTrades.value = !displayAllTrades.value;
|
||||
if (displayAllTrades.value) {
|
||||
displayChangeNow.value = true;
|
||||
displaySideShift.value = true;
|
||||
displayXMRTO.value = true;
|
||||
displayMorphToken.value = true;
|
||||
displaySimpleSwap.value = true;
|
||||
}
|
||||
if (!displayAllTrades.value) {
|
||||
displayChangeNow.value = false;
|
||||
displaySideShift.value = false;
|
||||
displayXMRTO.value = false;
|
||||
displayMorphToken.value = false;
|
||||
displaySimpleSwap.value = false;
|
||||
if (displayAllTrades) {
|
||||
displayChangeNow = false;
|
||||
displaySideShift = false;
|
||||
displayXMRTO = false;
|
||||
displayMorphToken = false;
|
||||
displaySimpleSwap = false;
|
||||
} else {
|
||||
displayChangeNow = true;
|
||||
displaySideShift = true;
|
||||
displayXMRTO = true;
|
||||
displayMorphToken = true;
|
||||
displaySimpleSwap = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -70,24 +71,22 @@ abstract class TradeFilterStoreBase with Store {
|
|||
List<TradeListItem> filtered({required List<TradeListItem> trades, required WalletBase wallet}) {
|
||||
final _trades =
|
||||
trades.where((item) => item.trade.walletId == wallet.id).toList();
|
||||
final needToFilter = !displayChangeNow.value || !displaySideShift.value
|
||||
|| !displayXMRTO.value || !displayMorphToken.value
|
||||
|| !displaySimpleSwap.value;
|
||||
final needToFilter = !displayAllTrades;
|
||||
|
||||
return needToFilter
|
||||
? _trades
|
||||
.where((item) =>
|
||||
(displayXMRTO.value &&
|
||||
(displayXMRTO &&
|
||||
item.trade.provider == ExchangeProviderDescription.xmrto) ||
|
||||
(displaySideShift.value &&
|
||||
(displaySideShift &&
|
||||
item.trade.provider == ExchangeProviderDescription.sideShift) ||
|
||||
(displayChangeNow.value &&
|
||||
(displayChangeNow &&
|
||||
item.trade.provider ==
|
||||
ExchangeProviderDescription.changeNow) ||
|
||||
(displayMorphToken.value &&
|
||||
(displayMorphToken &&
|
||||
item.trade.provider ==
|
||||
ExchangeProviderDescription.morphToken)
|
||||
||(displaySimpleSwap.value &&
|
||||
||(displaySimpleSwap &&
|
||||
item.trade.provider ==
|
||||
ExchangeProviderDescription.simpleSwap))
|
||||
.toList()
|
||||
|
|
|
@ -10,11 +10,14 @@ class TransactionFilterStore = TransactionFilterStoreBase
|
|||
with _$TransactionFilterStore;
|
||||
|
||||
abstract class TransactionFilterStoreBase with Store {
|
||||
TransactionFilterStoreBase();
|
||||
TransactionFilterStoreBase() : displayIncoming = true,
|
||||
displayOutgoing = true;
|
||||
|
||||
Observable<bool> displayAll = Observable(true);
|
||||
Observable<bool> displayIncoming = Observable(true);
|
||||
Observable<bool> displayOutgoing = Observable(true);
|
||||
@observable
|
||||
bool displayIncoming;
|
||||
|
||||
@observable
|
||||
bool displayOutgoing;
|
||||
|
||||
@observable
|
||||
DateTime? startDate;
|
||||
|
@ -22,40 +25,30 @@ abstract class TransactionFilterStoreBase with Store {
|
|||
@observable
|
||||
DateTime? endDate;
|
||||
|
||||
@computed
|
||||
bool get displayAll => displayIncoming && displayOutgoing;
|
||||
|
||||
@action
|
||||
void toggleIAll() {
|
||||
displayAll.value = (!displayAll.value);
|
||||
if (displayAll.value) {
|
||||
displayOutgoing.value = true;
|
||||
displayIncoming.value = true;
|
||||
}
|
||||
if (!displayAll.value) {
|
||||
displayOutgoing.value = false;
|
||||
displayIncoming.value = false;
|
||||
void toggleAll() {
|
||||
if (displayAll) {
|
||||
displayOutgoing = false;
|
||||
displayIncoming = false;
|
||||
} else {
|
||||
displayOutgoing = true;
|
||||
displayIncoming = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@action
|
||||
void toggleIncoming() {
|
||||
displayIncoming.value = (!displayIncoming.value);
|
||||
if (displayIncoming.value && displayOutgoing.value) {
|
||||
displayAll.value = true;
|
||||
}
|
||||
if (!displayIncoming.value || !displayOutgoing.value) {
|
||||
displayAll.value = false;
|
||||
}
|
||||
displayIncoming = !displayIncoming;
|
||||
}
|
||||
|
||||
|
||||
@action
|
||||
void toggleOutgoing() {
|
||||
displayOutgoing.value = (!displayOutgoing.value);
|
||||
if (displayIncoming.value && displayOutgoing.value) {
|
||||
displayAll.value = true;
|
||||
}
|
||||
if (!displayIncoming.value || !displayOutgoing.value) {
|
||||
displayAll.value = false;
|
||||
}
|
||||
displayOutgoing = !displayOutgoing;
|
||||
}
|
||||
|
||||
@action
|
||||
|
@ -66,8 +59,7 @@ abstract class TransactionFilterStoreBase with Store {
|
|||
|
||||
List<TransactionListItem> filtered({required List<TransactionListItem> transactions}) {
|
||||
var _transactions = <TransactionListItem>[];
|
||||
final needToFilter = !displayOutgoing.value ||
|
||||
!displayIncoming.value ||
|
||||
final needToFilter = !displayAll ||
|
||||
(startDate != null && endDate != null);
|
||||
|
||||
if (needToFilter) {
|
||||
|
@ -79,11 +71,11 @@ abstract class TransactionFilterStoreBase with Store {
|
|||
&& (endDate?.isAfter(item.transaction.date) ?? false);
|
||||
}
|
||||
|
||||
if (allowed && (!displayOutgoing.value || !displayIncoming.value)) {
|
||||
allowed = (displayOutgoing.value &&
|
||||
if (allowed && (!displayAll)) {
|
||||
allowed = (displayOutgoing &&
|
||||
item.transaction.direction ==
|
||||
TransactionDirection.outgoing) ||
|
||||
(displayIncoming.value &&
|
||||
(displayIncoming &&
|
||||
item.transaction.direction == TransactionDirection.incoming);
|
||||
}
|
||||
|
||||
|
|
|
@ -59,15 +59,15 @@ abstract class DashboardViewModelBase with Store {
|
|||
filterItems = {
|
||||
S.current.transactions: [
|
||||
FilterItem(
|
||||
value: transactionFilterStore.displayAll,
|
||||
value: () => transactionFilterStore.displayAll,
|
||||
caption: S.current.all_transactions,
|
||||
onChanged: transactionFilterStore.toggleIAll),
|
||||
onChanged: transactionFilterStore.toggleAll),
|
||||
FilterItem(
|
||||
value: transactionFilterStore.displayIncoming,
|
||||
value: () => transactionFilterStore.displayIncoming,
|
||||
caption: S.current.incoming,
|
||||
onChanged:transactionFilterStore.toggleIncoming),
|
||||
FilterItem(
|
||||
value: transactionFilterStore.displayOutgoing,
|
||||
value: () => transactionFilterStore.displayOutgoing,
|
||||
caption: S.current.outgoing,
|
||||
onChanged: transactionFilterStore.toggleOutgoing),
|
||||
// FilterItem(
|
||||
|
@ -77,22 +77,22 @@ abstract class DashboardViewModelBase with Store {
|
|||
],
|
||||
S.current.trades: [
|
||||
FilterItem(
|
||||
value: tradeFilterStore.displayAllTrades,
|
||||
value: () => tradeFilterStore.displayAllTrades,
|
||||
caption: S.current.all_trades,
|
||||
onChanged: () => tradeFilterStore
|
||||
.toggleDisplayExchange(ExchangeProviderDescription.all)),
|
||||
FilterItem(
|
||||
value: tradeFilterStore.displayChangeNow,
|
||||
value: () => tradeFilterStore.displayChangeNow,
|
||||
caption: ExchangeProviderDescription.changeNow.title,
|
||||
onChanged: () => tradeFilterStore
|
||||
.toggleDisplayExchange(ExchangeProviderDescription.changeNow)),
|
||||
FilterItem(
|
||||
value: tradeFilterStore.displaySideShift,
|
||||
value: () => tradeFilterStore.displaySideShift,
|
||||
caption: ExchangeProviderDescription.sideShift.title,
|
||||
onChanged: () => tradeFilterStore
|
||||
.toggleDisplayExchange(ExchangeProviderDescription.sideShift)),
|
||||
FilterItem(
|
||||
value: tradeFilterStore.displaySimpleSwap,
|
||||
value: () => tradeFilterStore.displaySimpleSwap,
|
||||
caption: ExchangeProviderDescription.simpleSwap.title,
|
||||
onChanged: () => tradeFilterStore
|
||||
.toggleDisplayExchange(ExchangeProviderDescription.simpleSwap)),
|
||||
|
|
|
@ -6,7 +6,7 @@ class FilterItem {
|
|||
required this.caption,
|
||||
required this.onChanged});
|
||||
|
||||
Observable<bool> value;
|
||||
bool Function() value;
|
||||
String caption;
|
||||
Function onChanged;
|
||||
}
|
Loading…
Reference in a new issue