fixed some issues and added label and, or capability
This commit is contained in:
@@ -37,6 +37,7 @@ class HomeFilterWidgetCard extends StatelessWidget {
|
||||
MaterialPageRoute<void>(
|
||||
builder: (_) => TransactionsScreen(
|
||||
initialLabelIds: filter.labelIds,
|
||||
initialLabelMatch: filter.labelMatch,
|
||||
initialSearchInMonthOnly:
|
||||
widgetConfig.type == HomeWidgetType.budget || filter.monthOnly,
|
||||
initialQuery: filter.query,
|
||||
|
||||
@@ -55,6 +55,7 @@ Future<HomeFilterWidget?> composeHomeFilterWidget(
|
||||
? HomeFilterWidget.fromFilter(name: 'Filter', filter: filter)
|
||||
: existing.copyWith(
|
||||
labelIds: filter.labelIds.toList(growable: false),
|
||||
labelMatch: filter.labelMatch,
|
||||
flow: filter.flow,
|
||||
amountRange: filter.amountRange,
|
||||
query: filter.query,
|
||||
|
||||
@@ -15,6 +15,7 @@ import 'label_parent_picker.dart';
|
||||
class TransactionFilterSelection {
|
||||
const TransactionFilterSelection({
|
||||
required this.labelIds,
|
||||
this.labelMatch = LabelMatchMode.and,
|
||||
this.flow = TxFlowFilter.all,
|
||||
this.amountRange = const TxAmountRange(),
|
||||
this.query = '',
|
||||
@@ -22,6 +23,10 @@ class TransactionFilterSelection {
|
||||
});
|
||||
|
||||
final Set<String> labelIds;
|
||||
|
||||
/// AND vs OR when more than one label is selected.
|
||||
final LabelMatchMode labelMatch;
|
||||
|
||||
final TxFlowFilter flow;
|
||||
final TxAmountRange amountRange;
|
||||
final String query;
|
||||
@@ -497,6 +502,7 @@ class _TransactionFilterDialog extends StatefulWidget {
|
||||
|
||||
class _TransactionFilterDialogState extends State<_TransactionFilterDialog> {
|
||||
late final Set<String> _selected;
|
||||
late LabelMatchMode _labelMatch;
|
||||
late TxFlowFilter _flow;
|
||||
late bool _monthOnly;
|
||||
late final TextEditingController _queryController;
|
||||
@@ -510,6 +516,7 @@ class _TransactionFilterDialogState extends State<_TransactionFilterDialog> {
|
||||
super.initState();
|
||||
final initial = widget.initial;
|
||||
_selected = Set<String>.of(initial.labelIds);
|
||||
_labelMatch = initial.labelMatch;
|
||||
_flow = initial.flow;
|
||||
_monthOnly = initial.monthOnly;
|
||||
_queryController = TextEditingController(text: initial.query);
|
||||
@@ -593,6 +600,7 @@ class _TransactionFilterDialogState extends State<_TransactionFilterDialog> {
|
||||
context,
|
||||
TransactionFilterSelection(
|
||||
labelIds: Set<String>.of(_selected),
|
||||
labelMatch: _labelMatch,
|
||||
flow: _flow,
|
||||
amountRange: _amountResult,
|
||||
query: _queryController.text.trim(),
|
||||
@@ -840,7 +848,10 @@ class _TransactionFilterDialogState extends State<_TransactionFilterDialog> {
|
||||
),
|
||||
onChanged: (_) => setState(() {}),
|
||||
),
|
||||
Row(
|
||||
Wrap(
|
||||
spacing: 0,
|
||||
runSpacing: 4,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
@@ -859,6 +870,27 @@ class _TransactionFilterDialogState extends State<_TransactionFilterDialog> {
|
||||
onPressed: () => setState(() => _selected.clear()),
|
||||
child: const Text('No labels'),
|
||||
),
|
||||
SegmentedButton<LabelMatchMode>(
|
||||
style: const ButtonStyle(
|
||||
visualDensity: VisualDensity.compact,
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
),
|
||||
showSelectedIcon: false,
|
||||
segments: const [
|
||||
ButtonSegment(
|
||||
value: LabelMatchMode.and,
|
||||
label: Text('AND'),
|
||||
),
|
||||
ButtonSegment(
|
||||
value: LabelMatchMode.or,
|
||||
label: Text('OR'),
|
||||
),
|
||||
],
|
||||
selected: {_labelMatch},
|
||||
onSelectionChanged: (selection) {
|
||||
setState(() => _labelMatch = selection.first);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
|
||||
Reference in New Issue
Block a user