Skip to content

Commit ca5caee

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 84b64fc commit ca5caee

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
@@ -6,6 +6,7 @@ import 'package:zulip/api/model/model.dart';
66
import 'package:zulip/widgets/icons.dart';
77
import 'package:zulip/widgets/stream_colors.dart';
88
import 'package:zulip/widgets/subscription_list.dart';
9+
import 'package:zulip/widgets/text.dart';
910
import 'package:zulip/widgets/unread_count_badge.dart';
1011

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

0 commit comments

Comments
 (0)