Skip to content

Commit 0620510

Browse files
committed
subscription_list: Show muted streams as faded in streams list
Fixes: zulip#424
1 parent 544642a commit 0620510

File tree

2 files changed

+65
-22
lines changed

2 files changed

+65
-22
lines changed

lib/widgets/subscription_list.dart

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -212,28 +212,32 @@ 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),
220-
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))),
215+
Opacity(
216+
opacity: subscription.isMuted ? 0.55 : 1,
217+
child: Row(
218+
children: [
219+
Padding(
220+
padding: const EdgeInsets.symmetric(vertical: 11),
221+
child: Icon(size: 18, color: swatch.iconOnPlainBackground,
222+
iconDataForStream(subscription))),
223+
const SizedBox(width: 5),
224+
Expanded(
225+
child: Padding(
226+
padding: const EdgeInsets.symmetric(vertical: 10),
227+
// TODO(design): unclear whether bold text is applied to all subscriptions
228+
// or only those with unreads:
229+
// https://github.com/zulip/zulip-flutter/pull/397#pullrequestreview-1742524205
230+
child: Text(
231+
style: const TextStyle(
232+
fontSize: 18,
233+
height: (20 / 18),
234+
// TODO(#95) need dark-theme color
235+
color: Color(0xFF262626),
236+
).merge(weightVariableTextStyle(context,
237+
wght: hasUnreads ? 600 : null)),
238+
maxLines: 1,
239+
overflow: TextOverflow.ellipsis,
240+
subscription.name)))])),
237241
if (unreadCount > 0) ...[
238242
const SizedBox(width: 12),
239243
// 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)