added opacity to past custom events

This commit is contained in:
2026-05-04 09:45:24 +02:00
parent 0b8380eff0
commit f89ac87c51
2 changed files with 8 additions and 11 deletions
@@ -30,7 +30,7 @@ class _AppointmentComponentState extends State<AppointmentComponent> {
decoration: BoxDecoration(
shape: BoxShape.rectangle,
borderRadius: const BorderRadius.all(Radius.circular(5)),
color: meeting.color,
color: meeting.color.withAlpha(meeting.endTime.isBefore(DateTime.now()) ? 100 : 255),
),
child: SingleChildScrollView(
child: Column(
+7 -10
View File
@@ -159,7 +159,7 @@ class _TimetableState extends State<Timetable> {
appointmentBuilder: (BuildContext context, CalendarAppointmentDetails details) => AppointmentComponent(
details: details,
crossedOut: _isCrossedOut(details)
),
),
headerHeight: 0,
selectionDecoration: const BoxDecoration(),
@@ -333,7 +333,7 @@ class _TimetableState extends State<Timetable> {
subject: 'Änderung',
notes: element.info,
location: 'Unbekannt',
color: const Color(0xff404040).withAlpha(endTime.isBefore(DateTime.now()) ? 100 : 255),
color: const Color(0xff404040),
startTimeZone: '',
endTimeZone: '',
);
@@ -361,26 +361,23 @@ class _TimetableState extends State<Timetable> {
}
Color _getEventColor(GetTimetableResponseObject webuntisElement, DateTime startTime, DateTime endTime) {
// Make element darker, when it already took place
var alpha = endTime.isBefore(DateTime.now()) ? 100 : 255;
// Cancelled
if(webuntisElement.code == 'cancelled') return const Color(0xff000000).withAlpha(alpha);
if(webuntisElement.code == 'cancelled') return const Color(0xff000000);
// Any changes or no teacher at this element
if(webuntisElement.code == 'irregular' || webuntisElement.te.first.id == 0) return const Color(0xff8F19B3).withAlpha(alpha);
if(webuntisElement.code == 'irregular' || webuntisElement.te.first.id == 0) return const Color(0xff8F19B3);
// Teacher has changed
if(webuntisElement.te.any((element) => element.orgname != null)) return const Color(0xFF29639B).withAlpha(alpha);
if(webuntisElement.te.any((element) => element.orgname != null)) return const Color(0xFF29639B);
// Event was in the past
if(endTime.isBefore(DateTime.now())) return Theme.of(context).primaryColor.withAlpha(alpha);
if(endTime.isBefore(DateTime.now())) return Theme.of(context).primaryColor;
// Event takes currently place
if(endTime.isAfter(DateTime.now()) && startTime.isBefore(DateTime.now())) return Theme.of(context).primaryColor.withRed(200);
// Fallback
return Theme.of(context).primaryColor.withAlpha(alpha);
return Theme.of(context).primaryColor;
}
bool _isCrossedOut(CalendarAppointmentDetails calendarEntry) {