mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-29 10:17:16 +08:00
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:
@ -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:
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user