Skip to content

Commit b3456df

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 1815326 commit b3456df

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-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: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import 'package:zulip/widgets/app.dart';
77
import 'package:zulip/widgets/icons.dart';
88
import 'package:zulip/widgets/stream_colors.dart';
99
import 'package:zulip/widgets/subscription_list.dart';
10+
import 'package:zulip/widgets/text.dart';
1011
import 'package:zulip/widgets/unread_count_badge.dart';
1112

1213
import '../flutter_checks.dart';
@@ -235,4 +236,43 @@ void main() {
235236
checkOpacityForStreamAndBadge('Stream 1', 2, 0.55);
236237
checkOpacityForStreamAndBadge('Stream 2', 1, 1.0);
237238
});
239+
240+
testWidgets('stream name of unmuted streams with unmuted unreads is bold', (tester) async {
241+
void checkStreamNameWght(String streamName, double? expectedWght) {
242+
final streamFinder = find.text(streamName);
243+
final wght = wghtFromTextStyle(tester.widget<Text>(streamFinder).style!);
244+
check(wght).equals(expectedWght);
245+
}
246+
247+
final unmutedStreamWithUnmutedUnreads = eg.stream(name: 'Unmuted stream with unmuted unreads');
248+
final unmutedStreamWithNoUnmutedUnreads = eg.stream(name: 'Unmuted stream with no unmuted unreads');
249+
final mutedStreamWithUnmutedUnreads = eg.stream(name: 'Muted stream with unmuted unreads');
250+
final mutedStreamWithNoUnmutedUnreads = eg.stream(name: 'Muted stream with no unmuted unreads');
251+
252+
await setupStreamListPage(tester,
253+
subscriptions: [
254+
eg.subscription(unmutedStreamWithUnmutedUnreads, isMuted: false),
255+
eg.subscription(unmutedStreamWithNoUnmutedUnreads, isMuted: false),
256+
eg.subscription(mutedStreamWithUnmutedUnreads, isMuted: true),
257+
eg.subscription(mutedStreamWithNoUnmutedUnreads, isMuted: true),
258+
],
259+
userTopics: [
260+
eg.userTopicItem(unmutedStreamWithUnmutedUnreads, 'a', UserTopicVisibilityPolicy.unmuted),
261+
eg.userTopicItem(unmutedStreamWithNoUnmutedUnreads, 'b', UserTopicVisibilityPolicy.muted),
262+
eg.userTopicItem(mutedStreamWithUnmutedUnreads, 'c', UserTopicVisibilityPolicy.unmuted),
263+
eg.userTopicItem(mutedStreamWithNoUnmutedUnreads, 'd', UserTopicVisibilityPolicy.muted),
264+
],
265+
unreadMsgs: eg.unreadMsgs(streams: [
266+
UnreadStreamSnapshot(streamId: unmutedStreamWithUnmutedUnreads.streamId, topic: 'a', unreadMessageIds: [1]),
267+
UnreadStreamSnapshot(streamId: unmutedStreamWithNoUnmutedUnreads.streamId, topic: 'b', unreadMessageIds: [2]),
268+
UnreadStreamSnapshot(streamId: mutedStreamWithUnmutedUnreads.streamId, topic: 'c', unreadMessageIds: [3]),
269+
UnreadStreamSnapshot(streamId: mutedStreamWithNoUnmutedUnreads.streamId, topic: 'd', unreadMessageIds: [4]),
270+
]),
271+
);
272+
273+
checkStreamNameWght(unmutedStreamWithUnmutedUnreads.name, 600);
274+
checkStreamNameWght(unmutedStreamWithNoUnmutedUnreads.name, 400);
275+
checkStreamNameWght(mutedStreamWithUnmutedUnreads.name, 400);
276+
checkStreamNameWght(mutedStreamWithNoUnmutedUnreads.name, 400);
277+
});
238278
}

0 commit comments

Comments
 (0)