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,18 +1,22 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:rrule/rrule.dart';
import '../../../../api/mhsl/custom_timetable_event/custom_timetable_event.dart';
import '../../../../extensions/date_time.dart';
import '../../../../state/app/modules/timetable/bloc/timetable_bloc.dart';
import '../../../../widget/centered_leading.dart';
import '../../../../widget/debug/debug_tile.dart';
import '../../../../widget/details_bottom_sheet.dart';
import '../custom_events/custom_event_edit_dialog.dart';
import '../data/rrule_with_exceptions.dart';
import '../subject_colors/subject_color_picker.dart';
import 'delete_custom_event.dart';
class CustomEventSheet {
static void show(BuildContext context, CustomTimetableEvent event) {
final timeRange = event.startDate.timeRangeTo(event.endDate);
final bloc = context.read<TimetableBloc>();
showDetailsBottomSheet(
context,
@@ -23,6 +27,12 @@ class CustomEventSheet {
style: const TextStyle(fontWeight: FontWeight.bold),
),
subtitle: Text(timeRange),
trailing: TimetableColorHeaderButton(
initialColorName: event.color,
pickerTitle: 'Farbe wählen',
onSelected: (option) =>
bloc.updateCustomEvent(event.id, _withColor(event, option.name)),
),
),
children: (sheetCtx) => [
Padding(
@@ -104,4 +114,18 @@ class CustomEventSheet {
],
);
}
static CustomTimetableEvent _withColor(CustomTimetableEvent e, String color) =>
CustomTimetableEvent(
id: e.id,
title: e.title,
description: e.description,
startDate: e.startDate,
endDate: e.endDate,
color: color,
rrule: e.rrule,
skipHolidays: e.skipHolidays,
createdAt: e.createdAt,
updatedAt: DateTime.now(),
);
}