changed everything from filcnaplo to refilc finally
This commit is contained in:
35
refilc/lib/models/subject_lesson_count.dart
Normal file
35
refilc/lib/models/subject_lesson_count.dart
Normal file
@@ -0,0 +1,35 @@
|
||||
import 'package:refilc_kreta_api/models/category.dart';
|
||||
import 'package:refilc_kreta_api/models/subject.dart';
|
||||
|
||||
enum SubjectLessonCountUpdateState { ready, updating }
|
||||
|
||||
class SubjectLessonCount {
|
||||
DateTime lastUpdated;
|
||||
Map<GradeSubject, int> subjects;
|
||||
SubjectLessonCountUpdateState state;
|
||||
|
||||
SubjectLessonCount(
|
||||
{required this.lastUpdated,
|
||||
required this.subjects,
|
||||
this.state = SubjectLessonCountUpdateState.ready});
|
||||
|
||||
factory SubjectLessonCount.fromMap(Map json) {
|
||||
return SubjectLessonCount(
|
||||
lastUpdated:
|
||||
DateTime.fromMillisecondsSinceEpoch(json["last_updated"] ?? 0),
|
||||
subjects: ((json["subjects"] as Map?) ?? {}).map(
|
||||
(key, value) => MapEntry(
|
||||
GradeSubject(id: key, name: "", category: Category.fromJson({})),
|
||||
value,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Map toMap() {
|
||||
return {
|
||||
"last_updated": lastUpdated.millisecondsSinceEpoch,
|
||||
"subjects": subjects.map((key, value) => MapEntry(key.id, value)),
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user