fix filename extension mismatch
use TileMetaData also for preview tiles
This commit is contained in:
parent
b095838399
commit
192884c902
@ -59,7 +59,7 @@ class _AppState extends State<App> {
|
|||||||
ctx,
|
ctx,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (ctx) => DrawingPage(
|
builder: (ctx) => DrawingPage(
|
||||||
meta: NoteMetaData(filename, name),
|
meta: NoteMetaData(filename, name, DateTime.now()),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
).then((v) => notifier.loadAllNotes());
|
).then((v) => notifier.loadAllNotes());
|
||||||
|
@ -48,7 +48,8 @@ class Point {
|
|||||||
|
|
||||||
class NoteMetaData {
|
class NoteMetaData {
|
||||||
final String name;
|
final String name;
|
||||||
final String filePath;
|
final String relativePath;
|
||||||
|
final DateTime lastModified;
|
||||||
|
|
||||||
NoteMetaData(this.name, this.filePath);
|
NoteMetaData(this.name, this.relativePath, this.lastModified);
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ class _DrawingPageState extends State<DrawingPage> {
|
|||||||
Offset offset = const Offset(.0, .0);
|
Offset offset = const Offset(.0, .0);
|
||||||
|
|
||||||
late PaintController controller;
|
late PaintController controller;
|
||||||
late NoteFile noteFile = NoteFile(widget.meta.filePath);
|
late NoteFile noteFile = NoteFile(widget.meta.relativePath);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
@ -2,15 +2,15 @@ import 'dart:io';
|
|||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
|
|
||||||
|
import '../canvas/document_types.dart';
|
||||||
import '../savesystem/path.dart';
|
import '../savesystem/path.dart';
|
||||||
import '../widgets/note_tile.dart';
|
|
||||||
|
|
||||||
class FileChangeNotifier extends ChangeNotifier {
|
class FileChangeNotifier extends ChangeNotifier {
|
||||||
FileChangeNotifier();
|
FileChangeNotifier();
|
||||||
|
|
||||||
List<NoteTileData> tiledata = [];
|
List<NoteMetaData> tiledata = [];
|
||||||
|
|
||||||
Future<List<NoteTileData>> loadAllNotes() async {
|
Future<List<NoteMetaData>> loadAllNotes() async {
|
||||||
final path = await getSavePath();
|
final path = await getSavePath();
|
||||||
if (!(await path.exists())) {
|
if (!(await path.exists())) {
|
||||||
await path.create(recursive: true);
|
await path.create(recursive: true);
|
||||||
@ -23,7 +23,7 @@ class FileChangeNotifier extends ChangeNotifier {
|
|||||||
final lastmodified = (await fsentity.stat()).modified;
|
final lastmodified = (await fsentity.stat()).modified;
|
||||||
final filename = fsentity.path.split(Platform.pathSeparator).last;
|
final filename = fsentity.path.split(Platform.pathSeparator).last;
|
||||||
final name = filename.substring(0, filename.length - 7);
|
final name = filename.substring(0, filename.length - 7);
|
||||||
return NoteTileData(name, filename, lastmodified);
|
return NoteMetaData(name, filename, lastmodified);
|
||||||
}).toList();
|
}).toList();
|
||||||
dta.sort(
|
dta.sort(
|
||||||
(a, b) => b.lastModified.compareTo(a.lastModified),
|
(a, b) => b.lastModified.compareTo(a.lastModified),
|
||||||
|
@ -5,18 +5,10 @@ import '../canvas/document_types.dart';
|
|||||||
import '../canvas/drawing_page.dart';
|
import '../canvas/drawing_page.dart';
|
||||||
import '../context/file_change_notifier.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 {
|
class NoteTile extends StatelessWidget {
|
||||||
const NoteTile({Key? key, required this.data}) : super(key: key);
|
const NoteTile({Key? key, required this.data}) : super(key: key);
|
||||||
|
|
||||||
final NoteTileData data;
|
final NoteMetaData data;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -25,8 +17,7 @@ class NoteTile extends StatelessWidget {
|
|||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) =>
|
builder: (context) => DrawingPage(meta: data),
|
||||||
DrawingPage(meta: NoteMetaData(data.relativePath, data.name)),
|
|
||||||
),
|
),
|
||||||
).then((value) =>
|
).then((value) =>
|
||||||
Provider.of<FileChangeNotifier>(context, listen: false)
|
Provider.of<FileChangeNotifier>(context, listen: false)
|
||||||
|
Loading…
Reference in New Issue
Block a user