Skip to content

Commit a9fdb97

Browse files
committed
subscription_list: Ensure bold name applies for unmuted streams only
If a stream is muted but has unmuted unreads it should not be bolded.
1 parent 2393a19 commit a9fdb97

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

lib/widgets/subscription_list.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ class SubscriptionItem extends StatelessWidget {
243243
// TODO(#95) need dark-theme color
244244
color: Color(0xFF262626),
245245
).merge(weightVariableTextStyle(context,
246-
wght: hasUnreads ? 600 : null)),
246+
wght: hasUnreads && !subscription.isMuted ? 600 : null)),
247247
maxLines: 1,
248248
overflow: TextOverflow.ellipsis,
249249
subscription.name)))),

test/widgets/subscription_list_test.dart

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,4 +235,43 @@ void main() {
235235
checkOpacityForStreamAndBadge('Stream 1', 2, 0.55);
236236
checkOpacityForStreamAndBadge('Stream 2', 1, 1.0);
237237
});
238+
239+
testWidgets('stream name of unmuted streams with unmuted unreads is bold', (tester) async {
240+
void checkOpacityForStreamAndBadge(String streamName, int? fontWeight) {
241+
final streamFinder = find.text(streamName);
242+
final foundWeight = tester.widget<Text>(streamFinder).style?.fontWeight?.value;
243+
check(foundWeight).equals(fontWeight);
244+
}
245+
246+
final unmutedStreamWithUnmutedUnreads = eg.stream(name: 'Unmuted stream with unmuted unreads');
247+
final unmutedStreamWithNoUnmutedUnreads = eg.stream(name: 'Unmuted stream with no unmuted unreads');
248+
final mutedStreamWithUnmutedUnreads = eg.stream(name: 'Muted stream with unmuted unreads');
249+
final mutedStreamWithNoUnmutedUnreads = eg.stream(name: 'Muted stream with no unmuted unreads');
250+
251+
await setupStreamListPage(tester,
252+
subscriptions: [
253+
eg.subscription(unmutedStreamWithUnmutedUnreads, isMuted: false),
254+
eg.subscription(unmutedStreamWithNoUnmutedUnreads, isMuted: false),
255+
eg.subscription(mutedStreamWithUnmutedUnreads, isMuted: true),
256+
eg.subscription(mutedStreamWithNoUnmutedUnreads, isMuted: true),
257+
],
258+
userTopics: [
259+
eg.userTopicItem(unmutedStreamWithUnmutedUnreads, 'a', UserTopicVisibilityPolicy.unmuted),
260+
eg.userTopicItem(unmutedStreamWithNoUnmutedUnreads, 'b', UserTopicVisibilityPolicy.muted),
261+
eg.userTopicItem(mutedStreamWithUnmutedUnreads, 'c', UserTopicVisibilityPolicy.unmuted),
262+
eg.userTopicItem(mutedStreamWithNoUnmutedUnreads, 'd', UserTopicVisibilityPolicy.muted),
263+
],
264+
unreadMsgs: eg.unreadMsgs(streams: [
265+
UnreadStreamSnapshot(streamId: unmutedStreamWithUnmutedUnreads.streamId, topic: 'a', unreadMessageIds: [1]),
266+
UnreadStreamSnapshot(streamId: unmutedStreamWithNoUnmutedUnreads.streamId, topic: 'b', unreadMessageIds: [2]),
267+
UnreadStreamSnapshot(streamId: mutedStreamWithUnmutedUnreads.streamId, topic: 'c', unreadMessageIds: [2]),
268+
UnreadStreamSnapshot(streamId: mutedStreamWithNoUnmutedUnreads.streamId, topic: 'd', unreadMessageIds: [2]),
269+
]),
270+
);
271+
272+
checkOpacityForStreamAndBadge(unmutedStreamWithUnmutedUnreads.name, 600);
273+
checkOpacityForStreamAndBadge(unmutedStreamWithNoUnmutedUnreads.name, 400);
274+
checkOpacityForStreamAndBadge(mutedStreamWithUnmutedUnreads.name, 400);
275+
checkOpacityForStreamAndBadge(mutedStreamWithNoUnmutedUnreads.name, 400);
276+
});
238277
}

0 commit comments

Comments
 (0)