Files
sharedinbox/lib/ui/screens/email_list_screen.dart
T
Thomas GüttlerandClaude Sonnet 4.6 6c27ad655b Complete UI gaps: move-to-folder, attachment indicators in list
- email_detail: add Move-to-folder button (bottom-sheet mailbox picker,
  excludes current folder, calls moveEmail on server)
- email_list: show amber star for flagged, paperclip for attachments
  in trailing area alongside date
- PLAN.md: mark phase 8 done
- README: add flag/move/attachment to working features

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-16 11:11:11 +02:00

99 lines
3.1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:intl/intl.dart';
import '../../di.dart';
final _dateFmt = DateFormat('MMM d');
class EmailListScreen extends ConsumerWidget {
const EmailListScreen({
super.key,
required this.accountId,
required this.mailboxPath,
});
final String accountId;
final String mailboxPath;
@override
Widget build(BuildContext context, WidgetRef ref) {
final repo = ref.watch(emailRepositoryProvider);
return Scaffold(
appBar: AppBar(
title: Text(mailboxPath),
actions: [
IconButton(
icon: const Icon(Icons.sync),
onPressed: () =>
repo.syncEmails(accountId, mailboxPath),
),
IconButton(
icon: const Icon(Icons.edit),
onPressed: () => context.push(
'/compose',
extra: {'accountId': accountId},
),
),
],
),
body: StreamBuilder(
stream: repo.observeEmails(accountId, mailboxPath),
builder: (ctx, snap) {
if (!snap.hasData) {
return const Center(child: CircularProgressIndicator());
}
final emails = snap.data!;
if (emails.isEmpty) {
return const Center(child: Text('No emails'));
}
return ListView.builder(
itemCount: emails.length,
itemBuilder: (ctx, i) {
final e = emails[i];
final sender = e.from.isNotEmpty
? (e.from.first.name ?? e.from.first.email)
: '(unknown)';
return ListTile(
leading: Icon(
e.isSeen ? Icons.mail_outline : Icons.mail,
color: e.isSeen ? null : Theme.of(ctx).colorScheme.primary,
),
title: Text(
sender,
style: e.isSeen
? null
: const TextStyle(fontWeight: FontWeight.bold),
),
subtitle: Text(
e.subject ?? '(no subject)',
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (e.isFlagged)
const Icon(Icons.star, color: Colors.amber, size: 16),
if (e.hasAttachment)
const Icon(Icons.attach_file, size: 16),
const SizedBox(width: 4),
Text(
e.sentAt != null ? _dateFmt.format(e.sentAt!) : '',
style: Theme.of(ctx).textTheme.bodySmall,
),
],
),
onTap: () => context.push(
'/accounts/$accountId/mailboxes/${Uri.encodeComponent(mailboxPath)}/emails/${Uri.encodeComponent(e.id)}',
),
);
},
);
},
),
);
}
}