load on all notes page all available .dbnote files and display them
reopen file on tile click
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import 'dart:ui';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'note_file.dart';
|
||||
import '../canvas/document_types.dart';
|
||||
@ -15,7 +15,7 @@ extension LineLoading on NoteFile {
|
||||
final int csid = i['strokeid'] as int;
|
||||
if (csid != strokeid) {
|
||||
strokeid = csid;
|
||||
strokes.add(Stroke(strokeid));
|
||||
strokes.add(Stroke(strokeid, Colors.green));
|
||||
}
|
||||
final Point p = Point(
|
||||
Offset(i['x'] as double, i['y'] as double), i['thickness'] as double);
|
||||
|
@ -1,29 +1,22 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:notes/savesystem/path.dart';
|
||||
import 'package:sqflite/sqflite.dart';
|
||||
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
|
||||
|
||||
class NoteFile {
|
||||
late Database _db;
|
||||
String filename;
|
||||
String filepath;
|
||||
|
||||
Database db() {
|
||||
return _db;
|
||||
}
|
||||
|
||||
NoteFile(this.filename);
|
||||
NoteFile(this.filepath);
|
||||
|
||||
Future<void> init() async {
|
||||
String dbpath = filename;
|
||||
if (defaultTargetPlatform == TargetPlatform.android ||
|
||||
defaultTargetPlatform == TargetPlatform.iOS) {
|
||||
dbpath = '${await getDatabasesPath()}/$filename';
|
||||
} else {
|
||||
// Change the default factory
|
||||
databaseFactory = databaseFactoryFfi;
|
||||
}
|
||||
|
||||
final path = (await getSavePath()).path + Platform.pathSeparator + filepath;
|
||||
_db = await openDatabase(
|
||||
dbpath,
|
||||
path,
|
||||
onCreate: (db, version) {
|
||||
return db.execute(
|
||||
'CREATE TABLE strokes(id integer primary key autoincrement, color INTEGER, elevation INTEGER);'
|
||||
|
17
lib/savesystem/path.dart
Normal file
17
lib/savesystem/path.dart
Normal file
@ -0,0 +1,17 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:sqflite/sqflite.dart';
|
||||
|
||||
Future<Directory> getSavePath() async {
|
||||
Directory dbpath;
|
||||
if (defaultTargetPlatform == TargetPlatform.android ||
|
||||
defaultTargetPlatform == TargetPlatform.iOS) {
|
||||
dbpath = Directory(await getDatabasesPath());
|
||||
} else {
|
||||
dbpath = Directory(
|
||||
'${(await getApplicationDocumentsDirectory()).path}${Platform.pathSeparator}notes');
|
||||
}
|
||||
return dbpath;
|
||||
}
|
Reference in New Issue
Block a user