custom filters
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
/// Visibility flags for built-in Home screen sections.
|
||||
library;
|
||||
|
||||
class HomeBuiltInSections {
|
||||
const HomeBuiltInSections({
|
||||
this.showTransactions = true,
|
||||
this.showCategorized = true,
|
||||
this.showRecent = true,
|
||||
});
|
||||
|
||||
static const defaults = HomeBuiltInSections();
|
||||
|
||||
final bool showTransactions;
|
||||
final bool showCategorized;
|
||||
final bool showRecent;
|
||||
|
||||
HomeBuiltInSections copyWith({
|
||||
bool? showTransactions,
|
||||
bool? showCategorized,
|
||||
bool? showRecent,
|
||||
}) {
|
||||
return HomeBuiltInSections(
|
||||
showTransactions: showTransactions ?? this.showTransactions,
|
||||
showCategorized: showCategorized ?? this.showCategorized,
|
||||
showRecent: showRecent ?? this.showRecent,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'showTransactions': showTransactions,
|
||||
'showCategorized': showCategorized,
|
||||
'showRecent': showRecent,
|
||||
};
|
||||
|
||||
factory HomeBuiltInSections.fromJson(Map<String, dynamic>? json) {
|
||||
if (json == null) return defaults;
|
||||
return HomeBuiltInSections(
|
||||
showTransactions: json['showTransactions'] as bool? ?? true,
|
||||
showCategorized: json['showCategorized'] as bool? ?? true,
|
||||
showRecent: json['showRecent'] as bool? ?? true,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ class HomeFilterWidget {
|
||||
required this.name,
|
||||
this.display = true,
|
||||
this.sortOrder = 0,
|
||||
this.halfWidth = false,
|
||||
this.labelIds = const [],
|
||||
this.flow = TxFlowFilter.all,
|
||||
this.amountRange = const TxAmountRange(),
|
||||
@@ -26,6 +27,9 @@ class HomeFilterWidget {
|
||||
final bool display;
|
||||
final int sortOrder;
|
||||
|
||||
/// When true, the Home card uses half the row width.
|
||||
final bool halfWidth;
|
||||
|
||||
final List<String> labelIds;
|
||||
final TxFlowFilter flow;
|
||||
final TxAmountRange amountRange;
|
||||
@@ -49,6 +53,7 @@ class HomeFilterWidget {
|
||||
String? name,
|
||||
bool? display,
|
||||
int? sortOrder,
|
||||
bool? halfWidth,
|
||||
List<String>? labelIds,
|
||||
TxFlowFilter? flow,
|
||||
TxAmountRange? amountRange,
|
||||
@@ -63,6 +68,7 @@ class HomeFilterWidget {
|
||||
name: name ?? this.name,
|
||||
display: display ?? this.display,
|
||||
sortOrder: sortOrder ?? this.sortOrder,
|
||||
halfWidth: halfWidth ?? this.halfWidth,
|
||||
labelIds: labelIds ?? this.labelIds,
|
||||
flow: flow ?? this.flow,
|
||||
amountRange: amountRange ?? this.amountRange,
|
||||
@@ -103,6 +109,7 @@ class HomeFilterWidget {
|
||||
'name': name,
|
||||
'display': display,
|
||||
'sortOrder': sortOrder,
|
||||
'halfWidth': halfWidth,
|
||||
'labelIds': labelIds,
|
||||
'flow': flow.name,
|
||||
'amountRange': {
|
||||
@@ -135,6 +142,7 @@ class HomeFilterWidget {
|
||||
: 'Filter',
|
||||
display: json['display'] as bool? ?? true,
|
||||
sortOrder: json['sortOrder'] as int? ?? 0,
|
||||
halfWidth: json['halfWidth'] as bool? ?? false,
|
||||
labelIds: [
|
||||
for (final id in (json['labelIds'] as List? ?? const []))
|
||||
if (id is String && id.isNotEmpty) id,
|
||||
|
||||
Reference in New Issue
Block a user