refactored HTTP error handling and streamlined UI components by centralizing shared logic and removing redundant parameters

This commit is contained in:
2026-07-13 22:58:02 +02:00
parent d7536ea5d0
commit 8274dd46cd
28 changed files with 284 additions and 447 deletions
@@ -78,39 +78,12 @@ class _OutsideDayColumn extends StatelessWidget {
});
void _showOverflow(BuildContext context, List<Appointment> hidden) {
showDetailsBottomSheet(
_showAppointmentOverflowSheet(
context,
children: (sheetCtx) {
final tiles = <Widget>[];
for (var i = 0; i < hidden.length; i++) {
if (i > 0) tiles.add(const Divider(height: 1));
final apt = hidden[i];
tiles.add(
ListTile(
leading: Container(
width: 12,
height: 12,
decoration: BoxDecoration(
color: apt.color,
borderRadius: BorderRadius.circular(3),
),
),
title: Text(
apt.subject,
style: isCrossedOut(apt)
? const TextStyle(decoration: TextDecoration.lineThrough)
: null,
),
subtitle: Text(_subtitleFor(apt)),
onTap: () {
Navigator.of(sheetCtx).pop();
onAppointmentTap(apt);
},
),
);
}
return tiles;
},
hidden,
onAppointmentTap: onAppointmentTap,
isCrossedOut: isCrossedOut,
subtitle: _subtitleFor,
);
}
@@ -252,39 +252,12 @@ class _DayColumn extends StatelessWidget {
) {
final sorted = [...appointments]
..sort((a, b) => a.startTime.compareTo(b.startTime));
showDetailsBottomSheet(
_showAppointmentOverflowSheet(
context,
children: (sheetContext) {
final tiles = <Widget>[];
for (var i = 0; i < sorted.length; i++) {
if (i > 0) tiles.add(const Divider(height: 1));
final apt = sorted[i];
tiles.add(
ListTile(
leading: Container(
width: 12,
height: 12,
decoration: BoxDecoration(
color: apt.color,
borderRadius: BorderRadius.circular(3),
),
),
title: Text(
apt.subject,
style: isCrossedOut(apt)
? const TextStyle(decoration: TextDecoration.lineThrough)
: null,
),
subtitle: Text(_overflowSubtitle(apt)),
onTap: () {
Navigator.of(sheetContext).pop();
onAppointmentTap(apt);
},
),
);
}
return tiles;
},
sorted,
onAppointmentTap: onAppointmentTap,
isCrossedOut: isCrossedOut,
subtitle: _overflowSubtitle,
);
}
@@ -388,6 +361,52 @@ class _DayColumn extends StatelessWidget {
}
}
/// Shared bottom sheet listing hidden appointments (used by both the in-grid
/// and outside-hours overflow cells). [appointments] is rendered in the given
/// order — callers pre-sort as needed.
void _showAppointmentOverflowSheet(
BuildContext context,
List<Appointment> appointments, {
required void Function(Appointment) onAppointmentTap,
required bool Function(Appointment) isCrossedOut,
required String Function(Appointment) subtitle,
}) {
showDetailsBottomSheet(
context,
children: (sheetContext) {
final tiles = <Widget>[];
for (var i = 0; i < appointments.length; i++) {
if (i > 0) tiles.add(const Divider(height: 1));
final apt = appointments[i];
tiles.add(
ListTile(
leading: Container(
width: 12,
height: 12,
decoration: BoxDecoration(
color: apt.color,
borderRadius: BorderRadius.circular(3),
),
),
title: Text(
apt.subject,
style: isCrossedOut(apt)
? const TextStyle(decoration: TextDecoration.lineThrough)
: null,
),
subtitle: Text(subtitle(apt)),
onTap: () {
Navigator.of(sheetContext).pop();
onAppointmentTap(apt);
},
),
);
}
return tiles;
},
);
}
class _CurrentTimeMarker extends StatelessWidget {
final DateTime now;
final PeriodLayout layout;
@@ -57,9 +57,6 @@ class TimetableCalendarViewState extends State<TimetableCalendarView> {
_calendarKey.currentState?.jumpToDate(_initialDisplayDate());
}
bool isOnInitialWeek() =>
widget.state.startDate == _mondayOf(_initialDisplayDate());
List<Appointment> _appointments(TimetableState state) {
final timetableSettings = context
.watch<SettingsCubit>()