implemented custom subject colors for the timetable and unified the color palette system

This commit is contained in:
2026-07-12 21:30:08 +02:00
parent a7111844b1
commit fe2b3c43b2
23 changed files with 916 additions and 89 deletions
@@ -1,43 +0,0 @@
import 'package:flutter/material.dart';
import '../../../../theming/dark_app_theme.dart';
enum CustomTimetableColors { orange, red, green, blue }
class TimetableColors {
static const CustomTimetableColors defaultColor =
CustomTimetableColors.orange;
static ColorModeDisplay getDisplayOptions(CustomTimetableColors color) {
switch (color) {
case CustomTimetableColors.green:
return ColorModeDisplay(color: Colors.green, displayName: 'Grün');
case CustomTimetableColors.blue:
return ColorModeDisplay(color: Colors.blue, displayName: 'Blau');
case CustomTimetableColors.orange:
return ColorModeDisplay(
color: Colors.orange.shade800,
displayName: 'Orange',
);
case CustomTimetableColors.red:
return ColorModeDisplay(
color: DarkAppTheme.marianumRed,
displayName: 'Rot',
);
}
}
static Color getColorFromString(String color) => getDisplayOptions(
CustomTimetableColors.values.firstWhere(
(e) => e.name == color,
orElse: () => defaultColor,
),
).color;
}
class ColorModeDisplay {
final Color color;
final String displayName;
ColorModeDisplay({required this.color, required this.displayName});
}
@@ -12,7 +12,8 @@ import '../../../../state/app/modules/timetable/bloc/timetable_bloc.dart';
import '../../../../widget/async_action_button.dart';
import '../../../../widget/demo_restricted.dart';
import '../../../../widget/focus_behaviour.dart';
import 'custom_event_colors.dart';
import '../data/subject_color_palette.dart';
import '../subject_colors/subject_color_picker.dart';
class CustomEventEditDialog extends StatefulWidget {
final CustomTimetableEvent? existingEvent;
@@ -61,10 +62,9 @@ class _CustomEventEditDialogState extends State<CustomEventEditDialog> {
// mhsl-Termine tragen ausgeschaltet (Modell-Default), da sie nie ein Serien-
// Ferien-Flag hatten.
late bool _skipHolidays = widget.existingEvent?.skipHolidays ?? true;
late CustomTimetableColors _color = CustomTimetableColors.values.firstWhere(
(e) => e.name == widget.existingEvent?.color,
orElse: () => TimetableColors.defaultColor,
);
late SubjectColor _color =
SubjectColorPalette.fromName(widget.existingEvent?.color) ??
SubjectColorPalette.defaultColor;
bool get _isEditing => widget.existingEvent != null;
@@ -261,30 +261,18 @@ class _CustomEventEditDialogState extends State<CustomEventEditDialog> {
ListTile(
leading: const Icon(Icons.color_lens_outlined),
title: const Text('Farbgebung'),
trailing: DropdownButton<CustomTimetableColors>(
value: _color,
icon: const Icon(Icons.arrow_drop_down),
items: CustomTimetableColors.values
.map(
(e) => DropdownMenuItem<CustomTimetableColors>(
value: e,
enabled: e != _color,
child: Row(
children: [
Icon(
Icons.circle,
color: TimetableColors.getDisplayOptions(e).color,
),
const SizedBox(width: 10),
Text(
TimetableColors.getDisplayOptions(e).displayName,
),
],
),
),
)
.toList(),
onChanged: (e) => setState(() => _color = e!),
subtitle: Text(SubjectColorPalette.displayOf(_color).displayName),
trailing: Icon(
Icons.circle,
color: SubjectColorPalette.displayOf(_color).color,
),
onTap: () => showTimetableColorPicker(
context,
title: 'Farbe wählen',
current: _color,
// Rein lokal (kein Netzwerk) — Sheet schließt sofort, gespeichert
// wird erst beim „Speichern" des Termins.
onSelected: (option) async => setState(() => _color = option),
),
),
const Divider(),