@@ -4,6 +4,83 @@ import 'package:flutter/material.dart';
4
4
import 'package:smashlibs/smashlibs.dart' ;
5
5
6
6
class MockProjectDb implements ProjectDb {
7
+ List <Note > notes = [
8
+ // SimpleNote (Text)
9
+ Note ()
10
+ ..id = 1
11
+ ..lon = 11.33140
12
+ ..lat = 46.47781
13
+ ..altim = - 1.0
14
+ ..timeStamp = DateTime .now ().millisecondsSinceEpoch
15
+ ..description = "POI"
16
+ ..text = "note"
17
+ ..form = null
18
+ ..style = null
19
+ ..isDirty = 1 ,
20
+ // FormNote (Image)
21
+ Note ()
22
+ ..id = 2
23
+ ..lon = 11.33140
24
+ ..lat = 46.47781
25
+ ..altim = - 1.0
26
+ ..timeStamp = DateTime .now ().millisecondsSinceEpoch
27
+ ..description = "POI"
28
+ ..text = "image note"
29
+ ..form =
30
+ '{"sectionname":"image note","sectiondescription":"note with image","sectionicon":"image","forms":[{"formname":"image note","formitems":[{"key":"description","islabel":"true","value":"test","icon":"infoCircle","type":"string","mandatory":"no"},{"key":"images","value":"2","type":"pictures"}]},{"formname":"image from library","formitems":[{"key":"description","islabel":"true","value":"","icon":"infoCircle","type":"string","mandatory":"no"},{"key":"imagesfromlib","value":"","type":"imagelib"}]}]}'
31
+ ..style = null
32
+ ..isDirty = 1 ,
33
+ // FormNote (Text)
34
+ Note ()
35
+ ..id = 3
36
+ ..lon = 11.33140
37
+ ..lat = 46.47781
38
+ ..altim = - 1.0
39
+ ..timeStamp = DateTime .now ().millisecondsSinceEpoch
40
+ ..description = "POI"
41
+ ..text = "text note"
42
+ ..form =
43
+ '{"sectionname":"text note","sectiondescription":"a simple text note","sectionicon":"fileAlt","forms":[{"formname":"text note","formitems":[{"key":"title","value":"title","icon":"font","islabel":"true","type":"string","mandatory":"no"},{"key":"description","value":"test","icon":"infoCircle","type":"string","mandatory":"no"}]}]}'
44
+ ..style = null
45
+ ..isDirty = 1 ,
46
+ ];
47
+
48
+ List <DbImage > images = [
49
+ // SimpleNote (Image)
50
+ DbImage ()
51
+ ..id = 1
52
+ ..lon = 11.33140
53
+ ..lat = 46.47781
54
+ ..altim = - 1.0
55
+ ..azim = - 1.0
56
+ ..imageDataId = 1
57
+ ..timeStamp = DateTime .now ().millisecondsSinceEpoch
58
+ ..text = "IMG_20221201_000000"
59
+ ..noteId = null
60
+ ..isDirty = 1 ,
61
+ // FormNote (Image)
62
+ DbImage ()
63
+ ..id = 2
64
+ ..lon = 11.33140
65
+ ..lat = 46.47781
66
+ ..altim = - 1.0
67
+ ..azim = - 1.0
68
+ ..imageDataId = 2
69
+ ..timeStamp = DateTime .now ().millisecondsSinceEpoch
70
+ ..text = "IMG_20221202_000000"
71
+ ..noteId = 2
72
+ ..isDirty = 1 ,
73
+ ];
74
+
75
+ List <Log > logs = [
76
+ Log ()
77
+ ..id = 1
78
+ ..startTime = DateTime .now ().millisecondsSinceEpoch - 1000
79
+ ..endTime = DateTime .now ().millisecondsSinceEpoch
80
+ ..lengthm = 0
81
+ ..isDirty = 1
82
+ ..text = "log_20221202_000000"
83
+ ];
7
84
8
85
@override
9
86
String getPath () {
@@ -12,80 +89,58 @@ class MockProjectDb implements ProjectDb {
12
89
13
90
@override
14
91
int getNotesCount (bool onlyDirty) {
15
- return 1 ;
92
+ return notes
93
+ .where ((Note n) => (! onlyDirty || (onlyDirty && n.isDirty == 1 )))
94
+ .length;
16
95
}
17
96
18
97
@override
19
98
int getSimpleNotesCount (bool onlyDirty) {
20
- return 1 ;
99
+ return notes
100
+ .where ((Note n) =>
101
+ ((! onlyDirty || (onlyDirty && n.isDirty == 1 )) && (n.form == null )))
102
+ .length;
21
103
}
22
104
23
105
@override
24
106
int getFormNotesCount (bool onlyDirty) {
25
- return 1 ;
107
+ return notes
108
+ .where ((Note n) =>
109
+ ((! onlyDirty || (onlyDirty && n.isDirty == 1 )) && (n.form != null )))
110
+ .length;
26
111
}
27
112
28
113
List <Note > getNotes ({bool ? doSimple, bool onlyDirty: false }) {
29
- Note note = Note ()
30
- ..id = 1
31
- ..lon = 135
32
- ..lat = 35
33
- ..altim = 0
34
- ..timeStamp = 0
35
- ..description = "Mock note description"
36
- ..text = "Mock note text"
37
- ..form = "Mock note form"
38
- ..style = "Mock note style"
39
- ..isDirty = 1 ;
40
- return [note];
114
+ return notes
115
+ .where ((Note n) => ((! onlyDirty || (onlyDirty && n.isDirty == 1 )) &&
116
+ (doSimple == null ||
117
+ (doSimple && n.form == null ) ||
118
+ (! doSimple && n.form != null ))))
119
+ .toList ();
41
120
}
42
121
43
122
Note getNoteById (int id) {
44
- Note note = Note ()
45
- ..id = 1
46
- ..lon = 135
47
- ..lat = 35
48
- ..altim = 0
49
- ..timeStamp = 0
50
- ..description = "Mock note description"
51
- ..text = "Mock note text"
52
- ..form = "Mock note form"
53
- ..style = "Mock note style"
54
- ..isDirty = 1 ;
55
- return note;
123
+ return notes.firstWhere ((Note n) => n.id == id);
56
124
}
57
125
58
126
@override
59
127
int getImagesCount (bool onlyDirty) {
60
- return 0 ;
128
+ return images
129
+ .where ((DbImage i) => (! onlyDirty || (onlyDirty && i.isDirty == 1 )))
130
+ .length;
61
131
}
62
132
63
133
@override
64
134
List <DbImage > getImages ({bool onlyDirty = false , bool onlySimple = true }) {
65
- DbImage image = DbImage ()
66
- ..id = 1
67
- ..lon = 135
68
- ..lat = 35
69
- ..altim = 0
70
- // TODO:
71
- ..timeStamp = 0
72
- ..text = "Mock image text"
73
- ..isDirty = 1 ;
74
- return [image];
135
+ return images
136
+ .where ((DbImage i) => ((! onlyDirty || (onlyDirty && i.isDirty == 1 )) &&
137
+ (onlySimple != true || (onlySimple == true && i.noteId == null ))))
138
+ .toList ();
75
139
}
76
140
77
141
@override
78
142
DbImage getImageById (int imageId) {
79
- DbImage image = DbImage ()
80
- ..id = 1
81
- ..lon = 135
82
- ..lat = 35
83
- ..altim = 0
84
- // TODO:
85
- ..timeStamp = 0
86
- ..text = "Mock image text"
87
- ..isDirty = 1 ;
88
- return image;
143
+ return images.firstWhere ((DbImage i) => i.id == imageId);
89
144
}
90
145
91
146
@override
@@ -140,17 +195,21 @@ class MockProjectDb implements ProjectDb {
140
195
141
196
@override
142
197
int getGpsLogCount (bool onlyDirty) {
143
- return 0 ;
198
+ return logs
199
+ .where ((Log l) => (! onlyDirty || (onlyDirty && l.isDirty == 1 )))
200
+ .length;
144
201
}
145
202
146
203
@override
147
204
List <Log > getLogs ({bool onlyDirty: false }) {
148
- return [];
205
+ return logs
206
+ .where ((Log l) => (! onlyDirty || (onlyDirty && l.isDirty == 1 )))
207
+ .toList ();
149
208
}
150
209
151
210
@override
152
211
Log ? getLogById (int logId) {
153
- return null ;
212
+ return logs. firstWhere (( Log l) => l.id == logId) ;
154
213
}
155
214
156
215
@override
@@ -247,4 +306,4 @@ class MockProjectDb implements ProjectDb {
247
306
void printInfo () {
248
307
return ;
249
308
}
250
- }
309
+ }
0 commit comments