From 896547dee9bc90f4b566b7786150aca314d9102f Mon Sep 17 00:00:00 2001 From: Zixuan James Li Date: Tue, 3 Dec 2024 20:40:10 -0500 Subject: [PATCH] inbox: Show topic visibility marker for topic items Signed-off-by: Zixuan James Li --- lib/widgets/inbox.dart | 4 +++ test/widgets/inbox_test.dart | 47 ++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/lib/widgets/inbox.dart b/lib/widgets/inbox.dart index 0f84a4373d..a8c70bee53 100644 --- a/lib/widgets/inbox.dart +++ b/lib/widgets/inbox.dart @@ -514,6 +514,8 @@ class _TopicItem extends StatelessWidget { final subscription = store.subscriptions[streamId]!; final designVariables = DesignVariables.of(context); + final visibilityIcon = iconDataForTopicVisibilityPolicy( + store.topicVisibilityPolicy(streamId, topic)); return Material( color: designVariables.background, // TODO(design) check if this is the right variable @@ -540,6 +542,8 @@ class _TopicItem extends StatelessWidget { topic))), const SizedBox(width: 12), if (hasMention) const _IconMarker(icon: ZulipIcons.at_sign), + // TODO(design) copies the "@" marker color; is there a better color? + if (visibilityIcon != null) _IconMarker(icon: visibilityIcon), Padding(padding: const EdgeInsetsDirectional.only(end: 16), child: UnreadCountBadge( backgroundColor: colorSwatchFor(context, subscription), diff --git a/test/widgets/inbox_test.dart b/test/widgets/inbox_test.dart index 82cc216189..b7ddbd7e23 100644 --- a/test/widgets/inbox_test.dart +++ b/test/widgets/inbox_test.dart @@ -305,6 +305,53 @@ void main() { }); }); + group('topic visibility', () { + final channel = eg.stream(); + const topic = 'topic'; + final message = eg.streamMessage(stream: channel, topic: topic); + + testWidgets('followed', (tester) async { + await setupPage(tester, + streams: [channel], + subscriptions: [eg.subscription(channel)], + unreadMessages: [message]); + await store.addUserTopic(channel, topic, UserTopicVisibilityPolicy.followed); + await tester.pump(); + check(hasIcon(tester, + parent: findRowByLabel(tester, topic), + icon: ZulipIcons.follow)).isTrue(); + }); + + testWidgets('followed and mentioned', (tester) async { + await setupPage(tester, + streams: [channel], + subscriptions: [eg.subscription(channel)], + unreadMessages: [eg.streamMessage(stream: channel, topic: topic, + flags: [MessageFlag.mentioned])]); + await store.addUserTopic(channel, topic, UserTopicVisibilityPolicy.followed); + await tester.pump(); + check(hasIcon(tester, + parent: findRowByLabel(tester, topic), + icon: ZulipIcons.follow)).isTrue(); + check(hasIcon(tester, + parent: findRowByLabel(tester, topic), + icon: ZulipIcons.at_sign)).isTrue(); + }); + + testWidgets('unmuted', (tester) async { + await setupPage(tester, + users: [eg.selfUser, eg.otherUser], + streams: [channel], + subscriptions: [eg.subscription(channel, isMuted: true)], + unreadMessages: [message]); + await store.addUserTopic(channel, topic, UserTopicVisibilityPolicy.unmuted); + await tester.pump(); + check(hasIcon(tester, + parent: findRowByLabel(tester, topic), + icon: ZulipIcons.unmute)).isTrue(); + }); + }); + group('collapsing', () { Icon findHeaderCollapseIcon(WidgetTester tester, Widget headerRow) { return tester.widget(