#26 Listview of custom timetable events

This commit is contained in:
2024-03-10 14:48:09 +01:00
parent faf37ff19f
commit 9f467d079f
5 changed files with 166 additions and 26 deletions

View File

@ -1,4 +1,6 @@
import 'dart:async';
import 'package:bottom_sheet/bottom_sheet.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
@ -135,6 +137,26 @@ class AppointmentDetails {
);
}
static Completer deleteCustomEvent(BuildContext context, CustomTimetableEvent appointment) {
Completer future = Completer();
ConfirmDialog(
title: "Termin löschen",
content: "Der ${appointment.rrule.isEmpty ? "Termin" : "Serientermin"} wird unwiederruflich gelöscht.",
confirmButton: "Löschen",
onConfirm: () {
RemoveCustomTimetableEvent(
RemoveCustomTimetableEventParams(
appointment.id
)
).run().then((value) {
Provider.of<TimetableProps>(context, listen: false).run(renew: true);
future.complete();
});
},
).asDialog(context);
return future;
}
static void _custom(BuildContext context, TimetableProps webuntisData, CustomTimetableEvent appointment) {
_bottomSheet(
context,
@ -169,21 +191,7 @@ class AppointmentDetails {
),
TextButton.icon(
onPressed: () {
ConfirmDialog(
title: "Termin löschen",
content: "Der ${appointment.rrule.isEmpty ? "Termin" : "Serientermin"} wird unwiederruflich gelöscht.",
confirmButton: "Löschen",
onConfirm: () {
RemoveCustomTimetableEvent(
RemoveCustomTimetableEventParams(
appointment.id
)
).run().then((value) {
Navigator.of(context).pop();
Provider.of<TimetableProps>(context, listen: false).run(renew: true);
});
},
).asDialog(context);
deleteCustomEvent(context, appointment).future.then((value) => Navigator.of(context).pop());
},
label: const Text("Löschen"),
icon: const Icon(Icons.delete_outline),
@ -214,7 +222,7 @@ class AppointmentDetails {
ListTile(
leading: const CenteredLeading(Icon(Icons.rule)),
title: const Text("RRule"),
subtitle: Text(appointment.rrule),
subtitle: Text(appointment.rrule.isEmpty ? "Keine" : appointment.rrule),
)
),
DebugTile(context).jsonData(appointment.toJson()),