Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit cf07bf8

Browse files
committedJun 1, 2024
subscription_list: Show muted streams as faded in streams list
Fixes: zulip#424
1 parent 544642a commit cf07bf8

File tree

2 files changed

+66
-21
lines changed

2 files changed

+66
-21
lines changed
 

‎lib/widgets/subscription_list.dart

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -212,28 +212,34 @@ class SubscriptionItem extends StatelessWidget {
212212
},
213213
child: Row(crossAxisAlignment: CrossAxisAlignment.center, children: [
214214
const SizedBox(width: 16),
215-
Padding(
216-
padding: const EdgeInsets.symmetric(vertical: 11),
217-
child: Icon(size: 18, color: swatch.iconOnPlainBackground,
218-
iconDataForStream(subscription))),
219-
const SizedBox(width: 5),
220215
Expanded(
221-
child: Padding(
222-
padding: const EdgeInsets.symmetric(vertical: 10),
223-
// TODO(design): unclear whether bold text is applied to all subscriptions
224-
// or only those with unreads:
225-
// https://github.com/zulip/zulip-flutter/pull/397#pullrequestreview-1742524205
226-
child: Text(
227-
style: const TextStyle(
228-
fontSize: 18,
229-
height: (20 / 18),
230-
// TODO(#95) need dark-theme color
231-
color: Color(0xFF262626),
232-
).merge(weightVariableTextStyle(context,
233-
wght: hasUnreads ? 600 : null)),
234-
maxLines: 1,
235-
overflow: TextOverflow.ellipsis,
236-
subscription.name))),
216+
child: Opacity(
217+
opacity: subscription.isMuted ? 0.55 : 1,
218+
child: Row(
219+
children: [
220+
Padding(
221+
padding: const EdgeInsets.symmetric(vertical: 11),
222+
child: Icon(size: 18, color: swatch.iconOnPlainBackground,
223+
iconDataForStream(subscription))),
224+
const SizedBox(width: 5),
225+
Expanded(
226+
child: Padding(
227+
padding: const EdgeInsets.symmetric(vertical: 10),
228+
// TODO(design): unclear whether bold text is applied to all subscriptions
229+
// or only those with unreads:
230+
// https://github.com/zulip/zulip-flutter/pull/397#pullrequestreview-1742524205
231+
child: Text(
232+
style: const TextStyle(
233+
fontSize: 18,
234+
height: (20 / 18),
235+
// TODO(#95) need dark-theme color
236+
color: Color(0xFF262626),
237+
).merge(weightVariableTextStyle(context,
238+
wght: hasUnreads ? 600 : null)),
239+
maxLines: 1,
240+
overflow: TextOverflow.ellipsis,
241+
subscription.name)))])),
242+
),
237243
if (unreadCount > 0) ...[
238244
const SizedBox(width: 12),
239245
// TODO(#384) show @-mention indicator when it applies

‎test/widgets/subscription_list_test.dart

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,4 +190,43 @@ void main() {
190190
check(tester.widget<UnreadCountBadge>(find.byType(UnreadCountBadge)).backgroundColor)
191191
.equals(swatch);
192192
});
193+
194+
testWidgets('muted streams are displayed as faded', (tester) async {
195+
final stream1 = eg.stream(name: 'Stream 1');
196+
final stream2 = eg.stream(streamId: 2, name: 'Stream 2');
197+
final unreadMsgs = eg.unreadMsgs(streams: [
198+
UnreadStreamSnapshot(streamId: stream1.streamId, topic: 'a', unreadMessageIds: [1, 2]),
199+
UnreadStreamSnapshot(streamId: stream2.streamId, topic: 'b', unreadMessageIds: [3]),
200+
]);
201+
await setupStreamListPage(tester,
202+
subscriptions: [
203+
eg.subscription(stream1, isMuted: true),
204+
eg.subscription(stream2, isMuted: false)
205+
],
206+
userTopics: [
207+
UserTopicItem(
208+
streamId: stream1.streamId,
209+
topicName: 'a',
210+
lastUpdated: 1234567890,
211+
visibilityPolicy: UserTopicVisibilityPolicy.unmuted,
212+
),
213+
UserTopicItem(
214+
streamId: stream2.streamId,
215+
topicName: 'b',
216+
lastUpdated: 1234567890,
217+
visibilityPolicy: UserTopicVisibilityPolicy.unmuted,
218+
),
219+
],
220+
unreadMsgs: unreadMsgs);
221+
222+
final stream1Finder = find.text('Stream 1');
223+
final stream1Opacity = tester.widget<Opacity>(
224+
find.ancestor(of: stream1Finder, matching: find.byType(Opacity))).opacity;
225+
check(stream1Opacity).equals(0.55);
226+
227+
final stream2Finder = find.text('Stream 2');
228+
final stream2Opacity = tester.widget<Opacity>(
229+
find.ancestor(of: stream2Finder, matching: find.byType(Opacity))).opacity;
230+
check(stream2Opacity).equals(1.0);
231+
});
193232
}

0 commit comments

Comments
 (0)
Please sign in to comment.