Skip to content

Commit 384050c

Browse files
committed
inbox: Show topic visibility marker for topic items
Signed-off-by: Zixuan James Li <[email protected]>
1 parent 2aca67b commit 384050c

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

lib/widgets/inbox.dart

+4
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,8 @@ class _TopicItem extends StatelessWidget {
514514
final subscription = store.subscriptions[streamId]!;
515515

516516
final designVariables = DesignVariables.of(context);
517+
final visibilityIcon = iconDataForTopicVisibilityPolicy(
518+
store.topicVisibilityPolicy(streamId, topic));
517519

518520
return Material(
519521
color: designVariables.background, // TODO(design) check if this is the right variable
@@ -540,6 +542,8 @@ class _TopicItem extends StatelessWidget {
540542
topic))),
541543
const SizedBox(width: 12),
542544
if (hasMention) const _IconMarker(icon: ZulipIcons.at_sign),
545+
// TODO(design) copies the "@" marker color; is there a better color?
546+
if (visibilityIcon != null) _IconMarker(icon: visibilityIcon),
543547
Padding(padding: const EdgeInsetsDirectional.only(end: 16),
544548
child: UnreadCountBadge(
545549
backgroundColor: colorSwatchFor(context, subscription),

test/widgets/inbox_test.dart

+50
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,56 @@ void main() {
305305
});
306306
});
307307

308+
group('topic visibility', () {
309+
final channel = eg.stream();
310+
const topic = 'topic';
311+
final message = eg.streamMessage(stream: channel, topic: topic);
312+
313+
testWidgets('followed', (tester) async {
314+
await setupPage(tester,
315+
users: [eg.selfUser, eg.otherUser],
316+
streams: [channel],
317+
subscriptions: [eg.subscription(channel)],
318+
unreadMessages: [message]);
319+
await store.addUserTopic(channel, topic, UserTopicVisibilityPolicy.followed);
320+
await tester.pump();
321+
check(hasIcon(tester,
322+
parent: findRowByLabel(tester, topic),
323+
icon: ZulipIcons.follow)).isTrue();
324+
});
325+
326+
testWidgets('followed and mentioned', (tester) async {
327+
await setupPage(tester,
328+
users: [eg.selfUser, eg.otherUser],
329+
streams: [channel],
330+
subscriptions: [eg.subscription(channel)],
331+
unreadMessages: [eg.streamMessage(stream: channel, topic: topic,
332+
flags: [MessageFlag.mentioned])]);
333+
await store.addUserTopic(channel, topic, UserTopicVisibilityPolicy.followed);
334+
await tester.pump();
335+
check(hasIcon(tester,
336+
parent: findRowByLabel(tester, topic),
337+
icon: ZulipIcons.follow)).isTrue();
338+
check(hasIcon(tester,
339+
parent: findRowByLabel(tester, topic),
340+
icon: ZulipIcons.at_sign)).isTrue();
341+
});
342+
343+
344+
testWidgets('unmuted', (tester) async {
345+
await setupPage(tester,
346+
users: [eg.selfUser, eg.otherUser],
347+
streams: [channel],
348+
subscriptions: [eg.subscription(channel, isMuted: true)],
349+
unreadMessages: [message]);
350+
await store.addUserTopic(channel, topic, UserTopicVisibilityPolicy.unmuted);
351+
await tester.pump();
352+
check(hasIcon(tester,
353+
parent: findRowByLabel(tester, topic),
354+
icon: ZulipIcons.unmute)).isTrue();
355+
});
356+
});
357+
308358
group('collapsing', () {
309359
Icon findHeaderCollapseIcon(WidgetTester tester, Widget headerRow) {
310360
return tester.widget(

0 commit comments

Comments
 (0)