From 9290d9421e9b6a0a09fc3a0d64fd5740cef07711 Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Sun, 9 Feb 2020 19:13:46 +0100 Subject: [PATCH] Revert "[Feat] add date to trailing widget in journal listing" This reverts commit 8f76b4d96089c4a9313a7bf15d40278afee9a6e0. I want to make another release and this substantially changes the existing behaviour - I thought it would be fine, but it's proving to be challenging. Problems - * Many notes do not have a title and the fileName is just too ugly to show to the user when it is an ISO8601 timestamp. --- lib/widgets/journal_list.dart | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/lib/widgets/journal_list.dart b/lib/widgets/journal_list.dart index 1a4039a8..e907c4bb 100644 --- a/lib/widgets/journal_list.dart +++ b/lib/widgets/journal_list.dart @@ -143,16 +143,30 @@ class _JournalListState extends State { Widget _buildRow(BuildContext context, Note note) { var textTheme = Theme.of(context).textTheme; - - var title = note.title ?? note.fileName; + var title = note.title; Widget titleWidget = Text(title, style: textTheme.title); - Widget trailing; + if (title.isEmpty) { + var date = note.modified ?? note.created; + if (date != null) { + var formatter = DateFormat('dd MMM, yyyy '); + var dateStr = formatter.format(date); - var date = note.modified ?? note.created; - if (date != null) { - var formatter = DateFormat('dd MMM, yyyy'); - var dateStr = formatter.format(date); - trailing = Text(dateStr, style: textTheme.caption); + var timeFormatter = DateFormat('Hm'); + var time = timeFormatter.format(date); + + var timeColor = textTheme.body1.color.withAlpha(100); + + titleWidget = Row( + children: [ + Text(dateStr, style: textTheme.title), + Text(time, style: textTheme.body1.copyWith(color: timeColor)), + ], + crossAxisAlignment: CrossAxisAlignment.baseline, + textBaseline: TextBaseline.alphabetic, + ); + } else { + titleWidget = Text(note.fileName, style: textTheme.title); + } } var body = stripMarkdownFormatting(note.body); @@ -170,7 +184,6 @@ class _JournalListState extends State { var tile = ListTile( isThreeLine: true, title: titleWidget, - trailing: trailing, subtitle: Column( children: children, crossAxisAlignment: CrossAxisAlignment.start,