Skip to content

Commit 65a15cd

Browse files
message list: Use channelTopicLabelSpan for app bar title.
1 parent a14da27 commit 65a15cd

File tree

2 files changed

+47
-27
lines changed

2 files changed

+47
-27
lines changed

lib/widgets/message_list.dart

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,7 @@ class MessageListAppBarTitle extends StatelessWidget {
529529
ZulipStream? stream,
530530
}) {
531531
final store = PerAccountStoreWidget.of(context);
532+
final designVariables = DesignVariables.of(context);
532533
final zulipLocalizations = ZulipLocalizations.of(context);
533534

534535
// A null [Icon.icon] makes a blank space.
@@ -547,10 +548,21 @@ class MessageListAppBarTitle extends StatelessWidget {
547548
// https://github.com/zulip/zulip-flutter/pull/219#discussion_r1281024746
548549
crossAxisAlignment: CrossAxisAlignment.center,
549550
children: [
550-
Icon(size: 16, color: iconColor, icon),
551-
const SizedBox(width: 4),
552-
Flexible(child: Text(
553-
stream?.name ?? zulipLocalizations.unknownChannelName)),
551+
if (stream != null)
552+
Flexible(child: Text.rich(
553+
channelTopicLabelSpan(
554+
context: context,
555+
channelId: stream.streamId,
556+
fontSize: 16,
557+
color: designVariables.unreadCountBadgeTextForChannel,
558+
)))
559+
else
560+
Flexible(child: Text(
561+
zulipLocalizations.unknownChannelName,
562+
style: TextStyle(
563+
fontStyle: FontStyle.italic,
564+
color: designVariables.unreadCountBadgeTextForChannel,
565+
))),
554566
]);
555567
}
556568

@@ -1719,22 +1731,29 @@ class StreamMessageRecipientHeader extends StatelessWidget {
17191731
child: Row(
17201732
crossAxisAlignment: CrossAxisAlignment.center,
17211733
children: [
1722-
Padding(
1723-
// Figma specifies 5px horizontal spacing around an icon that's
1724-
// 18x18 and includes 1px padding. The icon SVG is flush with
1725-
// the edges, so make it 16x16 with 6px horizontal padding.
1726-
// Bottom padding added here to shift icon up to
1727-
// match alignment with text visually.
1728-
padding: const EdgeInsets.only(left: 6, right: 6, bottom: 3),
1729-
child: Icon(size: 16, color: iconColor,
1730-
// A null [Icon.icon] makes a blank space.
1731-
stream != null ? iconDataForStream(stream) : null)),
1732-
Padding(
1733-
padding: const EdgeInsets.symmetric(vertical: 11),
1734-
child: Text(streamName,
1735-
style: recipientHeaderTextStyle(context),
1736-
overflow: TextOverflow.ellipsis),
1737-
),
1734+
if (stream != null)
1735+
Padding(
1736+
padding: const EdgeInsets.symmetric(vertical: 11),
1737+
child: Text.rich(
1738+
channelTopicLabelSpan(
1739+
context: context,
1740+
channelId: streamId,
1741+
fontSize: 16,
1742+
color: designVariables.unreadCountBadgeTextForChannel,
1743+
),
1744+
style: recipientHeaderTextStyle(context),
1745+
overflow: TextOverflow.ellipsis),
1746+
)
1747+
else
1748+
Padding(
1749+
padding: const EdgeInsets.symmetric(vertical: 11),
1750+
child: Text(streamName,
1751+
style: recipientHeaderTextStyle(context).copyWith(
1752+
fontStyle: FontStyle.italic,
1753+
color: designVariables.unreadCountBadgeTextForChannel,
1754+
),
1755+
overflow: TextOverflow.ellipsis),
1756+
),
17381757
Padding(
17391758
// Figma has 5px horizontal padding around an 8px wide icon.
17401759
// Icon is 16px wide here so horizontal padding is 1px.

test/widgets/message_list_test.dart

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ void main() {
119119
void checkAppBarChannelTopic(String channelName, String topic) {
120120
final appBarFinder = find.byType(MessageListAppBarTitle);
121121
check(appBarFinder).findsOne();
122-
check(find.descendant(of: appBarFinder, matching: find.text(channelName)))
122+
check(find.descendant(of: appBarFinder, matching: find.textContaining(channelName, findRichText: true)))
123123
.findsOne();
124-
check(find.descendant(of: appBarFinder, matching: find.text(topic)))
124+
check(find.descendant(of: appBarFinder, matching: find.textContaining(topic, findRichText: true)))
125125
.findsOne();
126126
}
127127

@@ -268,7 +268,8 @@ void main() {
268268
matching: find.byIcon(expectedIcon)));
269269

270270
check(Theme.brightnessOf(iconElement)).equals(Brightness.light);
271-
check(iconElement.widget as Icon).color.equals(Color(0xff5972fc));
271+
final swatch = ChannelColorSwatch.light(color);
272+
check(iconElement.widget as Icon).color.equals(swatch.iconOnPlainBackground);
272273
});
273274
}
274275
testChannelIconInChannelRow(ZulipIcons.globe, isWebPublic: true, inviteOnly: false);
@@ -1292,7 +1293,7 @@ void main() {
12921293
// Stream name shows up in [AppBar] so need to avoid matching that
12931294
return find.descendant(
12941295
of: find.byType(MessageList),
1295-
matching: find.text(text)).evaluate();
1296+
matching: find.textContaining(text, findRichText: true)).evaluate();
12961297
}
12971298

12981299
testWidgets('show stream name in CombinedFeedNarrow', (tester) async {
@@ -1407,7 +1408,7 @@ void main() {
14071408
subscriptions: [subscription]);
14081409
await tester.pump();
14091410
check(tester.widget<Icon>(find.byIcon(ZulipIcons.globe)))
1410-
.color.isNotNull().isSameColorAs(swatch.iconOnBarBackground);
1411+
.color.isNotNull().isSameColorAs(swatch.iconOnPlainBackground);
14111412
});
14121413

14131414
testWidgets('normal streams show hash icon', (tester) async {
@@ -1477,7 +1478,7 @@ void main() {
14771478
eg.streamMessage(stream: streamBefore),
14781479
]);
14791480
await tester.pump();
1480-
tester.widget(find.text('new stream name'));
1481+
tester.widget(find.textContaining('new stream name', findRichText: true));
14811482
});
14821483

14831484
testWidgets('navigates to ChannelNarrow on tapping channel in CombinedFeedNarrow', (tester) async {
@@ -1500,7 +1501,7 @@ void main() {
15001501
foundOldest: true, messages: [message]).toJson());
15011502
await tester.tap(find.descendant(
15021503
of: find.byType(StreamMessageRecipientHeader),
1503-
matching: find.text(channel.name)));
1504+
matching: find.textContaining(channel.name, findRichText: true)));
15041505
await tester.pump();
15051506
check(pushedRoutes).single.isA<WidgetRoute>().page.isA<MessageListPage>()
15061507
.initNarrow.equals(ChannelNarrow(channel.streamId));

0 commit comments

Comments
 (0)