From 2d8737743f2ab9e5cf16ed6fa98ee2dd4dbde496 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Wed, 14 Aug 2024 23:15:30 +0200 Subject: [PATCH] add timepicker --- covas_mobile/lib/pages/UpdateEventImage.dart | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/covas_mobile/lib/pages/UpdateEventImage.dart b/covas_mobile/lib/pages/UpdateEventImage.dart index 04ca787..3f242a5 100644 --- a/covas_mobile/lib/pages/UpdateEventImage.dart +++ b/covas_mobile/lib/pages/UpdateEventImage.dart @@ -44,6 +44,7 @@ class _UpdateeventImageState extends State TextEditingController inputPlace = TextEditingController(); TextEditingController inputDate = TextEditingController(); TextEditingController startDatepicker = TextEditingController(); + TextEditingController startTimepicker = TextEditingController(); onTapFunctionDatePicker({required BuildContext context}) async { DateTime? pickedDate = await showDatePicker( @@ -55,6 +56,13 @@ class _UpdateeventImageState extends State startDatepicker.text = DateFormat("dd-MM-yyyy").format(pickedDate); } + onTapFunctionTimePicker({required BuildContext context}) async { + TimeOfDay? pickedDate = + await showTimePicker(context: context, initialTime: TimeOfDay.now()); + if (pickedDate == null) return; + startTimepicker.text = pickedDate.format(context); + } + Future _updateEvent(BuildContext context) async { var url = Uri.parse("${globals.api}/token"); var name = inputName.text; @@ -207,6 +215,19 @@ class _UpdateeventImageState extends State hintText: 'Cliquez ici pour selectionner une date'), onTap: () => onTapFunctionDatePicker(context: context)), ), + Padding( + padding: const EdgeInsets.only( + left: 15.0, right: 15.0, top: 15, bottom: 0), + //padding: EdgeInsets.symmetric(horizontal: 15), + child: TextField( + controller: startTimepicker, + readOnly: true, + decoration: InputDecoration( + border: OutlineInputBorder(), + labelText: 'Heure de debut de l\'évènement', + hintText: 'Cliquez ici pour selectionner une heure'), + onTap: () => onTapFunctionTimePicker(context: context)), + ), SizedBox( height: 30, ),