Added different colors for future, current and past events
This commit is contained in:
parent
7a3744a70a
commit
29dd96940b
@ -107,7 +107,10 @@ class _WeekViewState extends State<WeekView> {
|
||||
startTime: parseTime(tableEvent.startTime),
|
||||
endTime: parseTime(tableEvent.endTime),
|
||||
padding: const EdgeInsets.all(5),
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
backgroundColor: getEventColor(
|
||||
currentDay.add(Duration(hours: parseTime(tableEvent.startTime).hour, minutes: parseTime(tableEvent.startTime).minute)),
|
||||
currentDay.add(Duration(hours: parseTime(tableEvent.endTime).hour, minutes: parseTime(tableEvent.endTime).minute)),
|
||||
),
|
||||
location: "\n${rooms.result.firstWhere((room) => room.id == tableEvent.ro[0]['id']).name} - ${tableEvent.te[0]['longname']} (${tableEvent.te[0]['name']})",
|
||||
);
|
||||
}
|
||||
@ -117,10 +120,10 @@ class _WeekViewState extends State<WeekView> {
|
||||
if(currentDay.isToday()) {
|
||||
events.add(TableEvent(
|
||||
title: "",
|
||||
eventId: 1,
|
||||
eventId: 0,
|
||||
laneIndex: day,
|
||||
startTime: formatTime(DateTime.now().add(Duration(hours: 8))),
|
||||
endTime: formatTime(DateTime.now().add(const Duration(minutes: 3, hours: 8))),
|
||||
startTime: formatTime(DateTime.now()),
|
||||
endTime: formatTime(DateTime.now().add(const Duration(minutes: 3))),
|
||||
backgroundColor: Theme.of(context).disabledColor,
|
||||
));
|
||||
}
|
||||
@ -157,6 +160,12 @@ class _WeekViewState extends State<WeekView> {
|
||||
TableEventTime formatTime(DateTime input) {
|
||||
return TableEventTime(hour: input.hour, minute: input.minute);
|
||||
}
|
||||
|
||||
Color getEventColor(DateTime startTime, DateTime endTime) {
|
||||
if(endTime.isBefore(DateTime.now())) return Colors.grey;
|
||||
if(startTime.isAfter(DateTime.now())) return Theme.of(context).primaryColor;
|
||||
return Colors.redAccent;
|
||||
}
|
||||
}
|
||||
|
||||
class CustomTableStyle extends TimetableStyle {
|
||||
|
Loading…
x
Reference in New Issue
Block a user