2 Commits

Author SHA1 Message Date
4f54b89689 Add a date to latest 2025-04-24 10:03:43 +02:00
eb2ec79150 Implement local date via intl
We don't want to display utc
2025-04-24 09:58:57 +02:00
4 changed files with 31 additions and 17 deletions

View File

@@ -800,7 +800,7 @@ class MainPageState extends State<MainPage> with WindowListener {
vertical: 2, vertical: 2,
), // Tighter padding ), // Tighter padding
title: Text( title: Text(
note.date, note.displayDate,
style: const TextStyle( style: const TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: fontSize:
@@ -839,7 +839,7 @@ class MainPageState extends State<MainPage> with WindowListener {
// Navigate to the selected note // Navigate to the selected note
Navigator.of(context).pop(); Navigator.of(context).pop();
this.setState(() { setState(() {
_currentlyDisplayedNote = note; _currentlyDisplayedNote = note;
_previousEntryController.text = _previousEntryController.text =
note.content; note.content;
@@ -1051,10 +1051,10 @@ class MainPageState extends State<MainPage> with WindowListener {
children: [ children: [
Expanded( Expanded(
child: Text( child: Text(
_currentlyDisplayedNote?.date == _currentlyDisplayedNote?.displayDate ==
previousNote?.date previousNote?.displayDate
? 'Previous Entry (Latest)' ? 'Previous Entry: ${_currentlyDisplayedNote?.displayDate ?? 'N/A'}'
: 'Entry: ${_currentlyDisplayedNote?.date ?? 'N/A'}', : 'Entry: ${_currentlyDisplayedNote?.displayDate ?? 'N/A'}',
style: TextStyle( style: TextStyle(
fontSize: 18, fontSize: 18,
color: Colors.grey, color: Colors.grey,
@@ -1083,17 +1083,17 @@ class MainPageState extends State<MainPage> with WindowListener {
style: Theme.of(context).textTheme.bodyMedium, style: Theme.of(context).textTheme.bodyMedium,
decoration: InputDecoration( decoration: InputDecoration(
hintText: hintText:
_currentlyDisplayedNote?.date != _currentlyDisplayedNote?.displayDate !=
previousNote?.date previousNote?.displayDate
? 'Viewing note from ${_currentlyDisplayedNote?.date} (Editable)' ? 'Viewing note from ${_currentlyDisplayedNote?.displayDate} (Editable)'
: 'Latest Note', : 'Latest Note: ${_currentlyDisplayedNote?.displayDate ?? 'N/A'}',
border: const OutlineInputBorder(), border: const OutlineInputBorder(),
filled: filled:
_currentlyDisplayedNote?.date != _currentlyDisplayedNote?.displayDate !=
previousNote?.date, previousNote?.displayDate,
fillColor: fillColor:
_currentlyDisplayedNote?.date != _currentlyDisplayedNote?.displayDate !=
previousNote?.date previousNote?.displayDate
? Colors.grey.withOpacity(0.1) ? Colors.grey.withOpacity(0.1)
: null, : null,
), ),

View File

@@ -1,12 +1,17 @@
import 'package:journaler/db.dart'; import 'package:journaler/db.dart';
import 'package:intl/intl.dart';
class Note { class Note {
final String date; final String date;
late final String displayDate;
String content; String content;
String? String? snippet;
snippet; // Optional field to hold highlighted snippets for search results
Note({required this.date, required this.content, this.snippet}); Note({required this.date, required this.content, this.snippet}) {
final dtUtc = DateFormat('yyyy-MM-dd HH:mm:ss').parse(date, true);
final dtLocal = dtUtc.toLocal();
displayDate = DateFormat('yyyy-MM-dd HH:mm:ss').format(dtLocal);
}
} }
class Scratch { class Scratch {

View File

@@ -224,6 +224,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.5.4" version: "4.5.4"
intl:
dependency: "direct main"
description:
name: intl
sha256: "3df61194eb431efc39c4ceba583b95633a403f46c9fd341e550ce0bfa50e9aa5"
url: "https://pub.dev"
source: hosted
version: "0.20.2"
json_annotation: json_annotation:
dependency: transitive dependency: transitive
description: description:

View File

@@ -40,6 +40,7 @@ dependencies:
sqflite_common_ffi: ^2.3.5 sqflite_common_ffi: ^2.3.5
path: ^1.8.0 path: ^1.8.0
ps_list: ^0.0.5 ps_list: ^0.0.5
intl: ^0.20.2
dev_dependencies: dev_dependencies:
flutter_test: flutter_test: