fixed guardian login edge cases and misleading placeholders on failed loads

This commit is contained in:
2026-09-20 19:03:45 +02:00
parent 2423c1a75e
commit 630497abdd
23 changed files with 299 additions and 72 deletions
+15 -12
View File
@@ -12,7 +12,6 @@ import '../../../state/app/modules/timetable/bloc/timetable_state.dart';
import '../../../state/app/modules/timetable/policy/timetable_policy.dart';
import '../../../state/app/modules/timetable/subject/timetable_subject.dart';
import '../../../utils/haptics.dart';
import '../../../widget/app_progress_indicator.dart';
import '../../../widget/child_switcher.dart';
import '../../../widget/demo_restricted.dart';
import 'custom_events/custom_event_edit_dialog.dart';
@@ -29,6 +28,11 @@ class Timetable extends StatefulWidget {
}
class _TimetableState extends State<Timetable> {
/// One calendar key per subject: a new subject (child switch, foreign plan)
/// must not inherit the displayed week of the previous one, but coming back
/// to a subject should find its calendar where it was left.
final Map<TimetableSubject, GlobalKey<TimetableCalendarViewState>>
_calendarKeys = {};
GlobalKey<TimetableCalendarViewState> _calendarKey =
GlobalKey<TimetableCalendarViewState>();
TimetableSubject? _calendarSubject;
@@ -107,7 +111,10 @@ class _TimetableState extends State<Timetable> {
// previous calendar state.
if (subject != _calendarSubject) {
_calendarSubject = subject;
_calendarKey = GlobalKey<TimetableCalendarViewState>();
_calendarKey = _calendarKeys.putIfAbsent(
subject,
GlobalKey<TimetableCalendarViewState>.new,
);
}
final innerState = context.watch<B>().state.data;
final atToday = innerState != null && _isOnInitialWeek(innerState);
@@ -204,20 +211,16 @@ class _TimetableState extends State<Timetable> {
}
/// Shown instead of a plan when the session has none, i.e. a guardian whose
/// children are not known (yet).
/// children are not known (yet). [NoChildrenPlaceholder] tells a pending or
/// failed capability load apart from a confirmed empty list.
class _NoTimetableView extends StatelessWidget {
const _NoTimetableView();
@override
Widget build(BuildContext context) {
final capabilities = context.watch<CapabilitiesCubit>().state;
return Scaffold(
appBar: AppBar(title: const Text('Stunden & Vertretungsplan')),
body: capabilities.loaded
? const NoChildrenPlaceholder()
: const Center(child: AppProgressIndicator.large()),
);
}
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(title: const Text('Stunden & Vertretungsplan')),
body: const NoChildrenPlaceholder(),
);
}
/// Slim banner shown at the top of the timetable while a foreign element's plan