Line data Source code
1 : import 'package:flutter/material.dart';
2 : import 'package:hive/hive.dart';
3 : import 'package:pal/src/database/entity/helper/helper_trigger_type.dart';
4 : import 'package:pal/src/database/entity/helper/helper_type.dart';
5 :
6 : part 'helper_entity.g.dart';
7 :
8 : @HiveType(typeId: 3)
9 : class HelperEntity {
10 :
11 : @HiveField(0)
12 : String id;
13 :
14 : @HiveField(1)
15 : DateTime creationDate;
16 :
17 : @HiveField(2)
18 : DateTime lastUpdateDate;
19 :
20 : @HiveField(3)
21 : String name;
22 :
23 : @HiveField(4)
24 : int priority;
25 :
26 : @HiveField(5)
27 : HelperType type;
28 :
29 : @HiveField(6)
30 : HelperTriggerType triggerType;
31 :
32 : @HiveField(7)
33 : int versionMinId;
34 :
35 : @HiveField(8)
36 : String versionMin;
37 :
38 : @HiveField(9)
39 : int versionMaxId;
40 :
41 : @HiveField(10)
42 : String versionMax;
43 :
44 : @HiveField(11)
45 : List<HelperBorderEntity> helperBorders;
46 :
47 : @HiveField(12)
48 : List<HelperImageEntity> helperImages;
49 :
50 : @HiveField(13)
51 : List<HelperTextEntity> helperTexts;
52 :
53 : @HiveField(14)
54 : List<HelperBoxEntity> helperBoxes;
55 :
56 8 : HelperEntity(
57 : {this.id,
58 : this.name,
59 : this.type,
60 : this.triggerType,
61 : this.creationDate,
62 : this.lastUpdateDate,
63 : this.priority,
64 : this.versionMinId,
65 : this.versionMin,
66 : this.versionMaxId,
67 : this.versionMax,
68 : this.helperBorders,
69 : this.helperImages,
70 : this.helperTexts,
71 : this.helperBoxes});
72 :
73 1 : factory HelperEntity.copy(HelperEntity from) {
74 1 : return HelperEntity(
75 2 : id: '${from.id}',
76 2 : name: '${from.name}',
77 1 : type: from.type,
78 1 : triggerType: from.triggerType,
79 1 : creationDate: from.creationDate,
80 1 : lastUpdateDate: from.lastUpdateDate,
81 1 : priority: from.priority,
82 1 : versionMinId: from.versionMinId,
83 1 : versionMin: from.versionMin,
84 1 : versionMaxId: from.versionMaxId,
85 1 : versionMax: from.versionMax,
86 1 : helperBorders: from.helperBorders != null ? [...from.helperBorders] : null,
87 4 : helperImages: from.helperImages != null ? [...from.helperImages] : null,
88 4 : helperTexts: from.helperTexts != null ? [...from.helperTexts] : null,
89 4 : helperBoxes: from.helperBoxes != null ? [...from.helperBoxes] : null,
90 : );
91 : }
92 :
93 2 : Map<String, dynamic> toJson() => {
94 1 : 'id': id,
95 1 : 'name': name,
96 4 : 'type': type.toString().split('.')[1],
97 4 : 'triggerType': triggerType.toString().split('.')[1],
98 1 : 'creationDate': creationDate != null ? creationDate.toIso8601String() : null,
99 1 : 'lastUpdateDate': lastUpdateDate != null ? lastUpdateDate.toIso8601String() : null,
100 1 : 'priority': priority,
101 1 : 'versionMinId': versionMinId,
102 1 : 'versionMin': versionMin,
103 1 : 'versionMaxId': versionMaxId,
104 1 : 'versionMax': versionMax,
105 1 : 'helperBorders': helperBorders,
106 1 : 'helperImages': helperImages,
107 1 : 'helperTexts': helperTexts,
108 1 : 'helperBoxes': helperBoxes,
109 : };
110 :
111 3 : @override
112 : bool operator ==(Object other) =>
113 : identical(this, other) ||
114 1 : other is HelperEntity &&
115 3 : id == other.id &&
116 0 : creationDate == other.creationDate &&
117 0 : lastUpdateDate == other.lastUpdateDate &&
118 0 : name == other.name &&
119 0 : priority == other.priority &&
120 0 : type == other.type &&
121 0 : triggerType == other.triggerType &&
122 0 : versionMinId == other.versionMinId &&
123 0 : versionMin == other.versionMin &&
124 0 : versionMaxId == other.versionMaxId &&
125 0 : versionMax == other.versionMax &&
126 0 : helperBorders == other.helperBorders &&
127 0 : helperImages == other.helperImages &&
128 0 : helperBoxes == other.helperBoxes &&
129 0 : helperTexts == other.helperTexts;
130 :
131 0 : @override
132 : int get hashCode =>
133 0 : id.hashCode ^
134 0 : creationDate.hashCode ^
135 0 : lastUpdateDate.hashCode ^
136 0 : name.hashCode ^
137 0 : priority.hashCode ^
138 0 : type.hashCode ^
139 0 : triggerType.hashCode ^
140 0 : versionMinId.hashCode ^
141 0 : versionMin.hashCode ^
142 0 : versionMaxId.hashCode ^
143 0 : versionMax.hashCode ^
144 0 : helperBorders.hashCode ^
145 0 : helperImages.hashCode ^
146 0 : helperTexts.hashCode;
147 : }
148 :
149 : @HiveType(typeId: 4)
150 : class HelperBorderEntity {
151 :
152 : @HiveField(0)
153 : int id;
154 :
155 : @HiveField(1)
156 : String color;
157 :
158 : @HiveField(2)
159 : String key;
160 :
161 : @HiveField(3)
162 : String style;
163 :
164 : @HiveField(4)
165 : double width;
166 :
167 0 : HelperBorderEntity({this.id, this.color, this.key, this.style, this.width});
168 :
169 0 : Map<String, dynamic> toJson() => {
170 0 : 'id': id,
171 0 : 'color': color,
172 0 : 'key': key,
173 0 : 'style': style,
174 0 : 'width': width,
175 : };
176 :
177 0 : HelperBorderEntity copy() => HelperBorderEntity(
178 0 : id: id,
179 0 : color: color,
180 0 : key: key,
181 0 : style: style,
182 0 : width: width,
183 : );
184 :
185 0 : @override
186 : bool operator ==(Object other) =>
187 : identical(this, other) ||
188 0 : other is HelperBorderEntity &&
189 0 : id == other.id &&
190 0 : color == other.color &&
191 0 : key == other.key &&
192 0 : style == other.style &&
193 0 : width == other.width;
194 :
195 0 : @override
196 : int get hashCode =>
197 0 : id.hashCode ^
198 0 : color.hashCode ^
199 0 : key.hashCode ^
200 0 : style.hashCode ^
201 0 : width.hashCode;
202 : }
203 :
204 : @HiveType(typeId: 5)
205 : class HelperImageEntity {
206 :
207 : @HiveField(0)
208 : int id;
209 :
210 : @HiveField(1)
211 : String key;
212 :
213 : @HiveField(2)
214 : String url;
215 :
216 2 : Map<String, dynamic> toJson() => {
217 1 : 'id': id,
218 1 : 'key': key,
219 1 : 'url': url,
220 : };
221 :
222 3 : HelperImageEntity({this.id, this.key, @required this.url});
223 :
224 0 : HelperImageEntity copy() => HelperImageEntity(
225 0 : id: id,
226 0 : key: key,
227 0 : url: url
228 : );
229 :
230 0 : @override
231 : bool operator ==(Object other) =>
232 : identical(this, other) ||
233 0 : other is HelperImageEntity &&
234 0 : id == other.id &&
235 0 : key == other.key &&
236 0 : url == other.url;
237 :
238 0 : @override
239 0 : int get hashCode => id.hashCode ^ key.hashCode ^ url.hashCode;
240 : }
241 :
242 : @HiveType(typeId: 6)
243 : class HelperTextEntity {
244 :
245 : @HiveField(0)
246 : int id;
247 :
248 : @HiveField(1)
249 : String fontColor;
250 :
251 : @HiveField(2)
252 : String fontFamily;
253 :
254 : @HiveField(3)
255 : String fontWeight;
256 :
257 : @HiveField(4)
258 : String key;
259 :
260 : @HiveField(5)
261 : String value;
262 :
263 : @HiveField(6)
264 : int fontSize;
265 :
266 3 : HelperTextEntity({
267 : this.id,
268 : this.fontColor,
269 : this.fontFamily,
270 : this.fontWeight,
271 : this.key,
272 : this.value,
273 : this.fontSize,
274 : });
275 :
276 2 : Map<String, dynamic> toJson() => {
277 1 : 'id': id,
278 1 : 'fontColor': fontColor,
279 1 : 'fontFamily': fontFamily,
280 1 : 'fontWeight': fontWeight,
281 1 : 'fontSize': fontSize,
282 1 : 'key': key,
283 1 : 'value': value,
284 : };
285 :
286 0 : HelperTextEntity copy() => HelperTextEntity(
287 0 : id: id,
288 0 : fontColor: fontColor,
289 0 : fontFamily: fontFamily,
290 0 : fontWeight: fontWeight,
291 0 : key: key,
292 0 : value: value,
293 0 : fontSize: fontSize
294 : );
295 :
296 1 : @override
297 : bool operator ==(Object other) =>
298 : identical(this, other) ||
299 1 : other is HelperTextEntity &&
300 3 : id == other.id &&
301 3 : fontColor == other.fontColor &&
302 3 : fontFamily == other.fontFamily &&
303 3 : fontWeight == other.fontWeight &&
304 3 : key == other.key &&
305 0 : value == other.value &&
306 0 : fontSize == other.fontSize;
307 :
308 0 : @override
309 : int get hashCode =>
310 0 : id.hashCode ^
311 0 : fontColor.hashCode ^
312 0 : fontFamily.hashCode ^
313 0 : fontWeight.hashCode ^
314 0 : key.hashCode ^
315 0 : value.hashCode ^
316 0 : fontSize.hashCode;
317 : }
318 :
319 : @HiveType(typeId: 7)
320 : class HelperBoxEntity {
321 : @HiveField(0)
322 : int id;
323 :
324 : @HiveField(1)
325 : String backgroundColor;
326 :
327 : @HiveField(2)
328 : String key;
329 :
330 3 : HelperBoxEntity({
331 : this.id,
332 : @required this.backgroundColor,
333 : this.key,
334 : });
335 :
336 2 : Map<String, dynamic> toJson() => {
337 1 : 'id': id,
338 1 : 'backgroundColor': backgroundColor,
339 1 : 'key': key,
340 : };
341 :
342 0 : HelperBoxEntity copy() => HelperBoxEntity(
343 0 : id: this.id,
344 0 : backgroundColor: this.backgroundColor,
345 0 : key: this.key
346 : );
347 :
348 0 : @override
349 : bool operator ==(Object other) =>
350 : identical(this, other) ||
351 0 : other is HelperBoxEntity &&
352 0 : id == other.id &&
353 0 : backgroundColor == other.backgroundColor &&
354 0 : key == other.key;
355 :
356 0 : @override
357 0 : int get hashCode => id.hashCode ^ backgroundColor.hashCode ^ key.hashCode;
358 :
359 0 : factory HelperBoxEntity.copy(HelperBoxEntity from) {
360 0 : return HelperBoxEntity(
361 0 : id: from.id,
362 0 : backgroundColor: from.backgroundColor,
363 0 : key: from.key,
364 : );
365 : }
366 : }
|