migrated timetable integration from WebUntis to the MarianumConnect API, implementing a Dio-based client with bearer token authentication, background session validation, and auto-refresh logic.

This commit is contained in:
2026-05-23 17:32:42 +02:00
parent 2858f910c9
commit 93b9929f8f
106 changed files with 2739 additions and 2624 deletions
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import '../../../../api/webuntis/queries/get_timegrid_units/get_timegrid_units_response.dart';
import '../../../../api/marianumconnect/queries/timetable_get_timegrid/timetable_get_timegrid_response.dart';
import '../../../../state/app/modules/timetable/bloc/timetable_state.dart';
class LessonPeriod {
@@ -28,22 +28,30 @@ class LessonPeriodSchedule {
const LessonPeriodSchedule(this.periods);
static LessonPeriodSchedule? fromApi(GetTimegridUnitsResponse response) {
final canonical = response.result.firstWhere(
(d) => d.day == 1,
orElse: () => response.result.isNotEmpty
? response.result.first
: GetTimegridUnitsResponseDay(0, []),
);
if (canonical.timeUnits.isEmpty) return null;
static LessonPeriodSchedule? fromApi(TimetableGetTimegridResponse response) {
// The Marianum-Connect endpoint returns one entry per (weekday, unit). The
// school's bell schedule is identical MonFri, so we pick Monday as the
// canonical day and fall back to the first available weekday if Monday is
// missing.
final monday = response.result
.where((u) => u.dayOfWeek == McDayOfWeek.monday)
.toList();
final source = monday.isNotEmpty ? monday : response.result;
if (source.isEmpty) return null;
final periods =
canonical.timeUnits
source
.map(
(u) => LessonPeriod(
name: u.name,
start: _fromHHMM(u.startTime),
end: _fromHHMM(u.endTime),
name: u.label,
start: TimeOfDay(
hour: u.startTime.hour,
minute: u.startTime.minute,
),
end: TimeOfDay(
hour: u.endTime.hour,
minute: u.endTime.minute,
),
),
)
.toList()
@@ -144,7 +152,4 @@ class LessonPeriodSchedule {
}
return LessonPeriodSchedule(result);
}
static TimeOfDay _fromHHMM(int hhmm) =>
TimeOfDay(hour: hhmm ~/ 100, minute: hhmm % 100);
}