1 Commits

Author SHA1 Message Date
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 29 additions and 15 deletions

View File

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

View File

@@ -1,12 +1,17 @@
import 'package:journaler/db.dart';
import 'package:intl/intl.dart';
class Note {
final String date;
late final String displayDate;
String content;
String?
snippet; // Optional field to hold highlighted snippets for search results
String? snippet;
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 {

View File

@@ -224,6 +224,14 @@ packages:
url: "https://pub.dev"
source: hosted
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:
dependency: transitive
description:

View File

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