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 zulip#200.
  • Loading branch information
gnprice committed Jul 17, 2023
1 parent 736993f commit 1738b33
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions lib/widgets/message_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,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 @@ -69,6 +70,26 @@ 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(
crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.alphabetic,
children: [
Padding(
// TODO(design): The vertical alignment of the stream privacy icon is ad hoc and eyeballed.
padding: const EdgeInsets.only(bottom: 4),
child: Icon(size: 16, icon)),
const SizedBox(width: 8),
Text(text),
]);
}

@override
Widget build(BuildContext context) {
switch (narrow) {
Expand All @@ -77,13 +98,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 1738b33

Please sign in to comment.