Skip to content

Commit 24d9bc1

Browse files
committed
subscription_list: Show muted streams as faded in streams list
Fixes: zulip#424
1 parent 8deade9 commit 24d9bc1

File tree

2 files changed

+75
-22
lines changed

2 files changed

+75
-22
lines changed

lib/widgets/subscription_list.dart

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -220,32 +220,42 @@ class SubscriptionItem extends StatelessWidget {
220220
},
221221
child: Row(crossAxisAlignment: CrossAxisAlignment.center, children: [
222222
const SizedBox(width: 16),
223-
Padding(
224-
padding: const EdgeInsets.symmetric(vertical: 11),
225-
child: Icon(size: 18, color: swatch.iconOnPlainBackground,
226-
iconDataForStream(subscription))),
227-
const SizedBox(width: 5),
228223
Expanded(
229-
child: Padding(
230-
padding: const EdgeInsets.symmetric(vertical: 10),
231-
// TODO(design): unclear whether bold text is applied to all subscriptions
232-
// or only those with unreads:
233-
// https://github.com/zulip/zulip-flutter/pull/397#pullrequestreview-1742524205
234-
child: Text(
235-
style: const TextStyle(
236-
fontSize: 18,
237-
height: (20 / 18),
238-
// TODO(#95) need dark-theme color
239-
color: Color(0xFF262626),
240-
).merge(weightVariableTextStyle(context,
241-
wght: hasUnreads ? 600 : null)),
242-
maxLines: 1,
243-
overflow: TextOverflow.ellipsis,
244-
subscription.name))),
224+
child: Opacity(
225+
opacity: subscription.isMuted ? 0.55 : 1,
226+
child: Row(
227+
children: [
228+
Padding(
229+
padding: const EdgeInsets.symmetric(vertical: 11),
230+
child: Icon(size: 18, color: swatch.iconOnPlainBackground,
231+
iconDataForStream(subscription))),
232+
const SizedBox(width: 5),
233+
Expanded(
234+
child: Padding(
235+
padding: const EdgeInsets.symmetric(vertical: 10),
236+
// TODO(design): unclear whether bold text is applied to all subscriptions
237+
// or only those with unreads:
238+
// https://github.com/zulip/zulip-flutter/pull/397#pullrequestreview-1742524205
239+
child: Text(
240+
style: const TextStyle(
241+
fontSize: 18,
242+
height: (20 / 18),
243+
// TODO(#95) need dark-theme color
244+
color: Color(0xFF262626),
245+
).merge(weightVariableTextStyle(context,
246+
wght: hasUnreads ? 600 : null)),
247+
maxLines: 1,
248+
overflow: TextOverflow.ellipsis,
249+
subscription.name)))]))),
245250
if (unreadCount > 0) ...[
246251
const SizedBox(width: 12),
247252
// TODO(#747) show @-mention indicator when it applies
248-
UnreadCountBadge(count: unreadCount, backgroundColor: swatch, bold: true),
253+
Opacity(
254+
opacity: subscription.isMuted ? 0.55 : 1,
255+
child: UnreadCountBadge(
256+
count: unreadCount,
257+
backgroundColor: swatch,
258+
bold: true)),
249259
],
250260
const SizedBox(width: 16),
251261
])));

test/widgets/subscription_list_test.dart

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,47 @@ void main() {
202202
check(tester.widget<UnreadCountBadge>(find.byType(UnreadCountBadge)).backgroundColor)
203203
.equals(swatch);
204204
});
205+
206+
testWidgets('muted streams are displayed as faded', (tester) async {
207+
208+
testOpacityForStreamAndBadge(String streamName, double opacity) {
209+
final streamFinder = find.text(streamName);
210+
final streamOpacity = tester.widget<Opacity>(
211+
find.ancestor(of: streamFinder, matching: find.byType(Opacity))).opacity;
212+
final badgeOpacity = tester.widget<Opacity>(find.ancestor(of: find.descendant(
213+
of: find.ancestor(of: streamFinder, matching: find.byType(Row)),
214+
matching: find.byType(UnreadCountBadge)), matching: find.byType(Opacity))).opacity;
215+
check(streamOpacity).equals(opacity);
216+
check(badgeOpacity).equals(opacity);
217+
}
218+
219+
final stream1 = eg.stream(name: 'Stream 1');
220+
final stream2 = eg.stream(name: 'Stream 2');
221+
final unreadMsgs = eg.unreadMsgs(streams: [
222+
UnreadStreamSnapshot(streamId: stream1.streamId, topic: 'a', unreadMessageIds: [1, 2]),
223+
UnreadStreamSnapshot(streamId: stream2.streamId, topic: 'b', unreadMessageIds: [3]),
224+
]);
225+
await setupStreamListPage(tester,
226+
subscriptions: [
227+
eg.subscription(stream1, isMuted: true),
228+
eg.subscription(stream2, isMuted: false)
229+
],
230+
userTopics: [
231+
UserTopicItem(
232+
streamId: stream1.streamId,
233+
topicName: 'a',
234+
lastUpdated: 1234567890,
235+
visibilityPolicy: UserTopicVisibilityPolicy.unmuted,
236+
),
237+
UserTopicItem(
238+
streamId: stream2.streamId,
239+
topicName: 'b',
240+
lastUpdated: 1234567890,
241+
visibilityPolicy: UserTopicVisibilityPolicy.unmuted,
242+
),
243+
], unreadMsgs: unreadMsgs);
244+
245+
testOpacityForStreamAndBadge('Stream 1', 0.55);
246+
testOpacityForStreamAndBadge('Stream 2', 1.0);
247+
});
205248
}

0 commit comments

Comments
 (0)