Skip to content

Commit

Permalink
msglist: Show stream privacy icon in app bar
Browse files Browse the repository at this point in the history
This serves as a demo of our custom icon font #200.
  • Loading branch information
gnprice committed Aug 1, 2023
1 parent 4070cea commit 7c77e93
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions lib/widgets/message_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import '../model/store.dart';
import 'action_sheet.dart';
import 'compose_box.dart';
import 'content.dart';
import 'icons.dart';
import 'page.dart';
import 'sticky_header.dart';
import 'store.dart';
Expand Down Expand Up @@ -70,6 +71,27 @@ class MessageListAppBarTitle extends StatelessWidget {

final Narrow narrow;

Widget _buildStreamRow(ZulipStream? stream, String text) {
final icon = switch (stream) {
ZulipStream(isWebPublic: true) => ZulipIcons.globe,
ZulipStream(inviteOnly: true) => ZulipIcons.lock,
ZulipStream() => ZulipIcons.hash_sign,
null => null, // A null [Icon.icon] makes a blank space.
};
return Row(
mainAxisSize: MainAxisSize.min,
// TODO(design): The vertical alignment of the stream privacy icon is a bit ad hoc.
// For screenshots of some experiments, see:
// https://github.com/zulip/zulip-flutter/pull/219#discussion_r1281024746
crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.alphabetic,
children: [
Icon(size: 16, icon),
const SizedBox(width: 8),
Flexible(child: Text(text)),
]);
}

@override
Widget build(BuildContext context) {
switch (narrow) {
Expand All @@ -78,13 +100,15 @@ class MessageListAppBarTitle extends StatelessWidget {

case StreamNarrow(:var streamId):
final store = PerAccountStoreWidget.of(context);
final streamName = store.streams[streamId]?.name ?? '(unknown stream)';
return Text("#$streamName"); // TODO show stream privacy icon
final stream = store.streams[streamId];
final streamName = stream?.name ?? '(unknown stream)';
return _buildStreamRow(stream, streamName);

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

case DmNarrow(:var otherRecipientIds):
final store = PerAccountStoreWidget.of(context);
Expand Down

0 comments on commit 7c77e93

Please sign in to comment.