Skip to content

Commit b0b8a50

Browse files
Khader-1gnprice
authored andcommitted
subscription_list: Show muted streams as faded in streams list
Fixes: #424
1 parent a9ad78e commit b0b8a50

File tree

2 files changed

+57
-14
lines changed

2 files changed

+57
-14
lines changed

lib/widgets/subscription_list.dart

+24-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,39 @@ 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)))),
227230
const SizedBox(width: 5),
228231
Expanded(
229232
child: Padding(
230233
padding: const EdgeInsets.symmetric(vertical: 10),
231234
// TODO(design): unclear whether bold text is applied to all subscriptions
232235
// or only those with unreads:
233236
// 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))),
237+
child: Opacity(
238+
opacity: opacity,
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: opacity,
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

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