refactor: unify mail display with shared ThreadTile widget #445

Merged
guettlibot merged 2 commits from issue-429-unify-mail-display into main 2026-06-05 17:06:30 +00:00
guettlibot commented 2026-06-05 15:10:02 +00:00 (Migrated from codeberg.org)

Summary

Closes #429

There were three separate places that rendered a mail row:

  • EmailTile — used in SearchScreen and EmailListScreen._buildEmailList(), accepted an Email object
  • Inline ListTile in EmailListScreen._buildThreadList() — accepted an EmailThread
  • Inline ListTile in CombinedInboxScreen._buildThreadTile() — accepted an EmailThread

What changed

  • New lib/ui/widgets/thread_tile.dart — a single ThreadTile widget that renders an EmailThread with all the thread-level features (message count badge, preview snippet, flagged star, location label). The _fmtDate date-formatting cache previously duplicated in both screens is now owned by this widget.
  • EmailThread.fromEmail(Email e) factory added to lib/core/models/email.dart — maps a single Email to a one-message EmailThread so search results can be fed to ThreadTile without changing the repository layer.
  • EmailListScreen and CombinedInboxScreen inline ListTile blocks replaced with ThreadTile. Dismissible wrappers and all selection/swipe logic stay in the screens.
  • SearchScreen and EmailListScreen._buildEmailList() now convert EmailEmailThread.fromEmail() and use ThreadTile.
  • EmailTile deleted — no longer has any usages.

Verification

dart analyze on all changed files reports no issues.

## Summary Closes #429 There were three separate places that rendered a mail row: - `EmailTile` — used in `SearchScreen` and `EmailListScreen._buildEmailList()`, accepted an `Email` object - Inline `ListTile` in `EmailListScreen._buildThreadList()` — accepted an `EmailThread` - Inline `ListTile` in `CombinedInboxScreen._buildThreadTile()` — accepted an `EmailThread` ## What changed - **New `lib/ui/widgets/thread_tile.dart`** — a single `ThreadTile` widget that renders an `EmailThread` with all the thread-level features (message count badge, preview snippet, flagged star, location label). The `_fmtDate` date-formatting cache previously duplicated in both screens is now owned by this widget. - **`EmailThread.fromEmail(Email e)` factory** added to `lib/core/models/email.dart` — maps a single `Email` to a one-message `EmailThread` so search results can be fed to `ThreadTile` without changing the repository layer. - **`EmailListScreen`** and **`CombinedInboxScreen`** inline `ListTile` blocks replaced with `ThreadTile`. `Dismissible` wrappers and all selection/swipe logic stay in the screens. - **`SearchScreen`** and **`EmailListScreen._buildEmailList()`** now convert `Email` → `EmailThread.fromEmail()` and use `ThreadTile`. - **`EmailTile` deleted** — no longer has any usages. ## Verification `dart analyze` on all changed files reports no issues.
Sign in to join this conversation.