Skip to content

Commit 32e3bf6

Browse files
committed
subscription_list: Show muted streams as faded in streams list
Fixes: zulip#424
1 parent c2ff0fc commit 32e3bf6

File tree

2 files changed

+60
-14
lines changed

2 files changed

+60
-14
lines changed

lib/widgets/subscription_list.dart

+27-14
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ class SubscriptionItem extends StatelessWidget {
209209
Widget build(BuildContext context) {
210210
final swatch = colorSwatchFor(context, subscription);
211211
final hasUnreads = (unreadCount > 0);
212+
final opacity = subscription.isMuted ? 0.55 : 1.0;
212213
return Material(
213214
// TODO(#95) need dark-theme color
214215
color: Colors.white,
@@ -222,30 +223,42 @@ class SubscriptionItem extends StatelessWidget {
222223
const SizedBox(width: 16),
223224
Padding(
224225
padding: const EdgeInsets.symmetric(vertical: 11),
225-
child: Icon(size: 18, color: swatch.iconOnPlainBackground,
226-
iconDataForStream(subscription))),
226+
child: Opacity(
227+
opacity: opacity,
228+
child: Icon(size: 18, color: swatch.iconOnPlainBackground,
229+
iconDataForStream(subscription)),
230+
),
231+
),
227232
const SizedBox(width: 5),
228233
Expanded(
229234
child: Padding(
230235
padding: const EdgeInsets.symmetric(vertical: 10),
231236
// TODO(design): unclear whether bold text is applied to all subscriptions
232237
// or only those with unreads:
233238
// 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))),
239+
child: Opacity(
240+
opacity: opacity,
241+
child: Text(
242+
style: const TextStyle(
243+
fontSize: 18,
244+
height: (20 / 18),
245+
// TODO(#95) need dark-theme color
246+
color: Color(0xFF262626),
247+
).merge(weightVariableTextStyle(context,
248+
wght: hasUnreads ? 600 : null)),
249+
maxLines: 1,
250+
overflow: TextOverflow.ellipsis,
251+
subscription.name),
252+
))),
245253
if (unreadCount > 0) ...[
246254
const SizedBox(width: 12),
247255
// TODO(#747) show @-mention indicator when it applies
248-
UnreadCountBadge(count: unreadCount, backgroundColor: swatch, bold: true),
256+
Opacity(
257+
opacity: opacity,
258+
child: UnreadCountBadge(
259+
count: unreadCount,
260+
backgroundColor: swatch,
261+
bold: true)),
249262
],
250263
const SizedBox(width: 16),
251264
])));

test/widgets/subscription_list_test.dart

+33
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,37 @@ 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+
void checkOpacityForStreamAndBadge(String streamName, int unreadCount, double opacity) {
208+
final streamFinder = find.text(streamName);
209+
final streamOpacity = tester.widget<Opacity>(
210+
find.ancestor(of: streamFinder, matching: find.byType(Opacity)));
211+
final badgeFinder = find.text('$unreadCount');
212+
final badgeOpacity = tester.widget<Opacity>(
213+
find.ancestor(of: badgeFinder, matching: find.byType(Opacity)));
214+
check(streamOpacity.opacity).equals(opacity);
215+
check(badgeOpacity.opacity).equals(opacity);
216+
}
217+
218+
final stream1 = eg.stream(name: 'Stream 1');
219+
final stream2 = eg.stream(name: 'Stream 2');
220+
await setupStreamListPage(tester,
221+
subscriptions: [
222+
eg.subscription(stream1, isMuted: true),
223+
eg.subscription(stream2, isMuted: false)
224+
],
225+
userTopics: [
226+
eg.userTopicItem(stream1, 'a', UserTopicVisibilityPolicy.unmuted),
227+
eg.userTopicItem(stream2, 'b', UserTopicVisibilityPolicy.unmuted),
228+
],
229+
unreadMsgs: eg.unreadMsgs(streams: [
230+
UnreadStreamSnapshot(streamId: stream1.streamId, topic: 'a', unreadMessageIds: [1, 2]),
231+
UnreadStreamSnapshot(streamId: stream2.streamId, topic: 'b', unreadMessageIds: [3])
232+
]),
233+
);
234+
235+
checkOpacityForStreamAndBadge('Stream 1', 2, 0.55);
236+
checkOpacityForStreamAndBadge('Stream 2', 1, 1.0);
237+
});
205238
}

0 commit comments

Comments
 (0)