Skip to content

Commit 9f18c53

Browse files
PIG208gnprice
authored andcommitted
inbox: Show topic visibility marker for topic items
Signed-off-by: Zixuan James Li <[email protected]>
1 parent 4404537 commit 9f18c53

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-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

+47
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,53 @@ 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+
streams: [channel],
316+
subscriptions: [eg.subscription(channel)],
317+
unreadMessages: [message]);
318+
await store.addUserTopic(channel, topic, UserTopicVisibilityPolicy.followed);
319+
await tester.pump();
320+
check(hasIcon(tester,
321+
parent: findRowByLabel(tester, topic),
322+
icon: ZulipIcons.follow)).isTrue();
323+
});
324+
325+
testWidgets('followed and mentioned', (tester) async {
326+
await setupPage(tester,
327+
streams: [channel],
328+
subscriptions: [eg.subscription(channel)],
329+
unreadMessages: [eg.streamMessage(stream: channel, topic: topic,
330+
flags: [MessageFlag.mentioned])]);
331+
await store.addUserTopic(channel, topic, UserTopicVisibilityPolicy.followed);
332+
await tester.pump();
333+
check(hasIcon(tester,
334+
parent: findRowByLabel(tester, topic),
335+
icon: ZulipIcons.follow)).isTrue();
336+
check(hasIcon(tester,
337+
parent: findRowByLabel(tester, topic),
338+
icon: ZulipIcons.at_sign)).isTrue();
339+
});
340+
341+
testWidgets('unmuted', (tester) async {
342+
await setupPage(tester,
343+
users: [eg.selfUser, eg.otherUser],
344+
streams: [channel],
345+
subscriptions: [eg.subscription(channel, isMuted: true)],
346+
unreadMessages: [message]);
347+
await store.addUserTopic(channel, topic, UserTopicVisibilityPolicy.unmuted);
348+
await tester.pump();
349+
check(hasIcon(tester,
350+
parent: findRowByLabel(tester, topic),
351+
icon: ZulipIcons.unmute)).isTrue();
352+
});
353+
});
354+
308355
group('collapsing', () {
309356
Icon findHeaderCollapseIcon(WidgetTester tester, Widget headerRow) {
310357
return tester.widget(

0 commit comments

Comments
 (0)