Added docs for the event model, deleted the tasks property
This commit is contained in:
parent
dd435a46b3
commit
2f12601c1f
2 changed files with 33 additions and 7 deletions
|
|
@ -1,14 +1,37 @@
|
||||||
import 'package:meta/meta.dart';
|
import 'package:meta/meta.dart';
|
||||||
|
|
||||||
|
/// A user's event.
|
||||||
|
///
|
||||||
|
/// Represents all the data linked to an event.
|
||||||
class EventModel {
|
class EventModel {
|
||||||
|
/// The event id in the database.
|
||||||
final String id;
|
final String id;
|
||||||
|
|
||||||
|
/// The event name.
|
||||||
final String name;
|
final String name;
|
||||||
|
|
||||||
|
/// The amount of pending tasks linked to this event.
|
||||||
final int pendigTasks;
|
final int pendigTasks;
|
||||||
|
|
||||||
|
// TODO: Create a data model for [when]. It should support both days and times.
|
||||||
|
/// A representation of the ocurrance of this event.
|
||||||
|
///
|
||||||
|
/// This list whould contain five items each representing a day of the week.
|
||||||
|
/// If the value for a day is true then the event happens at that day.
|
||||||
final List<bool> when;
|
final List<bool> when;
|
||||||
|
|
||||||
|
/// The media files linked to this event.
|
||||||
|
///
|
||||||
|
/// The list items are data bucket paths.
|
||||||
final List<String> media;
|
final List<String> media;
|
||||||
final List<String> tasks;
|
|
||||||
|
/// The amount of high priority pending tasks linked to this event.
|
||||||
final int highPriority;
|
final int highPriority;
|
||||||
|
|
||||||
|
/// The amount of medium priority pending tasks linked to this event.
|
||||||
final int mediumPriority;
|
final int mediumPriority;
|
||||||
|
|
||||||
|
/// The amount of low priority pending tasks linked to this event.
|
||||||
final int lowPriority;
|
final int lowPriority;
|
||||||
|
|
||||||
EventModel({
|
EventModel({
|
||||||
|
|
@ -17,30 +40,35 @@ class EventModel {
|
||||||
@required this.pendigTasks,
|
@required this.pendigTasks,
|
||||||
@required this.when,
|
@required this.when,
|
||||||
@required this.media,
|
@required this.media,
|
||||||
@required this.tasks,
|
|
||||||
@required this.highPriority,
|
@required this.highPriority,
|
||||||
@required this.mediumPriority,
|
@required this.mediumPriority,
|
||||||
@required this.lowPriority,
|
@required this.lowPriority,
|
||||||
});
|
});
|
||||||
|
|
||||||
EventModel.fromFirestore(Map<String, dynamic> firestoreMap, {String id})
|
/// Creates an [EventModel] from a firestore map.
|
||||||
|
///
|
||||||
|
/// The database id for the event is not provided inside the map but should
|
||||||
|
/// always be specified.
|
||||||
|
EventModel.fromFirestore(Map<String, dynamic> firestoreMap,
|
||||||
|
{@required String id})
|
||||||
: id = id,
|
: id = id,
|
||||||
name = firestoreMap["name"],
|
name = firestoreMap["name"],
|
||||||
pendigTasks = firestoreMap["pendingTasks"],
|
pendigTasks = firestoreMap["pendingTasks"],
|
||||||
when = firestoreMap["when"].cast<bool>(),
|
when = firestoreMap["when"].cast<bool>(),
|
||||||
media = firestoreMap["media"].cast<String>(),
|
media = firestoreMap["media"].cast<String>(),
|
||||||
tasks = firestoreMap["tasks"].cast<String>(),
|
|
||||||
highPriority = firestoreMap["highPriority"],
|
highPriority = firestoreMap["highPriority"],
|
||||||
mediumPriority = firestoreMap["mediumPriority"],
|
mediumPriority = firestoreMap["mediumPriority"],
|
||||||
lowPriority = firestoreMap["lowPriority"];
|
lowPriority = firestoreMap["lowPriority"];
|
||||||
|
|
||||||
|
/// Returns a map that contains all the event's fields.
|
||||||
|
///
|
||||||
|
/// The id field does not need to be included, it is provided separately.
|
||||||
Map<String, dynamic> toFirestoreMap() {
|
Map<String, dynamic> toFirestoreMap() {
|
||||||
return <String, dynamic>{
|
return <String, dynamic>{
|
||||||
"name": name,
|
"name": name,
|
||||||
"pendingTasks": pendigTasks,
|
"pendingTasks": pendigTasks,
|
||||||
"when": when,
|
"when": when,
|
||||||
"media": media,
|
"media": media,
|
||||||
"tasks": tasks,
|
|
||||||
"highPriority": highPriority,
|
"highPriority": highPriority,
|
||||||
"mediumPriority": mediumPriority,
|
"mediumPriority": mediumPriority,
|
||||||
"lowPriority": lowPriority,
|
"lowPriority": lowPriority,
|
||||||
|
|
@ -54,7 +82,6 @@ class EventModel {
|
||||||
pendigTasks.hashCode ^
|
pendigTasks.hashCode ^
|
||||||
when.hashCode ^
|
when.hashCode ^
|
||||||
media.hashCode ^
|
media.hashCode ^
|
||||||
tasks.hashCode ^
|
|
||||||
highPriority.hashCode ^
|
highPriority.hashCode ^
|
||||||
mediumPriority.hashCode ^
|
mediumPriority.hashCode ^
|
||||||
lowPriority.hashCode;
|
lowPriority.hashCode;
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ main() {
|
||||||
name: 'An event',
|
name: 'An event',
|
||||||
pendigTasks: 0,
|
pendigTasks: 0,
|
||||||
media: <String>[],
|
media: <String>[],
|
||||||
tasks: <String>[],
|
|
||||||
when: <bool>[],
|
when: <bool>[],
|
||||||
highPriority: 0,
|
highPriority: 0,
|
||||||
mediumPriority: 0,
|
mediumPriority: 0,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue