-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.dart
239 lines (215 loc) · 6.21 KB
/
models.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
import 'package:get/get.dart';
//! user model
class UserModel {
const UserModel({
this.userId = "",
this.username = "",
this.email = "",
this.savedRom = const [],
this.verified = false,
this.moderator = false,
});
final String userId;
final String username;
final String email;
final List savedRom;
final bool verified;
final bool moderator;
factory UserModel.fromMap(Map<String, dynamic> data) => UserModel(
userId: data["_id"],
username: data["username"],
email: data["email"],
savedRom: data["savedRom"],
verified: data["verified"],
moderator: data["moderator"],
);
}
//! device model
class DeviceModel {
const DeviceModel({
this.codename = "",
this.name = "",
});
final String codename;
final String name;
factory DeviceModel.fromMap(Map<String, dynamic> data) => DeviceModel(
codename: data["codename"] ?? "",
name: data["name"] ?? "",
);
}
//! specs -> device model
class Specs {
const Specs({
this.camera = "",
this.battery = 0,
this.processor = "",
});
final String camera;
final int battery;
final String processor;
factory Specs.fromMap(Map<String, dynamic> data) => Specs(
camera: data["camera"] ?? "",
battery: data["battery"] ?? 0,
processor: data["processor"] ?? "",
);
}
//! version model
class VersionModel {
VersionModel({
this.id = "",
this.romid = "",
this.codename = "",
required this.date,
this.changelog = const [],
this.error = const [],
this.gappslink = "",
this.vanillalink = "",
this.downloadnumber = 0,
this.relasetype = "",
this.official = false,
this.uploadedBy = "",
this.versionNum = "",
});
final String id;
final String romid;
final String codename;
final DateTime date;
final List<dynamic> changelog;
final bool official;
final List<dynamic> error;
final String gappslink;
final String vanillalink;
final int downloadnumber;
final String relasetype;
final String uploadedBy;
final String versionNum;
factory VersionModel.fromMap(Map<String, dynamic> data) => VersionModel(
id: data["id"] ?? "",
romid: data["romid"] ?? "",
codename: data["codename"] ?? "",
date: DateTime.parse(data["date"]),
changelog: List<dynamic>.from(data["changelog"].map((x) => x)),
error: List<dynamic>.from(data["error"].map((x) => x)),
official: data["official"] ?? false,
gappslink: data["gappslink"] ?? "",
vanillalink: data["vanillalink"] ?? "",
downloadnumber: data["downloadnumber"] ?? 0,
relasetype: data["relasetype"] ?? "",
uploadedBy: data["uploadedby"] ?? "",
versionNum: data["version"] ?? "");
}
//! rom model
class RomModel {
const RomModel({
this.id = "",
this.romname = "",
this.androidversion = 0,
this.screenshot,
this.logo = "",
this.description = "",
this.link = const [],
this.verified = false,
this.codename = const [],
this.review = const Review(),
this.uploadedby = "",
});
final String id;
final String romname;
final int androidversion;
final RxList<String>? screenshot;
final String logo;
final String description;
final List<dynamic> link;
final bool verified;
final List<String> codename;
final Review review;
final String uploadedby;
factory RomModel.fromMap(Map<String, dynamic> data) => RomModel(
id: data["id"] ?? "",
romname: data["romname"] ?? "",
androidversion: data["androidversion"] ?? "",
screenshot: RxList<String>.from(data["screenshot"].map((x) => x)),
logo: data["logo"] ?? "",
description: data["description"] ?? "",
link: List<dynamic>.from(data["link"].map((x) => x)),
verified: data["verified"] ?? false,
codename: List<String>.from(data["codename"].map((x) => x)),
review: Review.fromMap(data["review"]),
uploadedby: data["uploadedby"] ?? "",
);
}
//! review -> rom model
class Review {
const Review({
this.battery = 0,
this.performance = 0,
this.stability = 0,
this.customization = 0,
this.revNum = 0,
});
final double battery;
final double performance;
final double stability;
final double customization;
final int revNum;
factory Review.fromMap(Map<String, dynamic> data) {
var x = int.parse(data["reviewnum"].toString());
if (x == 0) return const Review(battery: 0, performance: 0, stability: 0, customization: 0, revNum: 0);
return Review(
battery: double.parse(data["battery"].toString()) / x,
performance: double.parse(data["performance"].toString()) / x,
stability: double.parse(data["stability"].toString()) / x,
customization: double.parse(data["customization"].toString()) / x,
revNum: x,
);
}
}
//! comment -> rom model
class CommentModel {
const CommentModel({
this.romId = "",
this.codename = "",
this.username = "",
this.msg = "",
this.battery = 0,
this.performance = 0,
this.stability = 0,
this.customization = 0,
});
final String romId;
final String codename;
final String username;
final String msg;
final double battery;
final double performance;
final double stability;
final double customization;
factory CommentModel.fromMap(Map<String, dynamic> data) => CommentModel(
romId: data["romid"] ?? "",
codename: data["codename"] ?? "",
username: data["username"] ?? "",
msg: data["msg"] ?? "",
battery: double.parse(data["battery"].toString()),
performance: double.parse(data["performance"].toString()),
stability: double.parse(data["stability"].toString()),
customization: double.parse(data["customization"].toString()),
);
}
class RequestModel {
const RequestModel({
this.id = "",
this.romname = "",
this.codename = "",
this.androidVersion = 0,
});
final String id;
final String romname;
final String codename;
final double androidVersion;
factory RequestModel.fromMap(Map<String, dynamic> data) => RequestModel(
id: data["id"] ?? "",
romname: data["romname"] ?? "",
codename: data["codename"] ?? "",
androidVersion: double.parse(data["androidversion"] ?? "0"),
);
}