Fixed timetable colors updating periodic
This commit is contained in:
parent
a237fba482
commit
7b18fed51d
@ -69,7 +69,7 @@ class AppointmentDetails {
|
|||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: const Icon(Icons.room),
|
leading: const Icon(Icons.room),
|
||||||
title: Text("Raum: ${room.name}"),
|
title: Text("Raum: ${room.name} (${room.longName})"),
|
||||||
trailing: IconButton(
|
trailing: IconButton(
|
||||||
icon: const Icon(Icons.house_outlined),
|
icon: const Icon(Icons.house_outlined),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@ -79,7 +79,7 @@ class AppointmentDetails {
|
|||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: const Icon(Icons.person),
|
leading: const Icon(Icons.person),
|
||||||
title: Text("Lehrkraft: (${timetableData.te[0].name}) ${timetableData.te[0].longname}"),
|
title: Text("Lehrkraft: ${timetableData.te[0].name} (${timetableData.te[0].longname})"),
|
||||||
trailing: Visibility(
|
trailing: Visibility(
|
||||||
visible: !kReleaseMode,
|
visible: !kReleaseMode,
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
|
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:syncfusion_flutter_calendar/calendar.dart';
|
import 'package:syncfusion_flutter_calendar/calendar.dart';
|
||||||
@ -25,6 +27,7 @@ class Timetable extends StatefulWidget {
|
|||||||
|
|
||||||
class _TimetableState extends State<Timetable> {
|
class _TimetableState extends State<Timetable> {
|
||||||
CalendarController controller = CalendarController();
|
CalendarController controller = CalendarController();
|
||||||
|
late Timer updateTimings;
|
||||||
|
|
||||||
double elementScale = 40;
|
double elementScale = 40;
|
||||||
double baseElementScale = 40;
|
double baseElementScale = 40;
|
||||||
@ -42,6 +45,8 @@ class _TimetableState extends State<Timetable> {
|
|||||||
|
|
||||||
controller.displayDate = DateTime.now().add(const Duration(days: 2));
|
controller.displayDate = DateTime.now().add(const Duration(days: 2));
|
||||||
|
|
||||||
|
updateTimings = Timer.periodic(const Duration(seconds: 30), (Timer t) => setState((){}));
|
||||||
|
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,6 +75,7 @@ class _TimetableState extends State<Timetable> {
|
|||||||
button: TextButton(
|
button: TextButton(
|
||||||
child: const Text("Neu laden"),
|
child: const Text("Neu laden"),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
controller.displayDate = DateTime.now().add(const Duration(days: 2));
|
||||||
Provider.of<TimetableProps>(context, listen: false).resetWeek();
|
Provider.of<TimetableProps>(context, listen: false).resetWeek();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -142,6 +148,12 @@ class _TimetableState extends State<Timetable> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
updateTimings.cancel();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
List<TimeRegion> _buildSpecialTimeRegions(GetHolidaysResponse holidays, ) {
|
List<TimeRegion> _buildSpecialTimeRegions(GetHolidaysResponse holidays, ) {
|
||||||
DateTime lastMonday = DateTime.now().subtract(Duration(days: DateTime.now().weekday - 1));
|
DateTime lastMonday = DateTime.now().subtract(Duration(days: DateTime.now().weekday - 1));
|
||||||
DateTime firstBreak = lastMonday.copyWith(hour: 10, minute: 15);
|
DateTime firstBreak = lastMonday.copyWith(hour: 10, minute: 15);
|
||||||
@ -201,7 +213,7 @@ class _TimetableState extends State<Timetable> {
|
|||||||
endTime: endTime,
|
endTime: endTime,
|
||||||
subject: subjects.result.firstWhere((subject) => subject.id == element.su[0].id).name,
|
subject: subjects.result.firstWhere((subject) => subject.id == element.su[0].id).name,
|
||||||
location: ""
|
location: ""
|
||||||
"${rooms.result.firstWhere((room) => room.id == element.ro[0].id).name}"
|
"${rooms.result.firstWhere((room) => room.id == element.ro[0].id).name})"
|
||||||
"\n"
|
"\n"
|
||||||
"${element.te.first.longname}",
|
"${element.te.first.longname}",
|
||||||
notes: element.activityType,
|
notes: element.activityType,
|
||||||
@ -245,10 +257,10 @@ class _TimetableState extends State<Timetable> {
|
|||||||
if(endTime.isBefore(DateTime.now())) return Theme.of(context).primaryColor.withAlpha(alpha);
|
if(endTime.isBefore(DateTime.now())) return Theme.of(context).primaryColor.withAlpha(alpha);
|
||||||
|
|
||||||
// Event takes currently place
|
// Event takes currently place
|
||||||
if(endTime.isAfter(DateTime.now()) && startTime.isBefore(DateTime.now())) return Theme.of(context).primaryColor.withRed(100);
|
if(endTime.isAfter(DateTime.now()) && startTime.isBefore(DateTime.now())) return Theme.of(context).primaryColor.withRed(200);
|
||||||
|
|
||||||
// Fallback
|
// Fallback
|
||||||
return Theme.of(context).primaryColor;
|
return Theme.of(context).primaryColor.withAlpha(alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _isCrossedOut(CalendarAppointmentDetails calendarEntry) {
|
bool _isCrossedOut(CalendarAppointmentDetails calendarEntry) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user