Skip to content

Commit 5d80ad5

Browse files
Khader-1gnprice
authored andcommitted
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 e51d2f2 commit 5d80ad5

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
@@ -246,7 +246,7 @@ class SubscriptionItem extends StatelessWidget {
246246
// TODO(design) check if this is the right variable
247247
color: designVariables.labelMenuButton,
248248
).merge(weightVariableTextStyle(context,
249-
wght: hasUnreads ? 600 : null)),
249+
wght: hasUnreads && !subscription.isMuted ? 600 : null)),
250250
maxLines: 1,
251251
overflow: TextOverflow.ellipsis,
252252
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/channel_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(channels: [
264+
UnreadChannelSnapshot(streamId: unmutedStreamWithUnmutedUnreads.streamId, topic: 'a', unreadMessageIds: [1]),
265+
UnreadChannelSnapshot(streamId: unmutedStreamWithNoUnmutedUnreads.streamId, topic: 'b', unreadMessageIds: [2]),
266+
UnreadChannelSnapshot(streamId: mutedStreamWithUnmutedUnreads.streamId, topic: 'c', unreadMessageIds: [3]),
267+
UnreadChannelSnapshot(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)