Skip to content

Commit ee13363

Browse files
committed
wip and render them
1 parent 4c982ef commit ee13363

File tree

1 file changed

+57
-1
lines changed

1 file changed

+57
-1
lines changed

lib/widgets/message_list.dart

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,8 @@ class _MessageListState extends State<MessageList> with PerAccountStoreAwareStat
348348
case MessageListDateSeparatorItem():
349349
final header = RecipientHeader(message: data.message, narrow: widget.narrow);
350350
return StickyHeaderItem(allowOverflow: true,
351-
header: header, child: Text("a new day")); // TODO
351+
header: header,
352+
child: DateSeparator(message: data.message));
352353
case MessageListMessageItem():
353354
final header = RecipientHeader(message: data.message, narrow: widget.narrow);
354355
return MessageItem(
@@ -468,6 +469,61 @@ class RecipientHeader extends StatelessWidget {
468469
}
469470
}
470471

472+
class DateSeparator extends StatelessWidget {
473+
const DateSeparator({super.key, required this.message});
474+
475+
final Message message;
476+
477+
@override
478+
Widget build(BuildContext context) {
479+
final zulipLocalizations = ZulipLocalizations.of(context);
480+
481+
// This color matches recipient headers. TODO is that what we want?
482+
final color = Colors.black.withOpacity(0.4);
483+
484+
return ColoredBox(color: Colors.white,
485+
child: Padding(
486+
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 2),
487+
child: Row(children: [
488+
Expanded(
489+
child: SizedBox(height: 0,
490+
child: DecoratedBox(
491+
decoration: BoxDecoration(
492+
border: Border(
493+
bottom: BorderSide(
494+
width: 0,
495+
color: color)))))),
496+
Padding(padding: const EdgeInsets.symmetric(horizontal: 2),
497+
// TODO dedupe with RecipientHeaderDate
498+
child: Text(
499+
style: TextStyle(
500+
color: color,
501+
fontFamily: 'Source Sans 3',
502+
fontSize: 16,
503+
// In Figma this has a line-height of 19, but using 18
504+
// here to match the stream/topic text widgets helps
505+
// to align all the text to the same baseline.
506+
height: (18 / 16),
507+
// This is equivalent to css `all-small-caps`, see:
508+
// https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant-caps#all-small-caps
509+
fontFeatures: const [FontFeature.enable('c2sc'), FontFeature.enable('smcp')],
510+
).merge(weightVariableTextStyle(context)),
511+
formatHeaderDate(
512+
zulipLocalizations,
513+
DateTime.fromMillisecondsSinceEpoch(message.timestamp * 1000),
514+
now: DateTime.now()))),
515+
SizedBox(height: 0, width: 12,
516+
child: DecoratedBox(
517+
decoration: BoxDecoration(
518+
border: Border(
519+
bottom: BorderSide(
520+
width: 0,
521+
color: color)))))
522+
])),
523+
);
524+
}
525+
}
526+
471527
class MessageItem extends StatelessWidget {
472528
const MessageItem({
473529
super.key,

0 commit comments

Comments
 (0)