dart format

This commit is contained in:
2026-05-08 20:12:40 +02:00
parent 9e139b5704
commit 3b8da1d3d6
295 changed files with 6404 additions and 4161 deletions
@@ -7,12 +7,17 @@ import 'custom_event_sheet.dart';
import 'webuntis_lesson_sheet.dart';
class AppointmentDetailsDispatcher {
static void show(BuildContext context, TimetableBloc bloc, Appointment appointment) {
static void show(
BuildContext context,
TimetableBloc bloc,
Appointment appointment,
) {
final id = appointment.id;
if (id is! ArbitraryAppointment) return;
id.when(
webuntis: (lesson) => WebuntisLessonSheet.show(context, bloc, appointment, lesson),
webuntis: (lesson) =>
WebuntisLessonSheet.show(context, bloc, appointment, lesson),
custom: (event) => CustomEventSheet.show(context, event),
);
}
@@ -17,7 +17,10 @@ class CustomEventSheet {
context,
header: ListTile(
leading: const Icon(Icons.event_outlined, size: 32),
title: Text(event.title, style: const TextStyle(fontWeight: FontWeight.bold)),
title: Text(
event.title,
style: const TextStyle(fontWeight: FontWeight.bold),
),
subtitle: Text(timeRange),
),
children: (sheetCtx) => [
@@ -31,7 +34,8 @@ class CustomEventSheet {
Navigator.of(sheetCtx).pop();
showDialog(
context: context,
builder: (_) => CustomEventEditDialog(existingEvent: event),
builder: (_) =>
CustomEventEditDialog(existingEvent: event),
);
},
label: const Text('Bearbeiten'),
@@ -39,7 +43,9 @@ class CustomEventSheet {
),
TextButton.icon(
onPressed: () {
showDeleteCustomEventDialog(context, event).future.then((_) {
showDeleteCustomEventDialog(context, event).future.then((
_,
) {
if (!sheetCtx.mounted) return;
Navigator.of(sheetCtx).pop();
});
@@ -54,18 +60,28 @@ class CustomEventSheet {
const Divider(height: 1),
ListTile(
leading: const Icon(Icons.info_outline),
title: Text(event.description.isEmpty ? 'Keine Beschreibung' : event.description),
title: Text(
event.description.isEmpty
? 'Keine Beschreibung'
: event.description,
),
),
ListTile(
leading: const CenteredLeading(Icon(Icons.repeat_outlined)),
title: Text('Serie: ${event.rrule.isNotEmpty ? "Wiederholend" : "Einmalig"}'),
title: Text(
'Serie: ${event.rrule.isNotEmpty ? "Wiederholend" : "Einmalig"}',
),
subtitle: FutureBuilder(
future: RruleL10nEn.create(),
builder: (_, snapshot) {
if (event.rrule.isEmpty) return const Text('Keine weiteren Vorkommnisse');
if (event.rrule.isEmpty) {
return const Text('Keine weiteren Vorkommnisse');
}
if (snapshot.data == null) return const Text('...');
final rrule = RecurrenceRule.fromString(event.rrule);
if (!rrule.canFullyConvertToText) return const Text('Keine genauere Angabe möglich.');
if (!rrule.canFullyConvertToText) {
return const Text('Keine genauere Angabe möglich.');
}
return Text(rrule.toText(l10n: snapshot.data!));
},
),
@@ -7,12 +7,16 @@ import '../../../../api/mhsl/custom_timetable_event/custom_timetable_event.dart'
import '../../../../state/app/modules/timetable/bloc/timetable_bloc.dart';
import '../../../../widget/confirm_dialog.dart';
Completer<void> showDeleteCustomEventDialog(BuildContext context, CustomTimetableEvent event) {
Completer<void> showDeleteCustomEventDialog(
BuildContext context,
CustomTimetableEvent event,
) {
final completer = Completer<void>();
final bloc = context.read<TimetableBloc>();
ConfirmDialog(
title: 'Termin löschen',
content: 'Der ${event.rrule.isEmpty ? "Termin" : "Serientermin"} wird unwiederruflich gelöscht.',
content:
'Der ${event.rrule.isEmpty ? "Termin" : "Serientermin"} wird unwiederruflich gelöscht.',
confirmButton: 'Löschen',
onConfirmAsync: () async {
await bloc.removeCustomEvent(event.id);
@@ -14,13 +14,30 @@ import '../../../../widget/details_bottom_sheet.dart';
import '../../../../widget/unimplemented_dialog.dart';
class WebuntisLessonSheet {
static void show(BuildContext context, TimetableBloc bloc, Appointment appointment, GetTimetableResponseObject lesson) {
static void show(
BuildContext context,
TimetableBloc bloc,
Appointment appointment,
GetTimetableResponseObject lesson,
) {
final state = bloc.state.data;
if (state == null) return;
final headerSubject = LessonResolver.resolveSubject(state, lesson.su.firstOrNull?.id);
final headerTitle = firstNonEmpty([headerSubject.alternateName, headerSubject.name, headerSubject.longName, '?']);
final headerLongName = headerSubject.longName.isNotEmpty && headerSubject.longName != headerTitle ? headerSubject.longName : '';
final headerSubject = LessonResolver.resolveSubject(
state,
lesson.su.firstOrNull?.id,
);
final headerTitle = firstNonEmpty([
headerSubject.alternateName,
headerSubject.name,
headerSubject.longName,
'?',
]);
final headerLongName =
headerSubject.longName.isNotEmpty &&
headerSubject.longName != headerTitle
? headerSubject.longName
: '';
final timeRange = appointment.startTime.timeRangeTo(appointment.endTime);
@@ -32,9 +49,9 @@ class WebuntisLessonSheet {
'${LessonFormatter.codePrefix(lesson.code)}$headerTitle',
style: const TextStyle(fontWeight: FontWeight.bold),
),
subtitle: Text(headerLongName.isNotEmpty
? '$timeRange\n$headerLongName'
: timeRange),
subtitle: Text(
headerLongName.isNotEmpty ? '$timeRange\n$headerLongName' : timeRange,
),
isThreeLine: headerLongName.isNotEmpty,
),
children: (_) => <Widget>[
@@ -66,10 +83,12 @@ class WebuntisLessonSheet {
icon: Icons.people,
label: lesson.kl.length == 1 ? 'Klasse' : 'Klassen',
entries: lesson.kl
.map((k) => LessonFormatter.formatLine(
k.name.isNotEmpty ? k.name : '?',
longname: k.longname,
))
.map(
(k) => LessonFormatter.formatLine(
k.name.isNotEmpty ? k.name : '?',
longname: k.longname,
),
)
.toList(),
),
..._optionalTextTiles(lesson),
@@ -78,7 +97,11 @@ class WebuntisLessonSheet {
);
}
static Widget _roomTile(BuildContext context, TimetableState state, GetTimetableResponseObject lesson) {
static Widget _roomTile(
BuildContext context,
TimetableState state,
GetTimetableResponseObject lesson,
) {
final trailing = IconButton(
icon: const Icon(Icons.house_outlined),
onPressed: () => AppRoutes.openRoomplan(context),
@@ -112,7 +135,10 @@ class WebuntisLessonSheet {
);
}
static Widget _teacherTile(BuildContext context, GetTimetableResponseObject lesson) {
static Widget _teacherTile(
BuildContext context,
GetTimetableResponseObject lesson,
) {
final trailing = Visibility(
visible: !kReleaseMode,
child: IconButton(