JournalListing: Show the title

It's no longer a simple JournalListing and instead we also show the
title. The main problem is with what to do when the title is not there.
Just leaving it blank seems to feel weird, specially when the note is
too small.

Maybe it's time to change it such that each row size is not the same.
We're effectively wasting whitespace right now for very small notes.
This commit is contained in:
Vishesh Handa
2019-12-27 11:34:15 +01:00
parent 5a79fa26ca
commit 2b09708793
2 changed files with 56 additions and 1 deletions

View File

@ -44,6 +44,10 @@ class Note with ChangeNotifier implements Comparable<Note> {
return _filePath;
}
String get fileName {
return p.basename(_filePath);
}
DateTime get created {
return _created;
}

View File

@ -73,7 +73,58 @@ class JournalList extends StatelessWidget {
);
}
Widget _buildRow(BuildContext context, Note journal, int noteIndex) {
Widget _buildRow(BuildContext context, Note note, int noteIndex) {
var textTheme = Theme.of(context).textTheme;
var title = note.title;
Widget titleWidget = Text(title, style: textTheme.title);
if (title.isEmpty) {
var formatter = DateFormat('dd MMM, yyyy ');
var date = formatter.format(note.created);
var timeFormatter = DateFormat('Hm');
var time = timeFormatter.format(note.created);
var timeColor = textTheme.body1.color.withAlpha(100);
titleWidget = Row(
children: <Widget>[
Text(date, style: textTheme.title),
Text(time, style: textTheme.body1.copyWith(color: timeColor)),
],
crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.alphabetic,
);
}
var body = stripMarkdownFormatting(note.body);
var children = <Widget>[
const SizedBox(height: 8.0),
Text(
body,
maxLines: 3,
overflow: TextOverflow.ellipsis,
style: textTheme.body1,
),
];
var tile = ListTile(
isThreeLine: true,
title: titleWidget,
subtitle: Column(
children: children,
crossAxisAlignment: CrossAxisAlignment.start,
),
onTap: () => noteSelectedFunction(noteIndex),
);
return Padding(
padding: const EdgeInsets.only(top: 8.0, bottom: 8.0),
child: tile,
);
}
Widget _buildJournalRow(BuildContext context, Note journal, int noteIndex) {
var title = "";
var time = "";