Skip to content

Commit f25e276

Browse files
committed
subscription_list: Show muted streams as faded in streams list
Fixes: zulip#424
1 parent 53853ab commit f25e276

File tree

2 files changed

+71
-31
lines changed

2 files changed

+71
-31
lines changed

lib/widgets/subscription_list.dart

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -210,36 +210,39 @@ class SubscriptionItem extends StatelessWidget {
210210
MessageListPage.buildRoute(context: context,
211211
narrow: StreamNarrow(subscription.streamId)));
212212
},
213-
child: Row(crossAxisAlignment: CrossAxisAlignment.center, children: [
214-
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))),
237-
if (unreadCount > 0) ...[
238-
const SizedBox(width: 12),
239-
// TODO(#384) show @-mention indicator when it applies
240-
UnreadCountBadge(count: unreadCount, backgroundColor: swatch, bold: true),
241-
],
242-
const SizedBox(width: 16),
243-
])));
213+
child: Opacity(
214+
opacity: subscription.isMuted ? 0.55 : 1,
215+
child: Row(crossAxisAlignment: CrossAxisAlignment.center, children: [
216+
const SizedBox(width: 16),
217+
Padding(
218+
padding: const EdgeInsets.symmetric(vertical: 11),
219+
child: Icon(size: 18, color: swatch.iconOnPlainBackground,
220+
iconDataForStream(subscription))),
221+
const SizedBox(width: 5),
222+
Expanded(
223+
child: Padding(
224+
padding: const EdgeInsets.symmetric(vertical: 10),
225+
// TODO(design): unclear whether bold text is applied to all subscriptions
226+
// or only those with unreads:
227+
// https://github.com/zulip/zulip-flutter/pull/397#pullrequestreview-1742524205
228+
child: Text(
229+
style: const TextStyle(
230+
fontSize: 18,
231+
height: (20 / 18),
232+
// TODO(#95) need dark-theme color
233+
color: Color(0xFF262626),
234+
).merge(weightVariableTextStyle(context,
235+
wght: hasUnreads ? 600 : null)),
236+
maxLines: 1,
237+
overflow: TextOverflow.ellipsis,
238+
subscription.name))),
239+
if (unreadCount > 0) ...[
240+
const SizedBox(width: 12),
241+
// TODO(#384) show @-mention indicator when it applies
242+
UnreadCountBadge(count: unreadCount, backgroundColor: swatch, bold: true),
243+
],
244+
const SizedBox(width: 16),
245+
]),
246+
)));
244247
}
245248
}

test/widgets/subscription_list_test.dart

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,4 +190,41 @@ 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 stream = eg.stream(name: 'Channel 1');
196+
final stream2 = eg.stream(streamId: 2, name: 'Channel 2');
197+
final unreadMsgs = eg.unreadMsgs(streams: [
198+
UnreadStreamSnapshot(streamId: stream.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(stream, isMuted: true),
204+
eg.subscription(stream2, isMuted: false)
205+
],
206+
userTopics: [
207+
UserTopicItem(
208+
streamId: stream.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 channel1Finder = find.text('Channel 1');
223+
final channel1Opacity = tester.widget<Opacity>(find.ancestor(of: channel1Finder, matching: find.byType(Opacity))).opacity;
224+
check(channel1Opacity).isLessThan(1.0);
225+
226+
final channel2Finder = find.text('Channel 2');
227+
final channel2Opacity = tester.widget<Opacity>(find.ancestor(of: channel2Finder, matching: find.byType(Opacity))).opacity;
228+
check(channel2Opacity).equals(1.0);
229+
});
193230
}

0 commit comments

Comments
 (0)