From f31e42ecef6cfa153ad03d39e73366bc13b9a5db Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Thu, 5 Mar 2020 18:54:34 +0100 Subject: [PATCH] StandardView: Add date to trailing widget Patch adapted from Ivan's pull request - https://github.com/GitJournal/GitJournal/pull/59 It had to be reverted earlier as it was breaking functionality. But now it works perfectly. --- lib/folder_views/standard_view.dart | 39 +++++++++-------------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/lib/folder_views/standard_view.dart b/lib/folder_views/standard_view.dart index 092020b6..ebb4c042 100644 --- a/lib/folder_views/standard_view.dart +++ b/lib/folder_views/standard_view.dart @@ -33,35 +33,19 @@ class StandardView extends StatelessWidget { Widget _buildRow(BuildContext context, Note note) { var textTheme = Theme.of(context).textTheme; - var title = note.canHaveMetadata ? note.title : note.fileName; + + var title = note.title; + if (title == null || title.isEmpty) { + title = note.fileName; + } Widget titleWidget = Text(title, style: textTheme.title); - if (title.isEmpty) { - DateTime date; - if (Settings.instance.sortingMode == SortingMode.Modified) { - date = note.modified; - } else if (Settings.instance.sortingMode == SortingMode.Created) { - date = note.created; - } - if (date != null) { - var formatter = DateFormat('dd MMM, yyyy '); - var dateStr = formatter.format(date); + Widget trailing; - 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 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 children = [ @@ -77,6 +61,7 @@ class StandardView extends StatelessWidget { var tile = ListTile( isThreeLine: true, title: titleWidget, + trailing: trailing, subtitle: Column( children: children, crossAxisAlignment: CrossAxisAlignment.start,