Skip to content

Commit a14da27

Browse files
channel rows: Use channelTopicLabelSpan for consistent alignment.
1 parent 9296fb3 commit a14da27

File tree

6 files changed

+75
-24
lines changed

6 files changed

+75
-24
lines changed

lib/widgets/all_channels.dart

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,20 +106,21 @@ class AllChannelsListEntry extends StatelessWidget {
106106
child: ConstrainedBox(constraints: const BoxConstraints(minHeight: 44),
107107
child: Padding(padding: const EdgeInsetsDirectional.only(start: 8, end: 12),
108108
child: Row(spacing: 6, children: [
109-
Icon(
110-
size: 20,
111-
color: colorSwatchFor(context, subscription).iconOnPlainBackground,
112-
iconDataForStream(channel)),
113109
Expanded(
114-
child: Text(
110+
child: Text.rich(
115111
maxLines: 1,
116112
overflow: TextOverflow.ellipsis,
117113
style: TextStyle(
118114
color: designVariables.textMessage,
119115
fontSize: 17,
120116
height: 20 / 17,
121117
).merge(weightVariableTextStyle(context, wght: 600)),
122-
channel.name)),
118+
channelTopicLabelSpan(
119+
context: context,
120+
channelId: channel.streamId,
121+
fontSize: 16,
122+
color: designVariables.unreadCountBadgeTextForChannel,
123+
))),
123124
if (hasContentAccess) _SubscribeToggle(channel: channel),
124125
]))));
125126
}

lib/widgets/inbox.dart

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,8 @@ abstract class _HeaderItem extends StatelessWidget {
305305
).merge(weightVariableTextStyle(context, wght: 600)),
306306
maxLines: 1,
307307
overflow: TextOverflow.ellipsis,
308-
title(zulipLocalizations)))),
308+
title(zulipLocalizations))
309+
)),
309310
const SizedBox(width: 12),
310311
if (hasMention) const _IconMarker(icon: ZulipIcons.at_sign),
311312
Padding(padding: const EdgeInsetsDirectional.only(end: 16),
@@ -480,6 +481,53 @@ class _StreamHeaderItem extends _HeaderItem with _LongPressable {
480481
Future<void> onLongPress() async {
481482
showChannelActionSheet(sectionContext, channelId: subscription.streamId);
482483
}
484+
@override
485+
Widget build(BuildContext context) {
486+
final zulipLocalizations = ZulipLocalizations.of(context);
487+
final designVariables = DesignVariables.of(context);
488+
return Material(
489+
color: collapsed
490+
? designVariables.background // TODO(design) check if this is the right variable
491+
: uncollapsedBackgroundColor(context),
492+
child: InkWell(
493+
// TODO use onRowTap to handle taps that are not on the collapse button.
494+
// Probably we should give the collapse button a 44px or 48px square
495+
// touch target:
496+
// <https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/flutter.3A.20Mark-as-read/near/1680973>
497+
// But that's in tension with the Figma, which gives these header rows
498+
// 40px min height.
499+
onTap: onCollapseButtonTap,
500+
onLongPress: onLongPress,
501+
child: Row(crossAxisAlignment: CrossAxisAlignment.center, children: [
502+
Padding(padding: const EdgeInsets.all(10),
503+
child: Icon(size: 20, color: designVariables.sectionCollapseIcon,
504+
collapsed ? ZulipIcons.arrow_right : ZulipIcons.arrow_down)),
505+
const SizedBox(width: 5),
506+
Expanded(child: Padding(
507+
padding: const EdgeInsets.symmetric(vertical: 4),
508+
child: Text.rich(
509+
style: TextStyle(
510+
fontSize: 17,
511+
height: (20 / 17),
512+
// TODO(design) check if this is the right variable
513+
color: designVariables.labelMenuButton,
514+
).merge(weightVariableTextStyle(context, wght: 600)),
515+
maxLines: 1,
516+
overflow: TextOverflow.ellipsis,
517+
channelTopicLabelSpan(
518+
context: context,
519+
channelId: subscription.streamId,
520+
fontSize: 16,
521+
color: designVariables.unreadCountBadgeTextForChannel,
522+
)))),
523+
const SizedBox(width: 12),
524+
if (hasMention) const _IconMarker(icon: ZulipIcons.at_sign),
525+
Padding(padding: const EdgeInsetsDirectional.only(end: 16),
526+
child: UnreadCountBadge(
527+
channelIdForBackground: channelId,
528+
count: count)),
529+
])));
530+
}
483531
}
484532

485533
class _StreamSection extends StatelessWidget {

lib/widgets/subscription_list.dart

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,6 @@ class SubscriptionItem extends StatelessWidget {
305305
showTopicListButton: showTopicListButtonInActionSheet),
306306
child: Row(crossAxisAlignment: CrossAxisAlignment.center, children: [
307307
const SizedBox(width: 16),
308-
Padding(
309-
padding: const EdgeInsets.symmetric(vertical: 11),
310-
child: Opacity(
311-
opacity: opacity,
312-
child: Icon(size: 18, color: swatch.iconOnPlainBackground,
313-
iconDataForStream(subscription)))),
314-
const SizedBox(width: 5),
315308
Expanded(
316309
child: Padding(
317310
padding: const EdgeInsets.symmetric(vertical: 10),
@@ -320,7 +313,7 @@ class SubscriptionItem extends StatelessWidget {
320313
// https://github.com/zulip/zulip-flutter/pull/397#pullrequestreview-1742524205
321314
child: Opacity(
322315
opacity: opacity,
323-
child: Text(
316+
child: Text.rich(
324317
style: TextStyle(
325318
fontSize: 18,
326319
height: (20 / 18),
@@ -330,7 +323,12 @@ class SubscriptionItem extends StatelessWidget {
330323
wght: hasUnreads && !subscription.isMuted ? 600 : null)),
331324
maxLines: 1,
332325
overflow: TextOverflow.ellipsis,
333-
subscription.name)))),
326+
channelTopicLabelSpan(
327+
context: context,
328+
channelId: subscription.streamId,
329+
fontSize: 16,
330+
color: designVariables.unreadCountBadgeTextForChannel,
331+
))))),
334332
if (hasUnreads) ...[
335333
const SizedBox(width: 12),
336334
// TODO(#747) show @-mention indicator when it applies

test/widgets/all_channels_test.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ void main() {
193193
final colorSwatch = colorSwatchFor(element, maybeSubscription);
194194
check(icon).color.equals(colorSwatch.iconOnPlainBackground);
195195

196-
check(findInRow(find.text(channel.name))).findsOne();
196+
check(findInRow(find.textContaining(channel.name, findRichText: true))).findsOne();
197197

198198
final maybeToggle = tester.widgetList<Toggle>(
199199
findInRow(find.byType(Toggle))).singleOrNull;
@@ -230,8 +230,10 @@ void main() {
230230
await transitionDurationObserver.pumpPastTransition(tester);
231231

232232
check(find.descendant(
233-
of: find.byType(MessageListPage),
234-
matching: find.text('some-channel')),
233+
of: find.descendant(
234+
of: find.byType(MessageListPage),
235+
matching: find.byType(ZulipAppBar)),
236+
matching: find.textContaining('some-channel', findRichText: true)),
235237
).findsOne();
236238
});
237239

test/widgets/inbox_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ void main() {
122122
/// Find a row with the given label.
123123
Widget? findRowByLabel(WidgetTester tester, String label) {
124124
final rowLabel = tester.widgetList(
125-
find.text(label),
125+
find.textContaining(label, findRichText: true),
126126
).firstOrNull;
127127
if (rowLabel == null) {
128128
return null;
@@ -550,7 +550,7 @@ void main() {
550550
check(collapseIcon).icon.equals(ZulipIcons.arrow_down);
551551
final streamIcon = findStreamHeaderIcon(tester, streamId);
552552
check(streamIcon).color.isNotNull().isSameColorAs(
553-
ChannelColorSwatch.light(subscription.color).iconOnBarBackground);
553+
ChannelColorSwatch.light(subscription.color).iconOnPlainBackground);
554554
check(streamHeaderBackgroundColor(tester, streamId))
555555
.isNotNull().isSameColorAs(ChannelColorSwatch.light(subscription.color).barBackground);
556556
check(tester.widgetList(findSectionContent)).isNotEmpty();

test/widgets/subscription_list_test.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ void main() {
283283

284284
testWidgets('muted streams are displayed as faded', (tester) async {
285285
void checkOpacityForStreamAndBadge(String streamName, int unreadCount, double opacity) {
286-
final streamFinder = find.text(streamName);
286+
final streamFinder = find.textContaining(streamName, findRichText: true);
287287
final streamOpacity = tester.widget<Opacity>(
288288
find.ancestor(of: streamFinder, matching: find.byType(Opacity)));
289289
final badgeFinder = find.text('$unreadCount');
@@ -316,8 +316,10 @@ void main() {
316316

317317
testWidgets('stream name of unmuted streams with unmuted unreads is bold', (tester) async {
318318
void checkStreamNameWght(String streamName, double? expectedWght) {
319-
final streamFinder = find.text(streamName);
320-
final wght = wghtFromTextStyle(tester.widget<Text>(streamFinder).style!);
319+
final streamFinder = find.textContaining(streamName, findRichText: true);
320+
final textWidget = tester.widget(streamFinder);
321+
final TextStyle? style = textWidget is Text ? textWidget.style : (textWidget as RichText).text.style;
322+
final wght = wghtFromTextStyle(style!);
321323
check(wght).equals(expectedWght);
322324
}
323325

0 commit comments

Comments
 (0)