-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
1,153 additions
and
394 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+85.7 KB
assets/images/sketchbook-young-businesswoman-giving-a-presentation-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+187 KB
...s/images/sketchbook-young-man-and-his-dog-are-having-a-picnic-in-the-park-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,115 +1,21 @@ | ||
// /// The course model represents a course just as its name implies | ||
// class Course { | ||
// final String unit; | ||
// final String section; | ||
// final String dayOfWeek; | ||
// final String period; | ||
// final String campus; | ||
// final String room; | ||
// final String lecturer; | ||
// | ||
// Course({ | ||
// required this.unit, | ||
// required this.section, | ||
// required this.dayOfWeek, | ||
// required this.period, | ||
// required this.campus, | ||
// required this.room, | ||
// required this.lecturer, | ||
// }); | ||
// | ||
// // Method to convert Course instance to a Map (JSON format) | ||
// Map<String, dynamic> toJson() { | ||
// return { | ||
// 'unit': unit, | ||
// 'section': section, | ||
// 'day_of_the_week': dayOfWeek, | ||
// 'period': period, | ||
// 'campus': campus, | ||
// 'room': room, | ||
// 'lecturer': lecturer, | ||
// }; | ||
// } | ||
// | ||
// // Static method to create a Course instance from a Map (JSON format) | ||
// static Course fromJson(Map<String, dynamic> json) { | ||
// return Course( | ||
// unit: json['unit'], | ||
// section: json['section'], | ||
// dayOfWeek: json['day_of_the_week'], | ||
// period: json['period'], | ||
// campus: json['campus'], | ||
// room: json['room'], | ||
// lecturer: json['lecturer'], | ||
// ); | ||
// } | ||
// } | ||
|
||
import 'package:intl/intl.dart'; | ||
|
||
/// The course model represents a course just as its name implies | ||
class Course { | ||
final String unit; | ||
final String section; | ||
final String dayOfWeek; | ||
final String | ||
period; // This contains the time range (e.g., "02:10 PM-05:10 PM") | ||
final String campus; | ||
final String room; | ||
final String lecturer; | ||
late DateTime startTime; | ||
late DateTime stopTime; | ||
|
||
Course({ | ||
required this.unit, | ||
required this.section, | ||
required this.dayOfWeek, | ||
required this.period, | ||
required this.campus, | ||
required this.room, | ||
required this.lecturer, | ||
}) { | ||
extractTimesFromPeriod(period); | ||
} | ||
|
||
// Method to convert Course instance to a Map (JSON format) | ||
Map<String, dynamic> toJson() { | ||
return { | ||
'unit': unit, | ||
'section': section, | ||
'day_of_the_week': dayOfWeek, | ||
'period': period, | ||
'campus': campus, | ||
'room': room, | ||
'lecturer': lecturer, | ||
'start_time': startTime.toIso8601String(), | ||
'stop_time': stopTime.toIso8601String(), | ||
}; | ||
} | ||
|
||
// Static method to create a Course instance from a Map (JSON format) | ||
static Course fromJson(Map<String, dynamic> json) { | ||
return Course( | ||
unit: json['unit'], | ||
section: json['section'], | ||
dayOfWeek: json['day_of_the_week'], | ||
period: json['period'], | ||
campus: json['campus'], | ||
room: json['room'], | ||
lecturer: json['lecturer'], | ||
)..extractTimesFromPeriod(json['period']); | ||
} | ||
|
||
// Private method to extract start and stop times from the period string | ||
void extractTimesFromPeriod(String period) { | ||
// Split the period by the dash ('-') | ||
List<String> times = period.split('-'); | ||
|
||
// Define a DateFormat to parse the time strings | ||
DateFormat formatter = DateFormat("hh:mm a"); | ||
|
||
// Parse start and stop times | ||
startTime = formatter.parse(times[0].trim()); | ||
stopTime = formatter.parse(times[1].trim()); | ||
} | ||
import 'package:freezed_annotation/freezed_annotation.dart'; | ||
|
||
part 'course_model.freezed.dart'; | ||
part 'course_model.g.dart'; | ||
|
||
@freezed | ||
class Course with _$Course { | ||
const factory Course({ | ||
required String unit, | ||
required String section, | ||
@JsonKey(name: "day_of_the_week") required String dayOfWeek, | ||
required String period, | ||
required String campus, | ||
required String room, | ||
required String lecturer, | ||
@JsonKey(name: "start_time") DateTime? startTime, | ||
@JsonKey(name: "stop_time") DateTime? stopTime, | ||
}) = _Course; | ||
|
||
factory Course.fromJson(Map<String, dynamic> json) => _$CourseFromJson(json); | ||
} |
Oops, something went wrong.