|
|
|
@ -1,4 +1,9 @@
|
|
|
|
|
|
|
|
|
|
import 'dart:developer';
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:jiffy/jiffy.dart';
|
|
|
|
|
import 'package:rrule_generator/rrule_generator.dart';
|
|
|
|
|
|
|
|
|
|
class AddCustomTimetableEventDialog extends StatefulWidget {
|
|
|
|
|
const AddCustomTimetableEventDialog({super.key});
|
|
|
|
@ -8,98 +13,108 @@ class AddCustomTimetableEventDialog extends StatefulWidget {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _AddCustomTimetableEventDialogState extends State<AddCustomTimetableEventDialog> {
|
|
|
|
|
DateTime _selectedDate = DateTime.now();
|
|
|
|
|
TimeOfDay _selectedStartTime = TimeOfDay.now();
|
|
|
|
|
TimeOfDay _selectedEndTime = TimeOfDay.now();
|
|
|
|
|
final TextEditingController _eventNameController = TextEditingController();
|
|
|
|
|
bool _isRecurring = false;
|
|
|
|
|
String _recurringFrequency = 'Wöchentlich';
|
|
|
|
|
DateTime _date = DateTime.now();
|
|
|
|
|
TimeOfDay _starTime = TimeOfDay.now().replacing(minute: 00);
|
|
|
|
|
TimeOfDay _endTime = TimeOfDay.now().replacing(minute: 30);
|
|
|
|
|
final TextEditingController _eventName = TextEditingController();
|
|
|
|
|
final TextEditingController _eventDescription = TextEditingController();
|
|
|
|
|
String _recurringRule = "";
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return AlertDialog(
|
|
|
|
|
insetPadding: const EdgeInsets.all(20),
|
|
|
|
|
contentPadding: const EdgeInsets.all(10),
|
|
|
|
|
title: const Text('Termin hinzufügen'),
|
|
|
|
|
content: SingleChildScrollView(
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
ListTile(
|
|
|
|
|
title: const Text('Startdatum:'),
|
|
|
|
|
subtitle: Text('${_selectedDate.day}/${_selectedDate.month}/${_selectedDate.year}'),
|
|
|
|
|
title: TextField(
|
|
|
|
|
controller: _eventName,
|
|
|
|
|
autofocus: true,
|
|
|
|
|
decoration: const InputDecoration(
|
|
|
|
|
labelText: "Terminname",
|
|
|
|
|
border: OutlineInputBorder()
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
ListTile(
|
|
|
|
|
title: TextField(
|
|
|
|
|
controller: _eventDescription,
|
|
|
|
|
maxLines: 2,
|
|
|
|
|
minLines: 2,
|
|
|
|
|
decoration: const InputDecoration(
|
|
|
|
|
labelText: "Beschreibung",
|
|
|
|
|
border: OutlineInputBorder()
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const Divider(),
|
|
|
|
|
ListTile(
|
|
|
|
|
title: Text(Jiffy.parseFromDateTime(_date).yMMMd),
|
|
|
|
|
subtitle: const Text("Datum"),
|
|
|
|
|
onTap: () async {
|
|
|
|
|
final DateTime? pickedDate = await showDatePicker(
|
|
|
|
|
context: context,
|
|
|
|
|
initialDate: _selectedDate,
|
|
|
|
|
initialDate: _date,
|
|
|
|
|
firstDate: DateTime.now(),
|
|
|
|
|
lastDate: DateTime(2101),
|
|
|
|
|
);
|
|
|
|
|
if (pickedDate != null && pickedDate != _selectedDate) {
|
|
|
|
|
if (pickedDate != null && pickedDate != _date) {
|
|
|
|
|
setState(() {
|
|
|
|
|
_selectedDate = pickedDate;
|
|
|
|
|
_date = pickedDate;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
ListTile(
|
|
|
|
|
title: const Text('Startzeit:'),
|
|
|
|
|
subtitle: Text('${_selectedStartTime.hour}:${_selectedStartTime.minute}'),
|
|
|
|
|
title: Text(_starTime.format(context).toString()),
|
|
|
|
|
subtitle: const Text("Beginnend"),
|
|
|
|
|
onTap: () async {
|
|
|
|
|
final TimeOfDay? pickedTime = await showTimePicker(
|
|
|
|
|
context: context,
|
|
|
|
|
initialTime: _selectedStartTime,
|
|
|
|
|
initialTime: _starTime,
|
|
|
|
|
);
|
|
|
|
|
if (pickedTime != null && pickedTime != _selectedStartTime) {
|
|
|
|
|
if(pickedTime == null) return;
|
|
|
|
|
setState(() {
|
|
|
|
|
_selectedStartTime = pickedTime;
|
|
|
|
|
_starTime = pickedTime;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
ListTile(
|
|
|
|
|
title: const Text('Endzeit:'),
|
|
|
|
|
subtitle: Text('${_selectedEndTime.hour}:${_selectedEndTime.minute}'),
|
|
|
|
|
title: Text(_endTime.format(context).toString()),
|
|
|
|
|
subtitle: const Text("Endend"),
|
|
|
|
|
onTap: () async {
|
|
|
|
|
final TimeOfDay? pickedTime = await showTimePicker(
|
|
|
|
|
context: context,
|
|
|
|
|
initialTime: _selectedEndTime,
|
|
|
|
|
initialTime: _endTime,
|
|
|
|
|
);
|
|
|
|
|
if (pickedTime != null && pickedTime != _selectedEndTime) {
|
|
|
|
|
if (pickedTime != null && pickedTime != _endTime) {
|
|
|
|
|
setState(() {
|
|
|
|
|
_selectedEndTime = pickedTime;
|
|
|
|
|
_endTime = pickedTime;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
TextField(
|
|
|
|
|
controller: _eventNameController,
|
|
|
|
|
decoration: const InputDecoration(labelText: 'Terminname'),
|
|
|
|
|
const Divider(),
|
|
|
|
|
RRuleGenerator(
|
|
|
|
|
config: RRuleGeneratorConfig(
|
|
|
|
|
headerEnabled: true,
|
|
|
|
|
weekdayBackgroundColor: Theme.of(context).colorScheme.secondary,
|
|
|
|
|
weekdaySelectedBackgroundColor: Theme.of(context).primaryColor,
|
|
|
|
|
weekdayColor: Colors.black,
|
|
|
|
|
),
|
|
|
|
|
CheckboxListTile(
|
|
|
|
|
title: const Text('Wiederholend'),
|
|
|
|
|
value: _isRecurring,
|
|
|
|
|
onChanged: (bool? value) {
|
|
|
|
|
initialRRule: _recurringRule,
|
|
|
|
|
textDelegate: const GermanRRuleTextDelegate(),
|
|
|
|
|
onChange: (String newValue) {
|
|
|
|
|
log("Rule: $newValue");
|
|
|
|
|
setState(() {
|
|
|
|
|
_isRecurring = value!;
|
|
|
|
|
_recurringRule = newValue;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
if (_isRecurring) ...[
|
|
|
|
|
DropdownButtonFormField<String>(
|
|
|
|
|
value: _recurringFrequency,
|
|
|
|
|
items: ['Wöchentlich', 'Täglich', 'Monatlich'].map((String value) {
|
|
|
|
|
return DropdownMenuItem<String>(
|
|
|
|
|
value: value,
|
|
|
|
|
child: Text(value),
|
|
|
|
|
);
|
|
|
|
|
}).toList(),
|
|
|
|
|
onChanged: (String? value) {
|
|
|
|
|
setState(() {
|
|
|
|
|
_recurringFrequency = value ?? "";
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
// Hier könntest du weitere Felder für die Wiederholungseigenschaften hinzufügen
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
@ -113,22 +128,17 @@ class _AddCustomTimetableEventDialogState extends State<AddCustomTimetableEventD
|
|
|
|
|
TextButton(
|
|
|
|
|
onPressed: () {
|
|
|
|
|
// Hier kannst du die Eingaben verwenden
|
|
|
|
|
String startDate = '${_selectedDate.day}/${_selectedDate.month}/${_selectedDate.year}';
|
|
|
|
|
String startTime = '${_selectedStartTime.hour}:${_selectedStartTime.minute}';
|
|
|
|
|
String endTime = '${_selectedEndTime.hour}:${_selectedEndTime.minute}';
|
|
|
|
|
String eventName = _eventNameController.text;
|
|
|
|
|
bool isRecurring = _isRecurring;
|
|
|
|
|
String recurringFrequency = _recurringFrequency;
|
|
|
|
|
String startDate = '${_date.day}/${_date.month}/${_date.year}';
|
|
|
|
|
String startTime = '${_starTime.hour}:${_starTime.minute}';
|
|
|
|
|
String endTime = '${_endTime.hour}:${_endTime.minute}';
|
|
|
|
|
String eventName = _eventName.text;
|
|
|
|
|
String recurringFrequency = _recurringRule;
|
|
|
|
|
|
|
|
|
|
// Hier kannst du die Daten speichern oder weiterverarbeiten
|
|
|
|
|
print('Startdatum: $startDate');
|
|
|
|
|
print('Startzeit: $startTime');
|
|
|
|
|
print('Endzeit: $endTime');
|
|
|
|
|
print('Terminname: $eventName');
|
|
|
|
|
print('Wiederholend: $isRecurring');
|
|
|
|
|
if (_isRecurring) {
|
|
|
|
|
print('Wiederholungs-Frequenz: $recurringFrequency');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Hier könntest du die Termindaten weiterverarbeiten, z.B. speichern und den Dialog schließen
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|