From b1ca67ed723efd722862f2837590a7482bb4ae73 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Mon, 14 Oct 2024 17:49:39 +0200 Subject: [PATCH] add tags automatically --- covas_mobile/lib/pages/DisplayPictureScreen.dart | 2 +- covas_mobile/lib/pages/UpdateEventImage.dart | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/covas_mobile/lib/pages/DisplayPictureScreen.dart b/covas_mobile/lib/pages/DisplayPictureScreen.dart index 9815034..584d55e 100644 --- a/covas_mobile/lib/pages/DisplayPictureScreen.dart +++ b/covas_mobile/lib/pages/DisplayPictureScreen.dart @@ -132,7 +132,7 @@ class DisplayPictureScreenState extends State gemini .textAndImage( text: - "Peux-tu donner le nom, la date avec l'année actuelle ou d'une année future proche et le lieu de l'évènement sous format JSON avec les valeurs suivantes : name, address, city, zip_code, country, description, start_date et end_date sous le format en YYYY-MM-DD HH:mm:ssZ, et sans la présence du mot json dans la chaîne de caractère", + "Peux-tu donner le nom, la date avec l'année actuelle ou d'une année future proche et le lieu de l'évènement sous format JSON avec les valeurs suivantes : name, address, city, zip_code, country, description, tags (tableau sans espace), start_date et end_date sous le format en YYYY-MM-DD HH:mm:ssZ, et sans la présence du mot json dans la chaîne de caractère", images: [file.readAsBytesSync()], modelName: "models/gemini-1.5-pro-latest") .then((value) => searchEvents( diff --git a/covas_mobile/lib/pages/UpdateEventImage.dart b/covas_mobile/lib/pages/UpdateEventImage.dart index 8abc7b0..86809d1 100644 --- a/covas_mobile/lib/pages/UpdateEventImage.dart +++ b/covas_mobile/lib/pages/UpdateEventImage.dart @@ -58,6 +58,7 @@ class _UpdateeventImageState extends State TextEditingController endDatepicker = TextEditingController(); TextEditingController endTimepicker = TextEditingController(); final _stringTagController = StringTagController(); + List initialTags = []; onTapFunctionDatePicker( {required BuildContext context, required String position}) async { @@ -97,6 +98,13 @@ class _UpdateeventImageState extends State return check; } + convertNulltoArray(List check) { + if (check == null) { + return []; + } + return check; + } + String formatDate(String date) { var splitedDate = date.split("-"); var day = splitedDate[0]; @@ -248,6 +256,7 @@ class _UpdateeventImageState extends State endDatepicker.text = DateFormat("dd-MM-yyyy").format(pickedEndDate); startTimepicker.text = DateFormat("HH-mm").format(pickedStartDate); endTimepicker.text = DateFormat("HH-mm").format(pickedEndDate); + initialTags = List.from(widget.events['tags'] as List); } @override @@ -396,7 +405,7 @@ class _UpdateeventImageState extends State ), TextFieldTags( textfieldTagsController: _stringTagController, - initialTags: [], + initialTags: initialTags, textSeparators: const [' ', ','], validator: (String tag) { if (_stringTagController.getTags!.contains(tag)) {