Fixedd background color of unknown timetable element in the past
This commit is contained in:
parent
d63958574b
commit
5f0426aab9
@ -208,14 +208,15 @@ class _TimetableState extends State<Timetable> {
|
|||||||
color: _getEventColor(element, startTime, endTime),
|
color: _getEventColor(element, startTime, endTime),
|
||||||
);
|
);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
DateTime endTime = _parseWebuntisTimestamp(element.date, element.endTime);
|
||||||
return Appointment(
|
return Appointment(
|
||||||
id: element,
|
id: element,
|
||||||
startTime: _parseWebuntisTimestamp(element.date, element.startTime),
|
startTime: _parseWebuntisTimestamp(element.date, element.startTime),
|
||||||
endTime: _parseWebuntisTimestamp(element.date, element.endTime),
|
endTime: endTime,
|
||||||
subject: "Änderung",
|
subject: "Änderung",
|
||||||
notes: element.info,
|
notes: element.info,
|
||||||
location: 'Unbekannt',
|
location: 'Unbekannt',
|
||||||
color: Theme.of(context).primaryColor,
|
color: endTime.isBefore(DateTime.now()) ? Theme.of(context).primaryColor.withAlpha(100) : Theme.of(context).primaryColor,
|
||||||
startTimeZone: '',
|
startTimeZone: '',
|
||||||
endTimeZone: '',
|
endTimeZone: '',
|
||||||
);
|
);
|
||||||
@ -232,16 +233,16 @@ class _TimetableState extends State<Timetable> {
|
|||||||
|
|
||||||
Color _getEventColor(GetTimetableResponseObject webuntisElement, DateTime startTime, DateTime endTime) {
|
Color _getEventColor(GetTimetableResponseObject webuntisElement, DateTime startTime, DateTime endTime) {
|
||||||
// Make element darker, when it already took place
|
// Make element darker, when it already took place
|
||||||
int opacity = endTime.isBefore(DateTime.now()) ? 100 : 255;
|
int alpha = endTime.isBefore(DateTime.now()) ? 100 : 255;
|
||||||
|
|
||||||
// Cancelled
|
// Cancelled
|
||||||
if(webuntisElement.code == "cancelled") return const Color(0xff000000).withAlpha(opacity);
|
if(webuntisElement.code == "cancelled") return const Color(0xff000000).withAlpha(alpha);
|
||||||
|
|
||||||
// Any changes or no teacher at this element
|
// Any changes or no teacher at this element
|
||||||
if(webuntisElement.code == "irregular" || webuntisElement.te.first.id == 0) return const Color(0xff8F19B3).withAlpha(opacity);
|
if(webuntisElement.code == "irregular" || webuntisElement.te.first.id == 0) return const Color(0xff8F19B3).withAlpha(alpha);
|
||||||
|
|
||||||
// Event was in the past
|
// Event was in the past
|
||||||
if(endTime.isBefore(DateTime.now())) return Theme.of(context).primaryColor.withAlpha(opacity);
|
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(100);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user