Implements issue #466 — a visual row-based filter editor (Field |
Comparison | Value, AND/OR grouping) reused in the Search screen and
the Sieve script editor.
New files:
- lib/core/filter/filter_expression.dart — FilterGroup/FilterLeaf tree
model (FilterField, FilterComparison, FilterOperator)
- lib/core/sieve/sieve_serializer.dart — serialises FilterGroup +
SieveActions to a Sieve RFC 5228 script
- lib/core/filter/filter_sieve_converter.dart — parses a Sieve script
back into a FilterGroup tree (round-trip support)
- lib/ui/widgets/filter_builder.dart — interactive FilterBuilderWidget
with nested group support (depth ≤ 1)
- test/unit/filter_and_sieve_test.dart — 25 unit tests covering
FilterGroup, FilterLeaf, SieveSerializer, and FilterSieveConverter
including round-trip coverage
Modified files:
- EmailRepository: adds searchEmailsStructured abstract method
- EmailRepositoryImpl: implements searchEmailsStructured via Drift query
builder (LIKE-based matching on JSON address fields and text columns)
- SearchScreen: adds Advanced Search mode (tune icon toggle) using the
FilterBuilderWidget
- SieveScriptEditScreen: gains a Visual / Script tab pair; switching
serialises or parses the script automatically; _ActionEditor covers
keep / discard / mark-as-read / file-into actions
- 5 test fake classes + 2 generated mock files: add stubs for the new
searchEmailsStructured method
- scripts/check_coverage.dart: adds filter_builder.dart to _excluded
(UI widget, covered by widget tests path)
- Fix: SieveSerializer now emits \\Seen (double-escaped) so the flag
survives quoted-string parsing back to \Seen
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>