mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-30 19:36:25 +08:00
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.
This commit is contained in:
@ -33,35 +33,19 @@ class StandardView extends StatelessWidget {
|
|||||||
|
|
||||||
Widget _buildRow(BuildContext context, Note note) {
|
Widget _buildRow(BuildContext context, Note note) {
|
||||||
var textTheme = Theme.of(context).textTheme;
|
var textTheme = Theme.of(context).textTheme;
|
||||||
var title = note.canHaveMetadata ? note.title : note.fileName;
|
|
||||||
Widget titleWidget = Text(title, style: textTheme.title);
|
var title = note.title;
|
||||||
if (title.isEmpty) {
|
if (title == null || title.isEmpty) {
|
||||||
DateTime date;
|
title = note.fileName;
|
||||||
if (Settings.instance.sortingMode == SortingMode.Modified) {
|
|
||||||
date = note.modified;
|
|
||||||
} else if (Settings.instance.sortingMode == SortingMode.Created) {
|
|
||||||
date = note.created;
|
|
||||||
}
|
}
|
||||||
|
Widget titleWidget = Text(title, style: textTheme.title);
|
||||||
|
Widget trailing;
|
||||||
|
|
||||||
|
var date = note.modified ?? note.created;
|
||||||
if (date != null) {
|
if (date != null) {
|
||||||
var formatter = DateFormat('dd MMM, yyyy');
|
var formatter = DateFormat('dd MMM, yyyy');
|
||||||
var dateStr = formatter.format(date);
|
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: <Widget>[
|
|
||||||
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 children = <Widget>[
|
var children = <Widget>[
|
||||||
@ -77,6 +61,7 @@ class StandardView extends StatelessWidget {
|
|||||||
var tile = ListTile(
|
var tile = ListTile(
|
||||||
isThreeLine: true,
|
isThreeLine: true,
|
||||||
title: titleWidget,
|
title: titleWidget,
|
||||||
|
trailing: trailing,
|
||||||
subtitle: Column(
|
subtitle: Column(
|
||||||
children: children,
|
children: children,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
Reference in New Issue
Block a user