Skip to content

Commit 541ecd8

Browse files
committed
msglist: Vary AppBar title by narrow
1 parent 2d8e80f commit 541ecd8

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

lib/widgets/message_list.dart

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class MessageListPage extends StatelessWidget {
2727
@override
2828
Widget build(BuildContext context) {
2929
return Scaffold(
30-
appBar: AppBar(title: const Text("All messages")),
30+
appBar: AppBar(title: MessageListAppBarTitle(narrow: narrow)),
3131
body: Builder(
3232
builder: (BuildContext context) => Center(
3333
child: Column(children: [
@@ -48,6 +48,31 @@ class MessageListPage extends StatelessWidget {
4848
}
4949
}
5050

51+
class MessageListAppBarTitle extends StatelessWidget {
52+
const MessageListAppBarTitle({super.key, required this.narrow});
53+
54+
final Narrow narrow;
55+
56+
@override
57+
Widget build(BuildContext context) {
58+
switch (narrow) {
59+
case AllMessagesNarrow():
60+
return const Text("All messages");
61+
62+
case StreamNarrow(:var streamId):
63+
final store = PerAccountStoreWidget.of(context);
64+
final streamName = store.streams[streamId]?.name ?? '(unknown stream)';
65+
return Text("#$streamName"); // TODO show stream privacy icon
66+
67+
case TopicNarrow(:var streamId, :var topic):
68+
final store = PerAccountStoreWidget.of(context);
69+
final streamName = store.streams[streamId]?.name ?? '(unknown stream)';
70+
return Text("#$streamName > $topic"); // TODO show stream privacy icon; format on two lines
71+
}
72+
}
73+
}
74+
75+
5176
class MessageList extends StatefulWidget {
5277
const MessageList({super.key, required this.narrow});
5378

0 commit comments

Comments
 (0)