Skip to content

Commit 8f0f27c

Browse files
gnpricechrisbobbe
authored andcommitted
msglist [nfc]: Factor a DateText widget out from RecipientHeaderDate
1 parent 587d1e7 commit 8f0f27c

File tree

1 file changed

+42
-18
lines changed

1 file changed

+42
-18
lines changed

lib/widgets/message_list.dart

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -708,26 +708,50 @@ class RecipientHeaderDate extends StatelessWidget {
708708

709709
@override
710710
Widget build(BuildContext context) {
711-
final zulipLocalizations = ZulipLocalizations.of(context);
712711
return Padding(
713712
padding: const EdgeInsets.fromLTRB(10, 0, 16, 0),
714-
child: Text(
715-
style: TextStyle(
716-
color: color,
717-
fontFamily: 'Source Sans 3',
718-
fontSize: 16,
719-
// In Figma this has a line-height of 19, but using 18
720-
// here to match the stream/topic text widgets helps
721-
// to align all the text to the same baseline.
722-
height: (18 / 16),
723-
// This is equivalent to css `all-small-caps`, see:
724-
// https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant-caps#all-small-caps
725-
fontFeatures: const [FontFeature.enable('c2sc'), FontFeature.enable('smcp')],
726-
).merge(weightVariableTextStyle(context)),
727-
formatHeaderDate(
728-
zulipLocalizations,
729-
DateTime.fromMillisecondsSinceEpoch(message.timestamp * 1000),
730-
now: DateTime.now())));
713+
child: DateText(
714+
color: color,
715+
fontSize: 16,
716+
// In Figma this has a line-height of 19, but using 18
717+
// here to match the stream/topic text widgets helps
718+
// to align all the text to the same baseline.
719+
height: (18 / 16),
720+
timestamp: message.timestamp));
721+
}
722+
}
723+
724+
class DateText extends StatelessWidget {
725+
const DateText({
726+
super.key,
727+
required this.color,
728+
required this.fontSize,
729+
required this.height,
730+
required this.timestamp,
731+
});
732+
733+
final Color color;
734+
final double fontSize;
735+
final double height;
736+
final int timestamp;
737+
738+
@override
739+
Widget build(BuildContext context) {
740+
final zulipLocalizations = ZulipLocalizations.of(context);
741+
return Text(
742+
style: TextStyle(
743+
color: color,
744+
fontFamily: 'Source Sans 3',
745+
fontSize: fontSize,
746+
height: height,
747+
// This is equivalent to css `all-small-caps`, see:
748+
// https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant-caps#all-small-caps
749+
fontFeatures: const [FontFeature.enable('c2sc'), FontFeature.enable('smcp')],
750+
).merge(weightVariableTextStyle(context)),
751+
formatHeaderDate(
752+
zulipLocalizations,
753+
DateTime.fromMillisecondsSinceEpoch(timestamp * 1000),
754+
now: DateTime.now()));
731755
}
732756
}
733757

0 commit comments

Comments
 (0)