Updated Timetable colors, added Prefix for irregular or cancelled hours

This commit is contained in:
Elias Müller 2023-02-22 12:39:17 +01:00
parent 2ba2fb9090
commit bc24ca24cb

View File

@ -1,9 +1,6 @@
import 'dart:developer' as dev;
import 'dart:math';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:jiffy/jiffy.dart';
import 'package:marianum_mobile/api/webuntis/queries/getHolidays/getHolidaysResponse.dart';
import 'package:timetable_view/timetable_view.dart';
@ -58,8 +55,8 @@ class _WeekViewState extends State<WeekView> {
child: Center(
child: Column(
children: [
Icon(Icons.info),
SizedBox(height: 10),
const Icon(Icons.info),
const SizedBox(height: 10),
Text("${subject.alternateName} - (${subject.longName})", style: const TextStyle(fontSize: 30)),
Text("${Jiffy(event.startTime).format("HH:mm")} - ${Jiffy(event.endTime).format("HH:mm")}", style: const TextStyle(fontSize: 15)),
],
@ -139,7 +136,7 @@ class _WeekViewState extends State<WeekView> {
startTime: parseTime(0800),
endTime: parseTime(1500),
padding: const EdgeInsets.all(5),
backgroundColor: Colors.indigoAccent,
backgroundColor: const Color(0xff3D62B3),
location: "\n${holidayInfo.longName}",
)
]),
@ -159,7 +156,7 @@ class _WeekViewState extends State<WeekView> {
GetSubjectsResponseObject subject = subjects.result.firstWhere((subject) => subject.id == tableEvent.su[0]['id']);
return TableEvent(
title: "${subject.alternateName} (${subject.longName})",
title: "${getEventPrefix(tableEvent.code)}${subject.alternateName} (${subject.longName})",
eventId: tableEvent.id,
laneIndex: day,
startTime: parseTime(tableEvent.startTime),
@ -220,12 +217,18 @@ class _WeekViewState extends State<WeekView> {
return TableEventTime(hour: input.hour, minute: input.minute);
}
String getEventPrefix(String? code) {
if(code == "cancelled") return "Entfällt: ";
if(code == "irregular") return "Änderung: ";
return code ?? "";
}
Color getEventColor(String? code, DateTime startTime, DateTime endTime) {
if(code == "cancelled") return Colors.deepPurple;
if(code == "irregular") return Colors.blueAccent;
if(code == "cancelled") return const Color(0xff8F19B3);
if(code == "irregular") return const Color(0xff992B99);
if(endTime.isBefore(DateTime.now())) return Colors.grey;
if(startTime.isAfter(DateTime.now())) return Theme.of(context).primaryColor;
return Colors.redAccent;
return const Color(0xff99563A);
}
}
@ -242,7 +245,7 @@ class CustomTableStyle extends TimetableStyle {
@override
Color get timeItemTextColor => Theme.of(context).primaryColor;
@override
double get timeItemHeight => MediaQuery.of(context).size.width > 1000 ? 60 : 100 + (-MediaQuery.of(context).size.width + 1000) * 0.01;
double get timeItemHeight => MediaQuery.of(context).size.width > 1000 ? 60 : 90;
@override
double get timeItemWidth => 50;
@override