Add support for a simpler filename format

Also make this the default when one doesn't have a title.

This is important as now the filename is far more visible with the new
standard view.
This commit is contained in:
Vishesh Handa
2020-03-05 19:14:27 +01:00
parent c87e6c7884
commit 8e9b23982c
4 changed files with 13 additions and 2 deletions

View File

@ -9,11 +9,13 @@ String getFileName(Note note) {
var date =
note.created ?? note.modified ?? note.fileLastModified ?? DateTime.now();
switch (Settings.instance.noteFileNameFormat) {
case NoteFileNameFormat.SimpleDate:
return toSimpleDateTime(date);
case NoteFileNameFormat.FromTitle:
if (note.title.isNotEmpty) {
return buildTitleFileName(note.parent.folderPath, note.title);
} else {
return toIso8601WithTimezone(date) + ".md";
return toSimpleDateTime(date) + ".md";
}
break;
case NoteFileNameFormat.Iso8601:

View File

@ -38,7 +38,9 @@ class StandardView extends StatelessWidget {
if (title == null || title.isEmpty) {
title = note.fileName;
}
Widget titleWidget = Text(title, style: textTheme.title);
var titleTheme =
textTheme.title.copyWith(fontSize: textTheme.title.fontSize * 0.95);
Widget titleWidget = Text(title, style: titleTheme);
Widget trailing;
var date = note.modified ?? note.created;

View File

@ -107,10 +107,13 @@ class NoteFileNameFormat {
static const Iso8601WithTimeZoneWithoutColon = NoteFileNameFormat(
"Iso8601WithTimeZoneWithoutColon", "ISO8601 without Colons");
static const FromTitle = NoteFileNameFormat("FromTitle", "Title");
static const SimpleDate =
NoteFileNameFormat("SimpleDate", "yyyy-mm-dd-hh-mm-ss");
static const Default = FromTitle;
static const options = <NoteFileNameFormat>[
SimpleDate,
FromTitle,
Iso8601,
Iso8601WithTimeZone,

View File

@ -1,6 +1,10 @@
import 'dart:core';
import 'package:intl/intl.dart';
String toSimpleDateTime(DateTime dt) {
return DateFormat("yyyy-MM-dd-HH-mm-ss").format(dt);
}
String toIso8601(DateTime dt) {
return DateFormat("yyyy-MM-ddTHH:mm:ss").format(dt);
}