Fixed timetable colors updating periodic
This commit is contained in:
@ -1,4 +1,6 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:syncfusion_flutter_calendar/calendar.dart';
|
||||
@ -25,6 +27,7 @@ class Timetable extends StatefulWidget {
|
||||
|
||||
class _TimetableState extends State<Timetable> {
|
||||
CalendarController controller = CalendarController();
|
||||
late Timer updateTimings;
|
||||
|
||||
double elementScale = 40;
|
||||
double baseElementScale = 40;
|
||||
@ -42,6 +45,8 @@ class _TimetableState extends State<Timetable> {
|
||||
|
||||
controller.displayDate = DateTime.now().add(const Duration(days: 2));
|
||||
|
||||
updateTimings = Timer.periodic(const Duration(seconds: 30), (Timer t) => setState((){}));
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@ -70,6 +75,7 @@ class _TimetableState extends State<Timetable> {
|
||||
button: TextButton(
|
||||
child: const Text("Neu laden"),
|
||||
onPressed: () {
|
||||
controller.displayDate = DateTime.now().add(const Duration(days: 2));
|
||||
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, ) {
|
||||
DateTime lastMonday = DateTime.now().subtract(Duration(days: DateTime.now().weekday - 1));
|
||||
DateTime firstBreak = lastMonday.copyWith(hour: 10, minute: 15);
|
||||
@ -201,7 +213,7 @@ class _TimetableState extends State<Timetable> {
|
||||
endTime: endTime,
|
||||
subject: subjects.result.firstWhere((subject) => subject.id == element.su[0].id).name,
|
||||
location: ""
|
||||
"${rooms.result.firstWhere((room) => room.id == element.ro[0].id).name}"
|
||||
"${rooms.result.firstWhere((room) => room.id == element.ro[0].id).name})"
|
||||
"\n"
|
||||
"${element.te.first.longname}",
|
||||
notes: element.activityType,
|
||||
@ -245,10 +257,10 @@ class _TimetableState extends State<Timetable> {
|
||||
if(endTime.isBefore(DateTime.now())) return Theme.of(context).primaryColor.withAlpha(alpha);
|
||||
|
||||
// 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
|
||||
return Theme.of(context).primaryColor;
|
||||
return Theme.of(context).primaryColor.withAlpha(alpha);
|
||||
}
|
||||
|
||||
bool _isCrossedOut(CalendarAppointmentDetails calendarEntry) {
|
||||
|
Reference in New Issue
Block a user