fix datepicker
This commit is contained in:
parent
792ce0227e
commit
045209575e
@ -65,10 +65,14 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
|
|
||||||
onTapFunctionDatePicker(
|
onTapFunctionDatePicker(
|
||||||
{required BuildContext context, required String position}) async {
|
{required BuildContext context, required String position}) async {
|
||||||
|
String date = "start_date";
|
||||||
|
if (position == "end") {
|
||||||
|
date = "end_date";
|
||||||
|
}
|
||||||
DateTime? pickedDate = await showDatePicker(
|
DateTime? pickedDate = await showDatePicker(
|
||||||
context: context,
|
context: context,
|
||||||
firstDate: DateTime.parse(widget.events["date"]),
|
firstDate: DateTime.parse(widget.events[date]),
|
||||||
initialDate: DateTime.parse(widget.events["date"]),
|
initialDate: DateTime.parse(widget.events[date]),
|
||||||
lastDate: DateTime(2104));
|
lastDate: DateTime(2104));
|
||||||
if (pickedDate == null) return;
|
if (pickedDate == null) return;
|
||||||
if (position == "start") {
|
if (position == "start") {
|
||||||
@ -81,10 +85,14 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
|
|
||||||
onTapFunctionTimePicker(
|
onTapFunctionTimePicker(
|
||||||
{required BuildContext context, required String position}) async {
|
{required BuildContext context, required String position}) async {
|
||||||
|
String date = "start_date";
|
||||||
|
if (position == "end") {
|
||||||
|
date = "end_date";
|
||||||
|
}
|
||||||
TimeOfDay? pickedDate = await showTimePicker(
|
TimeOfDay? pickedDate = await showTimePicker(
|
||||||
context: context,
|
context: context,
|
||||||
initialTime:
|
initialTime:
|
||||||
TimeOfDay.fromDateTime(DateTime.parse(widget.events["date"])));
|
TimeOfDay.fromDateTime(DateTime.parse(widget.events[date])));
|
||||||
if (pickedDate == null) return;
|
if (pickedDate == null) return;
|
||||||
if (position == "start") {
|
if (position == "start") {
|
||||||
startTimepicker.text = pickedDate.format(context);
|
startTimepicker.text = pickedDate.format(context);
|
||||||
@ -273,6 +281,11 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
String? _validateField(String? value) {
|
||||||
|
return value!.isEmpty ? 'Champ requis' : null;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@ -282,7 +295,9 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
backgroundColor: Colors.blue,
|
backgroundColor: Colors.blue,
|
||||||
foregroundColor: Colors.white,
|
foregroundColor: Colors.white,
|
||||||
),
|
),
|
||||||
body: SingleChildScrollView(
|
body: Form(
|
||||||
|
key: _formKey,
|
||||||
|
child: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Padding(
|
Padding(
|
||||||
@ -299,8 +314,9 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
Padding(
|
Padding(
|
||||||
//padding: const EdgeInsets.only(left:15.0,right: 15.0,top:0,bottom: 0),
|
//padding: const EdgeInsets.only(left:15.0,right: 15.0,top:0,bottom: 0),
|
||||||
padding: EdgeInsets.symmetric(horizontal: 15),
|
padding: EdgeInsets.symmetric(horizontal: 15),
|
||||||
child: TextField(
|
child: TextFormField(
|
||||||
controller: inputName,
|
controller: inputName,
|
||||||
|
validator: (value) => _validateField(value),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
labelText: 'Nom',
|
labelText: 'Nom',
|
||||||
@ -311,8 +327,9 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
left: 15.0, right: 15.0, top: 15, bottom: 0),
|
left: 15.0, right: 15.0, top: 15, bottom: 0),
|
||||||
//padding: EdgeInsets.symmetric(horizontal: 15),
|
//padding: EdgeInsets.symmetric(horizontal: 15),
|
||||||
child: TextField(
|
child: TextFormField(
|
||||||
controller: inputAddress,
|
controller: inputAddress,
|
||||||
|
validator: (value) => _validateField(value),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
labelText: 'Adresse',
|
labelText: 'Adresse',
|
||||||
@ -323,8 +340,9 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
left: 15.0, right: 15.0, top: 15, bottom: 0),
|
left: 15.0, right: 15.0, top: 15, bottom: 0),
|
||||||
//padding: EdgeInsets.symmetric(horizontal: 15),
|
//padding: EdgeInsets.symmetric(horizontal: 15),
|
||||||
child: TextField(
|
child: TextFormField(
|
||||||
controller: inputZipCode,
|
controller: inputZipCode,
|
||||||
|
validator: (value) => _validateField(value),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
labelText: 'Code postal',
|
labelText: 'Code postal',
|
||||||
@ -335,8 +353,9 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
left: 15.0, right: 15.0, top: 15, bottom: 0),
|
left: 15.0, right: 15.0, top: 15, bottom: 0),
|
||||||
//padding: EdgeInsets.symmetric(horizontal: 15),
|
//padding: EdgeInsets.symmetric(horizontal: 15),
|
||||||
child: TextField(
|
child: TextFormField(
|
||||||
controller: inputCity,
|
controller: inputCity,
|
||||||
|
validator: (value) => _validateField(value),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
labelText: 'Ville',
|
labelText: 'Ville',
|
||||||
@ -347,8 +366,9 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
left: 15.0, right: 15.0, top: 15, bottom: 0),
|
left: 15.0, right: 15.0, top: 15, bottom: 0),
|
||||||
//padding: EdgeInsets.symmetric(horizontal: 15),
|
//padding: EdgeInsets.symmetric(horizontal: 15),
|
||||||
child: TextField(
|
child: TextFormField(
|
||||||
controller: inputCountry,
|
controller: inputCountry,
|
||||||
|
validator: (value) => _validateField(value),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
labelText: 'Pays',
|
labelText: 'Pays',
|
||||||
@ -359,9 +379,10 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
left: 15.0, right: 15.0, top: 15, bottom: 0),
|
left: 15.0, right: 15.0, top: 15, bottom: 0),
|
||||||
//padding: EdgeInsets.symmetric(horizontal: 15),
|
//padding: EdgeInsets.symmetric(horizontal: 15),
|
||||||
child: TextField(
|
child: TextFormField(
|
||||||
controller: startDatepicker,
|
controller: startDatepicker,
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
|
validator: (value) => _validateField(value),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
labelText: 'Date de debut',
|
labelText: 'Date de debut',
|
||||||
@ -373,9 +394,10 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
left: 15.0, right: 15.0, top: 15, bottom: 0),
|
left: 15.0, right: 15.0, top: 15, bottom: 0),
|
||||||
//padding: EdgeInsets.symmetric(horizontal: 15),
|
//padding: EdgeInsets.symmetric(horizontal: 15),
|
||||||
child: TextField(
|
child: TextFormField(
|
||||||
controller: startTimepicker,
|
controller: startTimepicker,
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
|
validator: (value) => _validateField(value),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
labelText: 'Heure de debut',
|
labelText: 'Heure de debut',
|
||||||
@ -387,9 +409,10 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
left: 15.0, right: 15.0, top: 15, bottom: 0),
|
left: 15.0, right: 15.0, top: 15, bottom: 0),
|
||||||
//padding: EdgeInsets.symmetric(horizontal: 15),
|
//padding: EdgeInsets.symmetric(horizontal: 15),
|
||||||
child: TextField(
|
child: TextFormField(
|
||||||
controller: endDatepicker,
|
controller: endDatepicker,
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
|
validator: (value) => _validateField(value),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
labelText: 'Date de fin',
|
labelText: 'Date de fin',
|
||||||
@ -401,9 +424,10 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
left: 15.0, right: 15.0, top: 15, bottom: 0),
|
left: 15.0, right: 15.0, top: 15, bottom: 0),
|
||||||
//padding: EdgeInsets.symmetric(horizontal: 15),
|
//padding: EdgeInsets.symmetric(horizontal: 15),
|
||||||
child: TextField(
|
child: TextFormField(
|
||||||
controller: endTimepicker,
|
controller: endTimepicker,
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
|
validator: (value) => _validateField(value),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
labelText: 'Heure de fin',
|
labelText: 'Heure de fin',
|
||||||
@ -460,10 +484,13 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
),
|
),
|
||||||
color: Colors.blue,
|
color: Colors.blue,
|
||||||
),
|
),
|
||||||
margin: const EdgeInsets.symmetric(
|
margin:
|
||||||
|
const EdgeInsets.symmetric(
|
||||||
horizontal: 5.0),
|
horizontal: 5.0),
|
||||||
padding: const EdgeInsets.symmetric(
|
padding:
|
||||||
horizontal: 10.0, vertical: 5.0),
|
const EdgeInsets.symmetric(
|
||||||
|
horizontal: 10.0,
|
||||||
|
vertical: 5.0),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment:
|
mainAxisAlignment:
|
||||||
MainAxisAlignment.start,
|
MainAxisAlignment.start,
|
||||||
@ -471,7 +498,7 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
children: [
|
children: [
|
||||||
InkWell(
|
InkWell(
|
||||||
child: Text(
|
child: Text(
|
||||||
'#$tag',
|
'$tag',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: Colors.white),
|
color: Colors.white),
|
||||||
),
|
),
|
||||||
@ -552,10 +579,13 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
),
|
),
|
||||||
color: Colors.blue,
|
color: Colors.blue,
|
||||||
),
|
),
|
||||||
margin: const EdgeInsets.symmetric(
|
margin:
|
||||||
|
const EdgeInsets.symmetric(
|
||||||
horizontal: 5.0),
|
horizontal: 5.0),
|
||||||
padding: const EdgeInsets.symmetric(
|
padding:
|
||||||
horizontal: 10.0, vertical: 5.0),
|
const EdgeInsets.symmetric(
|
||||||
|
horizontal: 10.0,
|
||||||
|
vertical: 5.0),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment:
|
mainAxisAlignment:
|
||||||
MainAxisAlignment.start,
|
MainAxisAlignment.start,
|
||||||
@ -616,10 +646,13 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
height: 50,
|
height: 50,
|
||||||
width: 250,
|
width: 250,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.blue, borderRadius: BorderRadius.circular(20)),
|
color: Colors.blue,
|
||||||
|
borderRadius: BorderRadius.circular(20)),
|
||||||
child: TextButton(
|
child: TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
if (_formKey.currentState!.validate()) {
|
||||||
_updateEvent(context);
|
_updateEvent(context);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
'Ajouter',
|
'Ajouter',
|
||||||
@ -630,6 +663,6 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user