Added models for the user and its summary
This commit is contained in:
parent
223d367f54
commit
257aebec5f
3 changed files with 97 additions and 0 deletions
37
lib/src/models/summary_model.dart
Normal file
37
lib/src/models/summary_model.dart
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
class SummaryModel {
|
||||
final int completedMonday;
|
||||
final int addedMonday;
|
||||
final int completedTuesday;
|
||||
final int addedTuesday;
|
||||
final int completedWednesday;
|
||||
final int addedWednesday;
|
||||
final int completedThursday;
|
||||
final int addedThursday;
|
||||
final int completedFriday;
|
||||
final int addedFriday;
|
||||
|
||||
SummaryModel({
|
||||
this.completedMonday,
|
||||
this.addedMonday,
|
||||
this.completedTuesday,
|
||||
this.addedTuesday,
|
||||
this.completedWednesday,
|
||||
this.addedWednesday,
|
||||
this.completedThursday,
|
||||
this.addedThursday,
|
||||
this.completedFriday,
|
||||
this.addedFriday,
|
||||
});
|
||||
|
||||
SummaryModel.fromMap(Map<String, dynamic> map)
|
||||
: completedMonday = map["completedMonday"],
|
||||
addedMonday = map["addedMonday"],
|
||||
completedTuesday = map["completedTuesday"],
|
||||
addedTuesday = map["addedTuesday"],
|
||||
completedWednesday = map["completedWednesday"],
|
||||
addedWednesday = map["addedWednesday"],
|
||||
completedThursday = map["completedThursday"],
|
||||
addedThursday = map["addedThursday"],
|
||||
completedFriday = map["completedFriday"],
|
||||
addedFriday = map["addedFriday"];
|
||||
}
|
||||
36
lib/src/models/user_model.dart
Normal file
36
lib/src/models/user_model.dart
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import 'summary_model.dart';
|
||||
|
||||
class UserModel {
|
||||
final String username;
|
||||
final List<int> tasks;
|
||||
final SummaryModel summary;
|
||||
final int userId;
|
||||
final int pendingHigh;
|
||||
final int pendingMedium;
|
||||
final int pendingLow;
|
||||
|
||||
UserModel({
|
||||
this.username,
|
||||
this.tasks,
|
||||
this.summary,
|
||||
this.userId,
|
||||
this.pendingHigh,
|
||||
this.pendingMedium,
|
||||
this.pendingLow,
|
||||
}) : assert(username != null),
|
||||
assert(tasks != null),
|
||||
assert(summary != null),
|
||||
assert(userId != null),
|
||||
assert(pendingHigh != null),
|
||||
assert(pendingMedium != null),
|
||||
assert(pendingLow != null);
|
||||
|
||||
UserModel.fromFirestore(Map<String, dynamic> firestoreMap)
|
||||
: username = firestoreMap["username"],
|
||||
tasks = firestoreMap["tasks"].cast<int>(),
|
||||
summary = SummaryModel.fromMap(firestoreMap),
|
||||
userId = firestoreMap["userId"],
|
||||
pendingHigh = firestoreMap["pendingHigh"],
|
||||
pendingMedium = firestoreMap["pendingMedium"],
|
||||
pendingLow = firestoreMap["pendingLow"];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue