reload files after poping from drawing page

add delete item in top menu bar
add feature to rename file by tapping on title bar
This commit is contained in:
2022-11-12 19:35:16 +01:00
parent 192884c902
commit f532deb5ad
8 changed files with 132 additions and 74 deletions

View File

@@ -7,16 +7,20 @@ import 'path.dart';
class NoteFile {
late Database _db;
String filepath;
String filename;
late String _basePath;
String? _newFileName;
Database db() {
return _db;
}
NoteFile(this.filepath);
NoteFile(this.filename);
Future<void> init() async {
final path = (await getSavePath()).path + Platform.pathSeparator + filepath;
_basePath = (await getSavePath()).path;
final path = _basePath + Platform.pathSeparator + filename;
_db = await openDatabase(
path,
onCreate: (db, version) async {
@@ -38,8 +42,13 @@ class NoteFile {
);
}
void delete() {
// todo remove db file
Future<void> delete() async {
await close();
await File(_basePath + Platform.pathSeparator + filename).delete();
}
void rename(String newname) {
_newFileName = newname;
}
Future<void> close() async {
@@ -50,5 +59,13 @@ class NoteFile {
} else {
debugPrint('db file unexpectedly closed before shrinking');
}
// perform qued file renaming operations
if (_newFileName != null) {
File(_basePath + Platform.pathSeparator + filename)
.rename(_basePath + Platform.pathSeparator + _newFileName!);
filename = _newFileName!;
_newFileName = null;
}
}
}