mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-29 18:38:36 +08:00
[Feat] add date to trailing widget in journal listing
This commit is contained in:

committed by
Vishesh Handa

parent
3d12c833d3
commit
8f76b4d960
@ -138,30 +138,16 @@ class _JournalListState extends State<JournalList> {
|
|||||||
|
|
||||||
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.title;
|
|
||||||
|
var title = note.title ?? note.fileName;
|
||||||
Widget titleWidget = Text(title, style: textTheme.title);
|
Widget titleWidget = Text(title, style: textTheme.title);
|
||||||
if (title.isEmpty) {
|
Widget trailing;
|
||||||
var date = note.modified ?? note.created;
|
|
||||||
if (date != null) {
|
|
||||||
var formatter = DateFormat('dd MMM, yyyy ');
|
|
||||||
var dateStr = formatter.format(date);
|
|
||||||
|
|
||||||
var timeFormatter = DateFormat('Hm');
|
var date = note.modified ?? note.created;
|
||||||
var time = timeFormatter.format(date);
|
if (date != null) {
|
||||||
|
var formatter = DateFormat('dd MMM, yyyy');
|
||||||
var timeColor = textTheme.body1.color.withAlpha(100);
|
var dateStr = formatter.format(date);
|
||||||
|
trailing = Text(dateStr, style: textTheme.caption);
|
||||||
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 body = stripMarkdownFormatting(note.body);
|
var body = stripMarkdownFormatting(note.body);
|
||||||
@ -179,6 +165,7 @@ class _JournalListState extends State<JournalList> {
|
|||||||
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