fix filename extension mismatch

use TileMetaData also for preview tiles
This commit is contained in:
lukas-heiligenbrunner 2022-11-04 23:09:50 +01:00
parent b095838399
commit 192884c902
5 changed files with 11 additions and 19 deletions

View File

@ -59,7 +59,7 @@ class _AppState extends State<App> {
ctx,
MaterialPageRoute(
builder: (ctx) => DrawingPage(
meta: NoteMetaData(filename, name),
meta: NoteMetaData(filename, name, DateTime.now()),
),
),
).then((v) => notifier.loadAllNotes());

View File

@ -48,7 +48,8 @@ class Point {
class NoteMetaData {
final String name;
final String filePath;
final String relativePath;
final DateTime lastModified;
NoteMetaData(this.name, this.filePath);
NoteMetaData(this.name, this.relativePath, this.lastModified);
}

View File

@ -28,7 +28,7 @@ class _DrawingPageState extends State<DrawingPage> {
Offset offset = const Offset(.0, .0);
late PaintController controller;
late NoteFile noteFile = NoteFile(widget.meta.filePath);
late NoteFile noteFile = NoteFile(widget.meta.relativePath);
@override
void initState() {

View File

@ -2,15 +2,15 @@ import 'dart:io';
import 'package:flutter/cupertino.dart';
import '../canvas/document_types.dart';
import '../savesystem/path.dart';
import '../widgets/note_tile.dart';
class FileChangeNotifier extends ChangeNotifier {
FileChangeNotifier();
List<NoteTileData> tiledata = [];
List<NoteMetaData> tiledata = [];
Future<List<NoteTileData>> loadAllNotes() async {
Future<List<NoteMetaData>> loadAllNotes() async {
final path = await getSavePath();
if (!(await path.exists())) {
await path.create(recursive: true);
@ -23,7 +23,7 @@ class FileChangeNotifier extends ChangeNotifier {
final lastmodified = (await fsentity.stat()).modified;
final filename = fsentity.path.split(Platform.pathSeparator).last;
final name = filename.substring(0, filename.length - 7);
return NoteTileData(name, filename, lastmodified);
return NoteMetaData(name, filename, lastmodified);
}).toList();
dta.sort(
(a, b) => b.lastModified.compareTo(a.lastModified),

View File

@ -5,18 +5,10 @@ import '../canvas/document_types.dart';
import '../canvas/drawing_page.dart';
import '../context/file_change_notifier.dart';
class NoteTileData {
final String name;
final String relativePath;
final DateTime lastModified;
NoteTileData(this.name, this.relativePath, this.lastModified);
}
class NoteTile extends StatelessWidget {
const NoteTile({Key? key, required this.data}) : super(key: key);
final NoteTileData data;
final NoteMetaData data;
@override
Widget build(BuildContext context) {
@ -25,8 +17,7 @@ class NoteTile extends StatelessWidget {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
DrawingPage(meta: NoteMetaData(data.relativePath, data.name)),
builder: (context) => DrawingPage(meta: data),
),
).then((value) =>
Provider.of<FileChangeNotifier>(context, listen: false)