Files
Client/lib/view/pages/timetable/data/arbitrary_appointment.dart
T

25 lines
786 B
Dart

import '../../../../api/marianumconnect/queries/timetable_get_week/timetable_get_week_response.dart';
import '../../../../api/mhsl/custom_timetable_event/custom_timetable_event.dart';
sealed class ArbitraryAppointment {
const ArbitraryAppointment();
T when<T>({
required T Function(McTimetableEntry lesson) lesson,
required T Function(CustomTimetableEvent event) custom,
}) => switch (this) {
LessonAppointment(:final entry) => lesson(entry),
CustomAppointment(:final event) => custom(event),
};
}
class LessonAppointment extends ArbitraryAppointment {
final McTimetableEntry entry;
const LessonAppointment(this.entry);
}
class CustomAppointment extends ArbitraryAppointment {
final CustomTimetableEvent event;
const CustomAppointment(this.event);
}