From 2f12601c1f05a25c05315490da276532d6bcba1e Mon Sep 17 00:00:00 2001 From: AYM1607 Date: Fri, 5 Apr 2019 13:30:36 -0600 Subject: [PATCH] Added docs for the event model, deleted the tasks property --- lib/src/models/event_model.dart | 39 ++++++++++++++++--- .../resources/firestore_provider_test.dart | 1 - 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/lib/src/models/event_model.dart b/lib/src/models/event_model.dart index c78310e..631b09e 100644 --- a/lib/src/models/event_model.dart +++ b/lib/src/models/event_model.dart @@ -1,14 +1,37 @@ import 'package:meta/meta.dart'; +/// A user's event. +/// +/// Represents all the data linked to an event. class EventModel { + /// The event id in the database. final String id; + + /// The event name. final String name; + + /// The amount of pending tasks linked to this event. 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 when; + + /// The media files linked to this event. + /// + /// The list items are data bucket paths. final List media; - final List tasks; + + /// The amount of high priority pending tasks linked to this event. final int highPriority; + + /// The amount of medium priority pending tasks linked to this event. final int mediumPriority; + + /// The amount of low priority pending tasks linked to this event. final int lowPriority; EventModel({ @@ -17,30 +40,35 @@ class EventModel { @required this.pendigTasks, @required this.when, @required this.media, - @required this.tasks, @required this.highPriority, @required this.mediumPriority, @required this.lowPriority, }); - EventModel.fromFirestore(Map 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 firestoreMap, + {@required String id}) : id = id, name = firestoreMap["name"], pendigTasks = firestoreMap["pendingTasks"], when = firestoreMap["when"].cast(), media = firestoreMap["media"].cast(), - tasks = firestoreMap["tasks"].cast(), highPriority = firestoreMap["highPriority"], mediumPriority = firestoreMap["mediumPriority"], 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 toFirestoreMap() { return { "name": name, "pendingTasks": pendigTasks, "when": when, "media": media, - "tasks": tasks, "highPriority": highPriority, "mediumPriority": mediumPriority, "lowPriority": lowPriority, @@ -54,7 +82,6 @@ class EventModel { pendigTasks.hashCode ^ when.hashCode ^ media.hashCode ^ - tasks.hashCode ^ highPriority.hashCode ^ mediumPriority.hashCode ^ lowPriority.hashCode; diff --git a/test/src/resources/firestore_provider_test.dart b/test/src/resources/firestore_provider_test.dart index 0fe9d6d..8c2f43f 100644 --- a/test/src/resources/firestore_provider_test.dart +++ b/test/src/resources/firestore_provider_test.dart @@ -17,7 +17,6 @@ main() { name: 'An event', pendigTasks: 0, media: [], - tasks: [], when: [], highPriority: 0, mediumPriority: 0,