Skip to content

Commit f9ec516

Browse files
chrisbobbegnprice
authored andcommitted
lightbox [nfc]: Go through MessageTimestampStyle for timestamp
1 parent 3addf69 commit f9ec516

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

lib/widgets/lightbox.dart

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter/scheduler.dart';
33
import 'package:flutter/services.dart';
4-
import 'package:intl/intl.dart';
54
import 'package:video_player/video_player.dart';
65

76
import '../api/core.dart';
@@ -12,6 +11,7 @@ import '../model/binding.dart';
1211
import 'actions.dart';
1312
import 'content.dart';
1413
import 'dialog.dart';
14+
import 'message_list.dart';
1515
import 'page.dart';
1616
import 'store.dart';
1717
import 'user.dart';
@@ -176,11 +176,8 @@ class _LightboxPageLayoutState extends State<_LightboxPageLayout> {
176176

177177
PreferredSizeWidget? appBar;
178178
if (_headerFooterVisible) {
179-
// TODO(#45): Format with e.g. "Yesterday at 4:47 PM"
180-
final timestampText = DateFormat
181-
.yMMMd(/* TODO(#278): Pass selected language here, I think? */)
182-
.add_Hms()
183-
.format(DateTime.fromMillisecondsSinceEpoch(widget.message.timestamp * 1000));
179+
final timestampText = MessageTimestampStyle.lightbox
180+
.format(widget.message.timestamp);
184181

185182
// We use plain [AppBar] instead of [ZulipAppBar], even though this page
186183
// has a [PerAccountStore], because:

lib/widgets/message_list.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1987,6 +1987,9 @@ enum MessageTimestampStyle {
19871987
none,
19881988
timeOnly,
19891989

1990+
// TODO(#45): E.g. "Yesterday at 4:47 PM"; see details in #45
1991+
lightbox,
1992+
19901993
/// The longest format, with full date and time as numbers, not "Today"/etc.
19911994
///
19921995
/// For UI contexts focused just on the one message,
@@ -2002,6 +2005,7 @@ enum MessageTimestampStyle {
20022005
;
20032006

20042007
static final _timeOnlyFormat = DateFormat('h:mm aa', 'en_US');
2008+
static final _lightboxFormat = DateFormat.yMMMd().add_Hms();
20052009
static final _fullFormat = DateFormat.yMMMd().add_jm();
20062010

20072011
/// Format a [Message.timestamp] for this mode.
@@ -2013,6 +2017,7 @@ enum MessageTimestampStyle {
20132017
switch (this) {
20142018
case none: return null;
20152019
case timeOnly: return _timeOnlyFormat.format(asDateTime);
2020+
case lightbox: return _lightboxFormat.format(asDateTime);
20162021
case full: return _fullFormat.format(asDateTime);
20172022
}
20182023
}

0 commit comments

Comments
 (0)