save correct color to db
use different pointer for highlighter
This commit is contained in:
@ -5,9 +5,13 @@ import 'note_file.dart';
|
||||
|
||||
extension LineLoading on NoteFile {
|
||||
Future<List<Stroke>> loadStrokes() async {
|
||||
final query = await db().query('points',
|
||||
orderBy: 'strokeid',
|
||||
columns: ['x', 'y', 'thickness', 'strokeid', 'id']);
|
||||
const sql = '''
|
||||
SELECT x, y, thickness, strokeid, points.id, s.color
|
||||
from points
|
||||
JOIN strokes s on s.id = strokeid
|
||||
ORDER BY strokeid
|
||||
''';
|
||||
final query = await db().rawQuery(sql);
|
||||
int strokeid = -1;
|
||||
List<Stroke> strokes = [];
|
||||
|
||||
@ -15,7 +19,7 @@ extension LineLoading on NoteFile {
|
||||
final int csid = i['strokeid'] as int;
|
||||
if (csid != strokeid) {
|
||||
strokeid = csid;
|
||||
strokes.add(Stroke(strokeid, Colors.green));
|
||||
strokes.add(Stroke(strokeid, Color(i['color'] as int)));
|
||||
}
|
||||
final Point p = Point(
|
||||
Offset(i['x'] as double, i['y'] as double), i['thickness'] as double);
|
||||
@ -26,11 +30,12 @@ extension LineLoading on NoteFile {
|
||||
}
|
||||
|
||||
// create new stroke in file and return strokeid
|
||||
Future<void> addStroke(int newStrokeId) async {
|
||||
Future<void> addStroke(int newStrokeId, Color color) async {
|
||||
await db().insert(
|
||||
'strokes', {'color': 0xffffff, 'elevation': 0, 'id': newStrokeId});
|
||||
'strokes', {'color': color.value, 'elevation': 0, 'id': newStrokeId});
|
||||
}
|
||||
|
||||
// add one point to a stroke in db
|
||||
Future<void> addPoint(int strokeid, Point p) async {
|
||||
await db().insert('points', {
|
||||
'x': p.point.dx,
|
||||
@ -40,6 +45,7 @@ extension LineLoading on NoteFile {
|
||||
});
|
||||
}
|
||||
|
||||
// add list of points to a stroke in db
|
||||
Future<void> addPoints(int strokeid, List<Point> pts) async {
|
||||
final batch = db().batch();
|
||||
for (final p in pts) {
|
||||
|
Reference in New Issue
Block a user