added base homescreen-widget setup, working on Android, iOS in progress

This commit is contained in:
2026-05-09 18:01:05 +02:00
parent 0ff5eb7bc9
commit 00664c66a8
66 changed files with 5600 additions and 4 deletions
+76
View File
@@ -0,0 +1,76 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'widget_data.freezed.dart';
part 'widget_data.g.dart';
/// Status mirror of [LessonStatus] in
/// `lib/view/pages/timetable/data/lesson_status.dart`. Native widget code
/// switches on the string form, so the JSON name MUST stay stable.
enum WidgetLessonStatus {
regular,
ongoing,
past,
cancelled,
irregular,
teacherChanged,
event,
}
@freezed
abstract class WidgetLesson with _$WidgetLesson {
const factory WidgetLesson({
required DateTime start,
required DateTime end,
required String subjectShort,
String? subjectLong,
String? room,
String? teacher,
String? originalTeacher,
required WidgetLessonStatus status,
String? customColor,
@Default(0) int siblingCount,
}) = _WidgetLesson;
factory WidgetLesson.fromJson(Map<String, Object?> json) =>
_$WidgetLessonFromJson(json);
}
@freezed
abstract class WidgetPeriod with _$WidgetPeriod {
const factory WidgetPeriod({
/// Webuntis period name — typically the lesson number as string ("1",
/// "2", "3", …). Native renderers append a trailing "." for display.
required String name,
/// Minutes since midnight, e.g. 480 for 08:00. Cheap to read in
/// Kotlin/Swift without re-parsing time strings.
required int startMinutes,
required int endMinutes,
/// Position on the **virtual** time axis used by the widget. Small
/// between-lesson gaps are squeezed out so periods stack flush; only
/// big breaks (> 5 min) remain as visible gaps. Computed by the
/// mapper so native renderers don't have to redo the maths.
required int virtualStartMinutes,
required int virtualEndMinutes,
}) = _WidgetPeriod;
factory WidgetPeriod.fromJson(Map<String, Object?> json) =>
_$WidgetPeriodFromJson(json);
}
@freezed
abstract class WidgetTimetableData with _$WidgetTimetableData {
const factory WidgetTimetableData({
required DateTime fetchedAt,
/// The day this widget snapshot is "about" — display anchor.
/// For the day variant: the rendered school day.
/// For the week variant: the Monday of the rendered school week.
required DateTime anchorDate,
required List<WidgetLesson> lessons,
@Default(<WidgetPeriod>[]) List<WidgetPeriod> periods,
@Default(false) bool isHoliday,
String? holidayName,
}) = _WidgetTimetableData;
factory WidgetTimetableData.fromJson(Map<String, Object?> json) =>
_$WidgetTimetableDataFromJson(json);
}