Skip to content

Commit 840f50b

Browse files
chrisbobbegnprice
authored andcommitted
inbox, topic_list [nfc]: Pull out InboxRowMarkerIcon helper widget
1 parent edd0042 commit 840f50b

2 files changed

Lines changed: 36 additions & 22 deletions

File tree

lib/widgets/inbox.dart

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -612,13 +612,7 @@ class InboxTopicItem extends StatelessWidget {
612612
// this Align shrink-wraps to its child's height.)
613613
alignment: .centerEnd,
614614
child: topic.isResolved
615-
? InlineIcon(
616-
// Compare icon style in the topic list; probably these
617-
// should stay in sync.
618-
icon: ZulipIcons.check,
619-
fontSize: InboxRowTrailingMarkers.fontSize,
620-
textScaler: MediaQuery.textScalerOf(context).clamp(maxScaleFactor: 1.5),
621-
color: DesignVariables.of(context).textMessage.withFadedAlpha(0.4))
615+
? InboxRowMarkerIcon(icon: ZulipIcons.check)
622616
: null)),
623617
SizedBox(width: 8),
624618
Expanded(child: Padding(
@@ -649,6 +643,38 @@ class InboxTopicItem extends StatelessWidget {
649643
}
650644
}
651645

646+
/// An [InlineIcon] styled for use as a marker in inbox rows.
647+
///
648+
/// This encapsulates style details that should stay in sync
649+
/// across the inbox and topic-list pages.
650+
class InboxRowMarkerIcon extends StatelessWidget {
651+
const InboxRowMarkerIcon({
652+
super.key,
653+
required this.icon,
654+
this.visible = true,
655+
this.padBefore = false,
656+
this.padAfter = false,
657+
});
658+
659+
final IconData icon;
660+
final bool visible;
661+
final bool padBefore;
662+
final bool padAfter;
663+
664+
@override
665+
Widget build(BuildContext context) {
666+
return InlineIcon(
667+
icon: icon,
668+
fontSize: InboxRowTrailingMarkers.fontSize,
669+
textScaler: MediaQuery.textScalerOf(context).clamp(maxScaleFactor: 1.5),
670+
color: DesignVariables.of(context).textMessage.withFadedAlpha(0.4),
671+
visible: visible,
672+
padBefore: padBefore,
673+
padAfter: padAfter,
674+
);
675+
}
676+
}
677+
652678
/// A short, baseline-aligned row, optionally containing
653679
/// an unread badge, @ icon, and topic visibility icon.
654680
///
@@ -670,13 +696,7 @@ class InboxRowTrailingMarkers extends StatelessWidget {
670696
static const fontSize = 17.0;
671697

672698
Widget _buildIcon(BuildContext context, IconData icon, {required bool padAfter}) {
673-
return InlineIcon(
674-
icon: icon,
675-
fontSize: fontSize,
676-
textScaler: MediaQuery.textScalerOf(context).clamp(maxScaleFactor: 1.5),
677-
color: DesignVariables.of(context).textMessage.withFadedAlpha(0.4),
678-
padAfter: padAfter,
679-
);
699+
return InboxRowMarkerIcon(icon: icon, padAfter: padAfter);
680700
}
681701

682702
@override

lib/widgets/topic_list.dart

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import '../model/topics.dart';
88
import '../model/unreads.dart';
99
import 'action_sheet.dart';
1010
import 'app_bar.dart';
11-
import 'color.dart';
1211
import 'icons.dart';
1312
import 'inbox.dart';
1413
import 'message_list.dart';
@@ -279,14 +278,9 @@ class _TopicItem extends StatelessWidget {
279278
crossAxisAlignment: .baseline,
280279
textBaseline: localizedTextBaseline(context),
281280
children: [
282-
InlineIcon(
283-
// Compare icon style in the inbox; probably these
284-
// should stay in sync.
285-
visible: topic.isResolved,
281+
InboxRowMarkerIcon(
286282
icon: ZulipIcons.check,
287-
fontSize: InboxRowTrailingMarkers.fontSize,
288-
textScaler: MediaQuery.textScalerOf(context).clamp(maxScaleFactor: 1.5),
289-
color: DesignVariables.of(context).textMessage.withFadedAlpha(0.4)),
283+
visible: topic.isResolved),
290284
Expanded(child: Opacity(
291285
opacity: opacity,
292286
child: Text(

0 commit comments

Comments
 (0)