Skip to content

Commit 7c77e93

Browse files
committed
msglist: Show stream privacy icon in app bar
This serves as a demo of our custom icon font #200.
1 parent 4070cea commit 7c77e93

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

lib/widgets/message_list.dart

+28-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import '../model/store.dart';
1111
import 'action_sheet.dart';
1212
import 'compose_box.dart';
1313
import 'content.dart';
14+
import 'icons.dart';
1415
import 'page.dart';
1516
import 'sticky_header.dart';
1617
import 'store.dart';
@@ -70,6 +71,27 @@ class MessageListAppBarTitle extends StatelessWidget {
7071

7172
final Narrow narrow;
7273

74+
Widget _buildStreamRow(ZulipStream? stream, String text) {
75+
final icon = switch (stream) {
76+
ZulipStream(isWebPublic: true) => ZulipIcons.globe,
77+
ZulipStream(inviteOnly: true) => ZulipIcons.lock,
78+
ZulipStream() => ZulipIcons.hash_sign,
79+
null => null, // A null [Icon.icon] makes a blank space.
80+
};
81+
return Row(
82+
mainAxisSize: MainAxisSize.min,
83+
// TODO(design): The vertical alignment of the stream privacy icon is a bit ad hoc.
84+
// For screenshots of some experiments, see:
85+
// https://github.com/zulip/zulip-flutter/pull/219#discussion_r1281024746
86+
crossAxisAlignment: CrossAxisAlignment.baseline,
87+
textBaseline: TextBaseline.alphabetic,
88+
children: [
89+
Icon(size: 16, icon),
90+
const SizedBox(width: 8),
91+
Flexible(child: Text(text)),
92+
]);
93+
}
94+
7395
@override
7496
Widget build(BuildContext context) {
7597
switch (narrow) {
@@ -78,13 +100,15 @@ class MessageListAppBarTitle extends StatelessWidget {
78100

79101
case StreamNarrow(:var streamId):
80102
final store = PerAccountStoreWidget.of(context);
81-
final streamName = store.streams[streamId]?.name ?? '(unknown stream)';
82-
return Text("#$streamName"); // TODO show stream privacy icon
103+
final stream = store.streams[streamId];
104+
final streamName = stream?.name ?? '(unknown stream)';
105+
return _buildStreamRow(stream, streamName);
83106

84107
case TopicNarrow(:var streamId, :var topic):
85108
final store = PerAccountStoreWidget.of(context);
86-
final streamName = store.streams[streamId]?.name ?? '(unknown stream)';
87-
return Text("#$streamName > $topic"); // TODO show stream privacy icon; format on two lines
109+
final stream = store.streams[streamId];
110+
final streamName = stream?.name ?? '(unknown stream)';
111+
return _buildStreamRow(stream, "$streamName > $topic");
88112

89113
case DmNarrow(:var otherRecipientIds):
90114
final store = PerAccountStoreWidget.of(context);

0 commit comments

Comments
 (0)