Skip to content

Commit 8ff7abd

Browse files
committed
msglist: Show topic visibility on app bar
The referenced design from the legacy mobile app displays the 'mute' icon when the channel is muted, replacing a privacy level related icon (e.g.: web public, invite only): https://github.com/zulip/zulip-mobile/blob/a115df1f71c9dc31e9b41060a8d57b51c017d786/src/streams/StreamIcon.js#L20-L29 We diverge from that in the Flutter app. We will have a different place to show channel mute/unmute status in zulip#347. This implementation also shows the corresponding icons for 'muted' and 'unmuted' topics; previously, only the icon for 'follow' was displayed. And we continue using the existing icons in the Flutter app, without trying to match the exact ones in the old design. Signed-off-by: Zixuan James Li <[email protected]>
1 parent da24a57 commit 8ff7abd

File tree

3 files changed

+48
-3
lines changed

3 files changed

+48
-3
lines changed

lib/widgets/icons.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,21 @@ IconData iconDataForStream(ZulipStream stream) {
139139
ZulipStream() => ZulipIcons.hash_sign,
140140
};
141141
}
142+
143+
IconData? iconDataForTopicVisibilityPolicy(UserTopicVisibilityPolicy policy) {
144+
switch (policy) {
145+
case UserTopicVisibilityPolicy.muted:
146+
return ZulipIcons.mute;
147+
case UserTopicVisibilityPolicy.unmuted:
148+
return ZulipIcons.unmute;
149+
case UserTopicVisibilityPolicy.followed:
150+
return ZulipIcons.follow;
151+
case UserTopicVisibilityPolicy.none:
152+
return null;
153+
case UserTopicVisibilityPolicy.unknown:
154+
// This case is unreachable (or should be) because we keep `unknown` out
155+
// of our data structures. We plan to remove the `unknown` case in #1074.
156+
assert(false);
157+
return null;
158+
}
159+
}

lib/widgets/message_list.dart

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,20 @@ class MessageListAppBarTitle extends StatelessWidget {
337337
required ZulipStream? stream,
338338
required String topic,
339339
}) {
340-
return Text(topic, style: const TextStyle(
341-
fontSize: 13,
342-
).merge(weightVariableTextStyle(context)));
340+
final store = PerAccountStoreWidget.of(context);
341+
final icon = (stream == null) ? null
342+
: iconDataForTopicVisibilityPolicy(
343+
store.topicVisibilityPolicy(stream.streamId, topic));
344+
return Row(
345+
children: [
346+
Flexible(child: Text(topic, style: const TextStyle(
347+
fontSize: 13,
348+
).merge(weightVariableTextStyle(context)))),
349+
if (icon != null)
350+
Padding(
351+
padding: const EdgeInsetsDirectional.only(start: 4),
352+
child: Opacity(opacity: 0.4, child: Icon(icon, size: 14))),
353+
]);
343354
}
344355

345356
@override

test/widgets/message_list_test.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,22 @@ void main() {
152152
.page.isA<MessageListPage>().initNarrow
153153
.equals(ChannelNarrow(channel.streamId));
154154
});
155+
156+
testWidgets('show topic visibility policy for topic narrows', (tester) async {
157+
final channel = eg.stream();
158+
const topic = 'topic';
159+
await setupMessageListPage(tester,
160+
narrow: TopicNarrow(channel.streamId, topic),
161+
streams: [channel], subscriptions: [eg.subscription(channel)],
162+
messageCount: 1);
163+
await store.handleEvent(eg.userTopicEvent(
164+
channel.streamId, topic, UserTopicVisibilityPolicy.muted));
165+
await tester.pump();
166+
167+
check(find.descendant(
168+
of: find.byType(MessageListAppBarTitle),
169+
matching: find.byIcon(ZulipIcons.mute))).findsOne();
170+
});
155171
});
156172

157173
group('presents message content appropriately', () {

0 commit comments

Comments
 (0)