mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-30 11:33:34 +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 =
|
var date =
|
||||||
note.created ?? note.modified ?? note.fileLastModified ?? DateTime.now();
|
note.created ?? note.modified ?? note.fileLastModified ?? DateTime.now();
|
||||||
switch (Settings.instance.noteFileNameFormat) {
|
switch (Settings.instance.noteFileNameFormat) {
|
||||||
|
case NoteFileNameFormat.SimpleDate:
|
||||||
|
return toSimpleDateTime(date);
|
||||||
case NoteFileNameFormat.FromTitle:
|
case NoteFileNameFormat.FromTitle:
|
||||||
if (note.title.isNotEmpty) {
|
if (note.title.isNotEmpty) {
|
||||||
return buildTitleFileName(note.parent.folderPath, note.title);
|
return buildTitleFileName(note.parent.folderPath, note.title);
|
||||||
} else {
|
} else {
|
||||||
return toIso8601WithTimezone(date) + ".md";
|
return toSimpleDateTime(date) + ".md";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NoteFileNameFormat.Iso8601:
|
case NoteFileNameFormat.Iso8601:
|
||||||
|
@ -38,7 +38,9 @@ class StandardView extends StatelessWidget {
|
|||||||
if (title == null || title.isEmpty) {
|
if (title == null || title.isEmpty) {
|
||||||
title = note.fileName;
|
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;
|
Widget trailing;
|
||||||
|
|
||||||
var date = note.modified ?? note.created;
|
var date = note.modified ?? note.created;
|
||||||
|
@ -107,10 +107,13 @@ class NoteFileNameFormat {
|
|||||||
static const Iso8601WithTimeZoneWithoutColon = NoteFileNameFormat(
|
static const Iso8601WithTimeZoneWithoutColon = NoteFileNameFormat(
|
||||||
"Iso8601WithTimeZoneWithoutColon", "ISO8601 without Colons");
|
"Iso8601WithTimeZoneWithoutColon", "ISO8601 without Colons");
|
||||||
static const FromTitle = NoteFileNameFormat("FromTitle", "Title");
|
static const FromTitle = NoteFileNameFormat("FromTitle", "Title");
|
||||||
|
static const SimpleDate =
|
||||||
|
NoteFileNameFormat("SimpleDate", "yyyy-mm-dd-hh-mm-ss");
|
||||||
|
|
||||||
static const Default = FromTitle;
|
static const Default = FromTitle;
|
||||||
|
|
||||||
static const options = <NoteFileNameFormat>[
|
static const options = <NoteFileNameFormat>[
|
||||||
|
SimpleDate,
|
||||||
FromTitle,
|
FromTitle,
|
||||||
Iso8601,
|
Iso8601,
|
||||||
Iso8601WithTimeZone,
|
Iso8601WithTimeZone,
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
import 'dart:core';
|
import 'dart:core';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
|
String toSimpleDateTime(DateTime dt) {
|
||||||
|
return DateFormat("yyyy-MM-dd-HH-mm-ss").format(dt);
|
||||||
|
}
|
||||||
|
|
||||||
String toIso8601(DateTime dt) {
|
String toIso8601(DateTime dt) {
|
||||||
return DateFormat("yyyy-MM-ddTHH:mm:ss").format(dt);
|
return DateFormat("yyyy-MM-ddTHH:mm:ss").format(dt);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user