Skip to content

Commit

Permalink
inbox: Show topic visibility marker for topic items
Browse files Browse the repository at this point in the history
Signed-off-by: Zixuan James Li <[email protected]>
  • Loading branch information
PIG208 committed Dec 10, 2024
1 parent 1997ea3 commit 68cdf81
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/widgets/inbox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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),
Expand Down
50 changes: 50 additions & 0 deletions test/widgets/inbox_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,56 @@ 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,
users: [eg.selfUser, eg.otherUser],
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,
users: [eg.selfUser, eg.otherUser],
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(
Expand Down

0 comments on commit 68cdf81

Please sign in to comment.