option to change custom timetable event colors

This commit is contained in:
2024-03-17 17:01:18 +01:00
parent 9cb3a93a51
commit a2f1ccae7b
5 changed files with 78 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:jiffy/jiffy.dart';
import 'package:marianum_mobile/extensions/dateTime.dart';
import 'package:marianum_mobile/view/pages/timetable/custonTimetableColors.dart';
import 'package:provider/provider.dart';
import 'package:rrule_generator/rrule_generator.dart';
import 'package:time_range_picker/time_range_picker.dart';
@ -32,6 +33,10 @@ class _AddCustomTimetableEventDialogState extends State<CustomTimetableEventEdit
late final TextEditingController _eventName = TextEditingController(text: widget.existingEvent?.title);
late final TextEditingController _eventDescription = TextEditingController(text: widget.existingEvent?.description);
late String _recurringRule = widget.existingEvent?.rrule ?? "";
late CustomTimetableColors _customTimetableColor = CustomTimetableColors.values.firstWhere(
(element) => element.name == widget.existingEvent?.color,
orElse: () => CustomTimetableColors.orange
);
late bool isEditingExisting = widget.existingEvent != null;
@ -77,6 +82,7 @@ class _AddCustomTimetableEventDialogState extends State<CustomTimetableEventEdit
),
const Divider(),
ListTile(
leading: const Icon(Icons.date_range_outlined),
title: Text(Jiffy.parseFromDateTime(_date).yMMMd),
subtitle: const Text("Datum"),
onTap: () async {
@ -94,6 +100,7 @@ class _AddCustomTimetableEventDialogState extends State<CustomTimetableEventEdit
},
),
ListTile(
leading: const Icon(Icons.access_time_outlined),
title: Text("${_startTime.format(context).toString()} - ${_endTime.format(context).toString()}"),
subtitle: const Text("Zeitraum"),
onTap: () async {
@ -120,6 +127,31 @@ class _AddCustomTimetableEventDialogState extends State<CustomTimetableEventEdit
},
),
const Divider(),
ListTile(
leading: const Icon(Icons.color_lens_outlined),
title: const Text("Farbgebung"),
trailing: DropdownButton<CustomTimetableColors>(
value: _customTimetableColor,
icon: const Icon(Icons.arrow_drop_down),
items: CustomTimetableColors.values.map((e) => DropdownMenuItem<CustomTimetableColors>(
value: e,
enabled: e != _customTimetableColor,
child: Row(
children: [
Icon(Icons.circle, color: TimetableColors.getDisplayOptions(e).color),
const SizedBox(width: 10),
Text(TimetableColors.getDisplayOptions(e).displayName),
],
),
)).toList(),
onChanged: (e) {
setState(() {
_customTimetableColor = e!;
});
},
),
),
const Divider(),
RRuleGenerator(
config: RRuleGeneratorConfig(
headerEnabled: true,
@ -156,6 +188,7 @@ class _AddCustomTimetableEventDialogState extends State<CustomTimetableEventEdit
description: _eventDescription.text,
startDate: _date.withTime(_startTime),
endDate: _date.withTime(_endTime),
color: _customTimetableColor.name,
rrule: _recurringRule,
createdAt: DateTime.now(),
updatedAt: DateTime.now(),