add timepicker

This commit is contained in:
Valentin CZERYBA 2024-08-14 23:15:30 +02:00
parent 00bc3bb0aa
commit 2d8737743f

View File

@ -44,6 +44,7 @@ class _UpdateeventImageState extends State<UpdateeventImage>
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<UpdateeventImage>
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<void> _updateEvent(BuildContext context) async {
var url = Uri.parse("${globals.api}/token");
var name = inputName.text;
@ -207,6 +215,19 @@ class _UpdateeventImageState extends State<UpdateeventImage>
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,
),