diff --git a/covas_mobile/lib/pages/UpdateEventImage.dart b/covas_mobile/lib/pages/UpdateEventImage.dart index 8868464..af9b8de 100644 --- a/covas_mobile/lib/pages/UpdateEventImage.dart +++ b/covas_mobile/lib/pages/UpdateEventImage.dart @@ -48,21 +48,33 @@ class _UpdateeventImageState extends State TextEditingController endDatepicker = TextEditingController(); TextEditingController endTimepicker = TextEditingController(); - onTapFunctionDatePicker({required BuildContext context}) async { + onTapFunctionDatePicker( + {required BuildContext context, required String position}) async { DateTime? pickedDate = await showDatePicker( context: context, firstDate: DateTime.now(), initialDate: DateTime.now(), lastDate: DateTime(2026)); if (pickedDate == null) return; - startDatepicker.text = DateFormat("dd-MM-yyyy").format(pickedDate); + if (position == "start") { + startDatepicker.text = DateFormat("dd-MM-yyyy").format(pickedDate); + } + if (position == "end") { + endDatepicker.text = DateFormat("dd-MM-yyyy").format(pickedDate); + } } - onTapFunctionTimePicker({required BuildContext context}) async { + onTapFunctionTimePicker( + {required BuildContext context, required String position}) async { TimeOfDay? pickedDate = await showTimePicker(context: context, initialTime: TimeOfDay.now()); if (pickedDate == null) return; - startTimepicker.text = pickedDate.format(context); + if (position == "start") { + startTimepicker.text = pickedDate.format(context); + } + if (position == "end") { + endTimepicker.text = pickedDate.format(context); + } } Future _updateEvent(BuildContext context) async { @@ -215,7 +227,8 @@ class _UpdateeventImageState extends State border: OutlineInputBorder(), labelText: 'Date de debut de l\'évènement', hintText: 'Cliquez ici pour selectionner une date'), - onTap: () => onTapFunctionDatePicker(context: context)), + onTap: () => onTapFunctionDatePicker( + context: context, position: "start")), ), Padding( padding: const EdgeInsets.only( @@ -228,7 +241,8 @@ class _UpdateeventImageState extends State border: OutlineInputBorder(), labelText: 'Heure de debut de l\'évènement', hintText: 'Cliquez ici pour selectionner une heure'), - onTap: () => onTapFunctionTimePicker(context: context)), + onTap: () => onTapFunctionTimePicker( + context: context, position: "start")), ), Padding( padding: const EdgeInsets.only( @@ -241,7 +255,8 @@ class _UpdateeventImageState extends State border: OutlineInputBorder(), labelText: 'Date de fin de l\'évènement', hintText: 'Cliquez ici pour selectionner une date'), - onTap: () => onTapFunctionDatePicker(context: context)), + onTap: () => onTapFunctionDatePicker( + context: context, position: "end")), ), Padding( padding: const EdgeInsets.only( @@ -254,7 +269,8 @@ class _UpdateeventImageState extends State border: OutlineInputBorder(), labelText: 'Heure de fin de l\'évènement', hintText: 'Cliquez ici pour selectionner une heure'), - onTap: () => onTapFunctionTimePicker(context: context)), + onTap: () => onTapFunctionTimePicker( + context: context, position: "end")), ), SizedBox( height: 30,