fix datepicker
This commit is contained in:
parent
44a0691e31
commit
00a9125eb2
@ -87,7 +87,7 @@ class DisplayPictureScreenState extends State<DisplayPictureScreen>
|
|||||||
Future<void> searchEvents(String json, String imagePath) async {
|
Future<void> searchEvents(String json, String imagePath) async {
|
||||||
print(json.replaceAll("'''json", '').replaceAll("'''", ""));
|
print(json.replaceAll("'''json", '').replaceAll("'''", ""));
|
||||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
|
try {
|
||||||
Map<String, dynamic> jsonData =
|
Map<String, dynamic> jsonData =
|
||||||
jsonDecode(json.replaceAll("```json", '').replaceAll("```", ""));
|
jsonDecode(json.replaceAll("```json", '').replaceAll("```", ""));
|
||||||
print("json : ${jsonData}");
|
print("json : ${jsonData}");
|
||||||
@ -120,6 +120,9 @@ class DisplayPictureScreenState extends State<DisplayPictureScreen>
|
|||||||
} else {
|
} else {
|
||||||
showErrorDialog(context, "Erreur de token");
|
showErrorDialog(context, "Erreur de token");
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
showErrorDialog(context, "Erreur de format de donnée fourni par l'IA");
|
||||||
|
}
|
||||||
|
|
||||||
//showDescImageAddDialog(context, message);
|
//showDescImageAddDialog(context, message);
|
||||||
}
|
}
|
||||||
|
@ -70,10 +70,16 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
if (position == "end") {
|
if (position == "end") {
|
||||||
date = "end_date";
|
date = "end_date";
|
||||||
}
|
}
|
||||||
|
DateTime dateEvent;
|
||||||
|
if (widget.events[date].toString().isEmpty) {
|
||||||
|
dateEvent = DateTime.now();
|
||||||
|
} else {
|
||||||
|
dateEvent = DateTime.parse(widget.events[date]);
|
||||||
|
}
|
||||||
DateTime? pickedDate = await showDatePicker(
|
DateTime? pickedDate = await showDatePicker(
|
||||||
context: context,
|
context: context,
|
||||||
firstDate: DateTime.parse(widget.events[date]),
|
firstDate: dateEvent,
|
||||||
initialDate: DateTime.parse(widget.events[date]),
|
initialDate: dateEvent,
|
||||||
lastDate: DateTime(2104));
|
lastDate: DateTime(2104));
|
||||||
if (pickedDate == null) return;
|
if (pickedDate == null) return;
|
||||||
if (position == "start") {
|
if (position == "start") {
|
||||||
@ -90,10 +96,14 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
if (position == "end") {
|
if (position == "end") {
|
||||||
date = "end_date";
|
date = "end_date";
|
||||||
}
|
}
|
||||||
TimeOfDay? pickedDate = await showTimePicker(
|
TimeOfDay timeEvent;
|
||||||
context: context,
|
if (widget.events[date].toString().isEmpty) {
|
||||||
initialTime:
|
timeEvent = TimeOfDay.now();
|
||||||
TimeOfDay.fromDateTime(DateTime.parse(widget.events[date])));
|
} else {
|
||||||
|
timeEvent = TimeOfDay.fromDateTime(DateTime.parse(widget.events[date]));
|
||||||
|
}
|
||||||
|
TimeOfDay? pickedDate =
|
||||||
|
await showTimePicker(context: context, initialTime: timeEvent);
|
||||||
if (pickedDate == null) return;
|
if (pickedDate == null) return;
|
||||||
if (position == "start") {
|
if (position == "start") {
|
||||||
startTimepicker.text = pickedDate.format(context);
|
startTimepicker.text = pickedDate.format(context);
|
||||||
@ -274,16 +284,18 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
inputName.text = convertNulltoEmptyString(widget.events["name"]);
|
inputName.text = convertNulltoEmptyString(widget.events["name"]);
|
||||||
inputGeo.text = convertNulltoEmptyString(widget.events["place"]);
|
inputGeo.text = convertNulltoEmptyString(widget.events["place"]);
|
||||||
inputDesc.text = convertNulltoEmptyString(widget.events["description"]);
|
inputDesc.text = convertNulltoEmptyString(widget.events["description"]);
|
||||||
|
if (widget.events["start_date"].toString().isNotEmpty) {
|
||||||
DateTime pickedStartDate =
|
DateTime pickedStartDate =
|
||||||
DateTime.parse(convertNulltoEmptyString(widget.events["start_date"]));
|
DateTime.parse(convertNulltoEmptyString(widget.events["start_date"]));
|
||||||
|
startDatepicker.text = DateFormat("dd-MM-yyyy").format(pickedStartDate);
|
||||||
|
startTimepicker.text = DateFormat("HH-mm").format(pickedStartDate);
|
||||||
|
}
|
||||||
|
if (widget.events["end_date"].toString().isNotEmpty) {
|
||||||
DateTime pickedEndDate =
|
DateTime pickedEndDate =
|
||||||
DateTime.parse(convertNulltoEmptyString(widget.events["end_date"]));
|
DateTime.parse(convertNulltoEmptyString(widget.events["end_date"]));
|
||||||
|
|
||||||
startDatepicker.text = DateFormat("dd-MM-yyyy").format(pickedStartDate);
|
|
||||||
endDatepicker.text = DateFormat("dd-MM-yyyy").format(pickedEndDate);
|
endDatepicker.text = DateFormat("dd-MM-yyyy").format(pickedEndDate);
|
||||||
startTimepicker.text = DateFormat("HH-mm").format(pickedStartDate);
|
|
||||||
endTimepicker.text = DateFormat("HH-mm").format(pickedEndDate);
|
endTimepicker.text = DateFormat("HH-mm").format(pickedEndDate);
|
||||||
|
}
|
||||||
initialTags = List<String>.from(widget.events['tags'] as List);
|
initialTags = List<String>.from(widget.events['tags'] as List);
|
||||||
initialOrga = List<String>.from(widget.events['organizers'] as List);
|
initialOrga = List<String>.from(widget.events['organizers'] as List);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user