creek

The AI Image Editor of 2030

lib/services/note_service.dart (1383B)


 1import 'package:creekui/data/repos/note_repo.dart';
 2import 'package:creekui/data/models/note_model.dart';
 3import 'analysis_queue_manager.dart';
 4
 5class NoteService {
 6  final _repo = NoteRepo();
 7
 8  Future<void> addNote(
 9    String imageId,
10    String content,
11    String category, {
12    double normX = 0.5,
13    double normY = 0.5,
14    double normWidth = 0.0,
15    double normHeight = 0.0,
16  }) async {
17    final note = NoteModel(
18      imageId: imageId,
19      content: content,
20      category: category,
21      createdAt: DateTime.now(),
22      normX: normX,
23      normY: normY,
24      normWidth: normWidth,
25      normHeight: normHeight,
26    );
27
28    await _repo.addNote(note);
29    AnalysisQueueManager().processQueue();
30  }
31
32  Future<void> updateNote(
33    int noteId, {
34    String? content,
35    String? category,
36    double? normX,
37    double? normY,
38    double? normWidth,
39    double? normHeight,
40  }) async {
41    // TODO: If category or crop area changes, need to re-analyze
42    await _repo.updateNote(
43      noteId,
44      content: content,
45      category: category,
46      normX: normX,
47      normY: normY,
48      normWidth: normWidth,
49      normHeight: normHeight,
50    );
51  }
52
53  Future<void> deleteNote(int noteId) async {
54    await _repo.deleteNote(noteId);
55  }
56
57  Future<List<NoteModel>> getNotesForImage(String imageId) async {
58    return await _repo.getNotesForImage(imageId);
59  }
60}