Changed color indication of elements without teacher
This commit is contained in:
parent
2c22147468
commit
77707ce720
@ -129,10 +129,7 @@ class _TimetableState extends State<Timetable> {
|
|||||||
timeRegionBuilder: (BuildContext context, TimeRegionDetails timeRegionDetails) => TimeRegionComponent(details: timeRegionDetails),
|
timeRegionBuilder: (BuildContext context, TimeRegionDetails timeRegionDetails) => TimeRegionComponent(details: timeRegionDetails),
|
||||||
appointmentBuilder: (BuildContext context, CalendarAppointmentDetails details) => AppointmentComponent(
|
appointmentBuilder: (BuildContext context, CalendarAppointmentDetails details) => AppointmentComponent(
|
||||||
details: details,
|
details: details,
|
||||||
crossedOut: (
|
crossedOut: _isCrossedOut(details)
|
||||||
(details.appointments.first.id as GetTimetableResponseObject).code == "cancelled"
|
|
||||||
|| (details.appointments.first.id as GetTimetableResponseObject).te.first.id == 0
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
|
|
||||||
headerHeight: 0,
|
headerHeight: 0,
|
||||||
@ -211,7 +208,7 @@ class _TimetableState extends State<Timetable> {
|
|||||||
"\n"
|
"\n"
|
||||||
"${element.te.first.longname}",
|
"${element.te.first.longname}",
|
||||||
notes: element.activityType,
|
notes: element.activityType,
|
||||||
color: _getEventColor(element.code, startTime, endTime),
|
color: _getEventColor(element, startTime, endTime),
|
||||||
);
|
);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
return Appointment(
|
return Appointment(
|
||||||
@ -236,15 +233,29 @@ class _TimetableState extends State<Timetable> {
|
|||||||
return DateTime.parse('$date ${timeString.substring(0, 2)}:${timeString.substring(2, 4)}');
|
return DateTime.parse('$date ${timeString.substring(0, 2)}:${timeString.substring(2, 4)}');
|
||||||
}
|
}
|
||||||
|
|
||||||
Color _getEventColor(String? code, DateTime startTime, DateTime endTime) {
|
Color _getEventColor(GetTimetableResponseObject webuntisElement, DateTime startTime, DateTime endTime) {
|
||||||
|
// Make element darker, when it already took place
|
||||||
int opacity = endTime.isBefore(DateTime.now()) ? 100 : 255;
|
int opacity = endTime.isBefore(DateTime.now()) ? 100 : 255;
|
||||||
|
|
||||||
if(code == "cancelled") return const Color(0xff000000).withAlpha(opacity);
|
// Cancelled
|
||||||
if(code == "irregular") return const Color(0xff8F19B3).withAlpha(opacity);
|
if(webuntisElement.code == "cancelled") return const Color(0xff000000).withAlpha(opacity);
|
||||||
|
|
||||||
|
// Any changes or no teacher at this element
|
||||||
|
if(webuntisElement.code == "irregular" || webuntisElement.te.first.id == 0) return const Color(0xff8F19B3).withAlpha(opacity);
|
||||||
|
|
||||||
|
// 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(opacity);
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
// Fallback
|
||||||
return Theme.of(context).primaryColor;
|
return Theme.of(context).primaryColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool _isCrossedOut(CalendarAppointmentDetails calendarEntry) {
|
||||||
|
GetTimetableResponseObject webuntisElement = (calendarEntry.appointments.first.id as GetTimetableResponseObject);
|
||||||
|
|
||||||
|
return webuntisElement.code == "cancelled";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
# In Windows, build-name is used as the major, minor, and patch parts
|
# In Windows, build-name is used as the major, minor, and patch parts
|
||||||
# of the product and file versions while build-number is used as the build suffix.
|
# of the product and file versions while build-number is used as the build suffix.
|
||||||
version: 0.0.1+8
|
version: 0.0.1+9
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>3.0.0'
|
sdk: '>3.0.0'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user