Skip to content

Commit b1cdf55

Browse files
committed
msglist: Show visibility policy on recipient headers
This mostly matches the legacy mobile app, except that now we also support topic visibility policies other than "follow", and that we use the color of the @-mention marker. Reference legacy mobile app code: https://github.com/zulip/zulip-mobile/blob/a115df1f71c9dc31e9b41060a8d57b51c017d786/src/streams/TopicItem.js#L47-L51 Signed-off-by: Zixuan James Li <[email protected]>
1 parent 97599fe commit b1cdf55

File tree

2 files changed

+42
-5
lines changed

2 files changed

+42
-5
lines changed

lib/widgets/message_list.dart

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,7 @@ class StreamMessageRecipientHeader extends StatelessWidget {
991991
// https://www.figma.com/file/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=538%3A20849&mode=dev
992992
// https://github.com/zulip/zulip-mobile/issues/5511
993993
final store = PerAccountStoreWidget.of(context);
994+
final designVariables = DesignVariables.of(context);
994995

995996
final topic = message.topic;
996997

@@ -1064,11 +1065,23 @@ class StreamMessageRecipientHeader extends StatelessWidget {
10641065
Expanded(
10651066
child: Padding(
10661067
padding: const EdgeInsets.symmetric(vertical: 11),
1067-
child: Text(topic,
1068-
// TODO: Give a way to see the whole topic (maybe a
1069-
// long-press interaction?)
1070-
overflow: TextOverflow.ellipsis,
1071-
style: recipientHeaderTextStyle(context)))),
1068+
child: Row(
1069+
children: [
1070+
Flexible(
1071+
child: Text(topic,
1072+
// TODO: Give a way to see the whole topic (maybe a
1073+
// long-press interaction?)
1074+
overflow: TextOverflow.ellipsis,
1075+
style: recipientHeaderTextStyle(context))),
1076+
Container(
1077+
width: 20,
1078+
padding: const EdgeInsetsDirectional.only(start: 4),
1079+
// TODO(design): Choose an color for the icon
1080+
child: Icon(size: 14, color: designVariables.atMentionMarker,
1081+
// A null [Icon.icon] makes a blank space.
1082+
iconDataForTopicVisibilityPolicy(
1083+
store.topicVisibilityPolicy(message.streamId, topic)))),
1084+
]))),
10721085
// TODO topic links?
10731086
// Then web also has edit/resolve/mute buttons. Skip those for mobile.
10741087
RecipientHeaderDate(message: message),

test/widgets/message_list_test.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,30 @@ void main() {
803803
check(findInMessageList('topic name')).length.equals(1);
804804
});
805805

806+
testWidgets('show topic visibility icon when followed', (tester) async {
807+
await setupMessageListPage(tester,
808+
narrow: const CombinedFeedNarrow(),
809+
messages: [message], subscriptions: [eg.subscription(stream)]);
810+
await store.handleEvent(eg.userTopicEvent(
811+
stream.streamId, message.topic, UserTopicVisibilityPolicy.followed));
812+
await tester.pump();
813+
check(find.descendant(
814+
of: find.byType(MessageList),
815+
matching: find.byIcon(ZulipIcons.follow))).findsOne();
816+
});
817+
818+
testWidgets('show topic visibility icon when unmuted', (tester) async {
819+
await setupMessageListPage(tester,
820+
narrow: TopicNarrow.ofMessage(message),
821+
messages: [message], subscriptions: [eg.subscription(stream, isMuted: true)]);
822+
await store.handleEvent(eg.userTopicEvent(
823+
stream.streamId, message.topic, UserTopicVisibilityPolicy.unmuted));
824+
await tester.pump();
825+
check(find.descendant(
826+
of: find.byType(MessageList),
827+
matching: find.byIcon(ZulipIcons.unmute))).findsOne();
828+
});
829+
806830
testWidgets('color of recipient header background', (tester) async {
807831
final subscription = eg.subscription(stream, color: Colors.red.argbInt);
808832
final swatch = ChannelColorSwatch.light(subscription.color);

0 commit comments

Comments
 (0)