import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:jiffy/jiffy.dart'; import 'package:marianum_mobile/api/webuntis/queries/getTimetable/getTimetableResponse.dart'; import 'package:marianum_mobile/data/timetable/timetableProps.dart'; import 'package:persistent_bottom_nav_bar/persistent_tab_view.dart'; import 'package:syncfusion_flutter_calendar/calendar.dart'; import '../../../api/webuntis/queries/getRooms/getRoomsResponse.dart'; import '../../../api/webuntis/queries/getSubjects/getSubjectsResponse.dart'; import '../../settings/debug/jsonViewer.dart'; import '../more/roomplan/roomplan.dart'; class AppointmentDetails { static String _getEventPrefix(String? code) { if(code == "cancelled") return "Entfällt: "; if(code == "irregular") return "Änderung: "; return code ?? ""; } static void show(BuildContext context, TimetableProps webuntisData, Appointment appointment) { GetTimetableResponseObject timetableData = appointment.id as GetTimetableResponseObject; //GetTimetableResponseObject timetableData = webuntisData.getTimetableResponse.result.firstWhere((element) => element.id == timetableObject.id); GetSubjectsResponseObject subject = webuntisData.getSubjectsResponse.result.firstWhere((subject) => subject.id == timetableData.su[0]['id']); GetRoomsResponseObject room = webuntisData.getRoomsResponse.result.firstWhere((room) => room.id == timetableData.ro[0]['id']); showModalBottomSheet(context: context, builder: (context) => Column( children: [ Padding( padding: const EdgeInsets.symmetric(vertical: 30), child: Center( child: Column( children: [ Icon(Icons.info, color: appointment.color), const SizedBox(height: 10), Text("${_getEventPrefix(timetableData.code)}${subject.alternateName} - (${subject.longName})", style: const TextStyle(fontSize: 30)), Text("${Jiffy(appointment.startTime).format("HH:mm")} - ${Jiffy(appointment.endTime).format("HH:mm")}", style: const TextStyle(fontSize: 15)), ], ), ), ), Expanded( child: ListView( children: [ ListTile( leading: const Icon(Icons.notifications_active), title: Text("Status: ${timetableData.code != null ? "Geändert" : "Regulär"}"), ), ListTile( leading: const Icon(Icons.room), title: Text("Raum: ${room.name}"), trailing: IconButton( icon: const Icon(Icons.house_outlined), onPressed: () { PersistentNavBarNavigator.pushNewScreen(context, withNavBar: false, screen: const Roomplan()); }, ), ), ListTile( leading: const Icon(Icons.person), title: Text("Lehrkraft: (${timetableData.te[0]['name']}) ${timetableData.te[0]['longname']}"), trailing: IconButton( icon: const Icon(Icons.textsms_outlined), onPressed: () { showDialog(context: context, builder: (context) => const AlertDialog(content: Text("Not implemented yet"))); }, ), ), ListTile( leading: const Icon(Icons.abc), title: Text("Typ: ${timetableData.activityType}"), ), ListTile( leading: const Icon(Icons.people), title: Text("Klasse(n): ${timetableData.kl.map((e) => e['name']).join(", ")}"), ), ListTile( leading: const Icon(Icons.bug_report_outlined), title: const Text("Webuntis Rohdaten zeigen"), onTap: () => JsonViewer.asDialog(context, timetableData.toJson()), ) ], ), ) ], )); } }