fixed some issues and added label and, or capability
This commit is contained in:
@@ -86,6 +86,7 @@ class HomeFilterWidget {
|
||||
this.budgetFixedAmount = 0,
|
||||
this.budgetAverageMonths = 3,
|
||||
this.labelIds = const [],
|
||||
this.labelMatch = LabelMatchMode.and,
|
||||
this.flow = TxFlowFilter.all,
|
||||
this.amountRange = const TxAmountRange(),
|
||||
this.query = '',
|
||||
@@ -115,6 +116,10 @@ class HomeFilterWidget {
|
||||
final int budgetAverageMonths;
|
||||
|
||||
final List<String> labelIds;
|
||||
|
||||
/// AND vs OR when multiple [labelIds] are selected.
|
||||
final LabelMatchMode labelMatch;
|
||||
|
||||
final TxFlowFilter flow;
|
||||
final TxAmountRange amountRange;
|
||||
final String query;
|
||||
@@ -128,6 +133,7 @@ class HomeFilterWidget {
|
||||
|
||||
TransactionFilterSelection get filter => TransactionFilterSelection(
|
||||
labelIds: labelIds.toSet(),
|
||||
labelMatch: labelMatch,
|
||||
flow: flow,
|
||||
amountRange: amountRange,
|
||||
query: query,
|
||||
@@ -147,6 +153,7 @@ class HomeFilterWidget {
|
||||
double? budgetFixedAmount,
|
||||
int? budgetAverageMonths,
|
||||
List<String>? labelIds,
|
||||
LabelMatchMode? labelMatch,
|
||||
TxFlowFilter? flow,
|
||||
TxAmountRange? amountRange,
|
||||
String? query,
|
||||
@@ -168,6 +175,7 @@ class HomeFilterWidget {
|
||||
budgetFixedAmount: budgetFixedAmount ?? this.budgetFixedAmount,
|
||||
budgetAverageMonths: budgetAverageMonths ?? this.budgetAverageMonths,
|
||||
labelIds: labelIds ?? this.labelIds,
|
||||
labelMatch: labelMatch ?? this.labelMatch,
|
||||
flow: flow ?? this.flow,
|
||||
amountRange: amountRange ?? this.amountRange,
|
||||
query: query ?? this.query,
|
||||
@@ -192,6 +200,7 @@ class HomeFilterWidget {
|
||||
display: display,
|
||||
sortOrder: sortOrder,
|
||||
labelIds: filter.labelIds.toList(growable: false),
|
||||
labelMatch: filter.labelMatch,
|
||||
flow: filter.flow,
|
||||
amountRange: filter.amountRange,
|
||||
query: filter.query,
|
||||
@@ -215,6 +224,7 @@ class HomeFilterWidget {
|
||||
'budgetFixedAmount': budgetFixedAmount,
|
||||
'budgetAverageMonths': budgetAverageMonths,
|
||||
'labelIds': labelIds,
|
||||
'labelMatch': labelMatch.name,
|
||||
'flow': flow.name,
|
||||
'amountRange': {
|
||||
if (amountRange.exact != null) 'exact': amountRange.exact,
|
||||
@@ -274,6 +284,10 @@ class HomeFilterWidget {
|
||||
for (final id in (json['labelIds'] as List? ?? const []))
|
||||
if (id is String && id.isNotEmpty) id,
|
||||
],
|
||||
labelMatch: LabelMatchMode.values.firstWhere(
|
||||
(e) => e.name == json['labelMatch'],
|
||||
orElse: () => LabelMatchMode.and,
|
||||
),
|
||||
flow: TxFlowFilter.values.firstWhere(
|
||||
(e) => e.name == json['flow'],
|
||||
orElse: () => TxFlowFilter.all,
|
||||
|
||||
@@ -134,6 +134,15 @@ int labelVisibleDepth(
|
||||
/// Filter-only id for txs with no labels (not an assignable category).
|
||||
const String kUncategorizedFilterId = '__uncategorized__';
|
||||
|
||||
/// How multiple selected labels combine in a transaction filter.
|
||||
enum LabelMatchMode {
|
||||
/// Tx must include every selected label.
|
||||
and,
|
||||
|
||||
/// Tx must include at least one selected label.
|
||||
or,
|
||||
}
|
||||
|
||||
/// Chip presentation for [kUncategorizedFilterId] refine filters.
|
||||
const TxLabel kUncategorizedFilterLabel = TxLabel(
|
||||
id: kUncategorizedFilterId,
|
||||
|
||||
Reference in New Issue
Block a user