Skip to content

Commit 6bf222f

Browse files
committed
subscription_list: Show muted streams as faded in streams list
Fixes: zulip#424
1 parent ada9a09 commit 6bf222f

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(children: [
227+
Padding(
228+
padding: const EdgeInsets.symmetric(vertical: 11),
229+
child: Icon(size: 18, color: swatch.iconOnPlainBackground,
230+
iconDataForStream(subscription))),
231+
const SizedBox(width: 5),
232+
Expanded(
233+
child: Padding(
234+
padding: const EdgeInsets.symmetric(vertical: 10),
235+
// TODO(design): unclear whether bold text is applied to all subscriptions
236+
// or only those with unreads:
237+
// https://github.com/zulip/zulip-flutter/pull/397#pullrequestreview-1742524205
238+
child: Text(
239+
style: const TextStyle(
240+
fontSize: 18,
241+
height: (20 / 18),
242+
// TODO(#95) need dark-theme color
243+
color: Color(0xFF262626),
244+
).merge(weightVariableTextStyle(context,
245+
wght: hasUnreads ? 600 : null)),
246+
maxLines: 1,
247+
overflow: TextOverflow.ellipsis,
248+
subscription.name))),
249+
]))),
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+
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+
UserTopicItem(
227+
streamId: stream1.streamId,
228+
topicName: 'a',
229+
lastUpdated: 1234567890,
230+
visibilityPolicy: UserTopicVisibilityPolicy.unmuted,
231+
),
232+
UserTopicItem(
233+
streamId: stream2.streamId,
234+
topicName: 'b',
235+
lastUpdated: 1234567890,
236+
visibilityPolicy: UserTopicVisibilityPolicy.unmuted,
237+
),
238+
],
239+
unreadMsgs: eg.unreadMsgs(streams: [
240+
UnreadStreamSnapshot(streamId: stream1.streamId, topic: 'a', unreadMessageIds: [1, 2]),
241+
UnreadStreamSnapshot(streamId: stream2.streamId, topic: 'b', unreadMessageIds: [3]),
242+
]),
243+
);
244+
245+
checkOpacityForStreamAndBadge('Stream 1', 2, 0.55);
246+
checkOpacityForStreamAndBadge('Stream 2', 1, 1.0);
247+
});
205248
}

0 commit comments

Comments
 (0)