feat: pull-to-refresh on email list screen

Wrapped the stream body in RefreshIndicator calling syncEmails.
Empty-state is now a scrollable ListView so the pull gesture triggers
even when the folder contains no messages.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Thomas Güttler
2026-04-24 16:44:53 +02:00
co-authored by Claude Sonnet 4.6
parent 39c3d1ea1a
commit 14b1ee14ac
3 changed files with 30 additions and 21 deletions
+6
View File
@@ -6,6 +6,12 @@ Tasks get moved from next.md to done.md
## Tasks
## Pull-to-refresh on email list
Wrapped `_buildStreamBody` in a `RefreshIndicator` that calls `syncEmails`.
The empty-state is now a scrollable `ListView` so the pull gesture works even
when the folder has no messages.
## Show email preview snippet in list
Added `preview` field to `EmailThread` (populated from the latest email in
+24 -13
View File
@@ -230,19 +230,30 @@ class _EmailListScreenState extends ConsumerState<EmailListScreen> {
}
Widget _buildStreamBody(EmailRepository emailRepo) {
return StreamBuilder<List<EmailThread>>(
stream: emailRepo.observeThreads(widget.accountId, widget.mailboxPath),
builder: (ctx, snap) {
if (!snap.hasData) {
return const Center(child: CircularProgressIndicator());
}
final threads = snap.data!;
_currentThreads = threads;
if (threads.isEmpty) {
return const Center(child: Text('No emails'));
}
return _buildThreadList(threads);
},
return RefreshIndicator(
onRefresh: () =>
emailRepo.syncEmails(widget.accountId, widget.mailboxPath),
child: StreamBuilder<List<EmailThread>>(
stream: emailRepo.observeThreads(widget.accountId, widget.mailboxPath),
builder: (ctx, snap) {
if (!snap.hasData) {
return const Center(child: CircularProgressIndicator());
}
final threads = snap.data!;
_currentThreads = threads;
if (threads.isEmpty) {
return ListView(
children: const [
SizedBox(
height: 300,
child: Center(child: Text('No emails')),
),
],
);
}
return _buildThreadList(threads);
},
),
);
}
-8
View File
@@ -18,14 +18,6 @@ Then commit.
## Tasks
## Pull-to-refresh on email list
`EmailListScreen` has a manual sync icon button but no swipe-to-refresh gesture.
Wrap the `StreamBuilder` result body in a `RefreshIndicator` that calls the
same sync trigger as the icon button.
File: `lib/ui/screens/email_list_screen.dart`
## Mark as unread button in email detail
`EmailRepository.setFlag(emailId, seen: false)` already exists. Add a