diff --git a/covas_mobile/lib/pages/ListItemMenu.dart b/covas_mobile/lib/pages/ListItemMenu.dart index 1bf80a2..7f42243 100644 --- a/covas_mobile/lib/pages/ListItemMenu.dart +++ b/covas_mobile/lib/pages/ListItemMenu.dart @@ -325,6 +325,10 @@ class _MyHomePageState extends State { stringParameter = stringParameter + "&item=${inputItem.text}"; endpoint = "events/search"; } + if (inputTags.text.isNotEmpty) { + stringParameter = stringParameter + "&tags=${inputTags.text}"; + endpoint = "events/search"; + } if (stringParameter.isNotEmpty) { stringParameter = "$stringParameter&$dateParameter"; } else { @@ -370,20 +374,22 @@ class _MyHomePageState extends State { "Content-Type": "application/json", HttpHeaders.cookieHeader: "access_token=$accessToken" }); + print("status code tags : ${response.statusCode}"); if (response.statusCode == 200) { final data = json.decode(utf8.decode(response.bodyBytes)); + print("tags ${data}"); setState(() { suggestionsTags = (data as List) .map((feature) => {'name': feature['name']}) .toList(); + print("suggesttion tag : ${suggestionsTags}"); if (suggestionsTags.isNotEmpty) { showInputGeo = false; showInputSearch = false; showArrow = false; } }); - print("status code : ${response.statusCode}"); } } } @@ -398,6 +404,7 @@ class _MyHomePageState extends State { "Content-Type": "application/json", HttpHeaders.cookieHeader: "access_token=$accessToken" }); + print("status code : ${response.statusCode}"); if (response.statusCode == 200) { final List body = json.decode(utf8.decode(response.bodyBytes)); @@ -595,9 +602,17 @@ class _MyHomePageState extends State { ), onChanged: (value) { if (value.isNotEmpty) { + setState(() { + itemTags = value; + searchSuggestionsByTag(value); + }); } else { setState(() { - inputTags.clear(); // Clear the text field + inputTags.clear(); + showArrow = true; + showInputSearch = true; + showInputGeo = true; // Optionally clear suggestions + itemTags = ''; // Clear the text field /// Clear the filted posts }); @@ -613,7 +628,7 @@ class _MyHomePageState extends State { ), child: ListView.builder( shrinkWrap: true, - itemCount: suggestions.length, + itemCount: suggestionsTags.length, itemBuilder: (context, index) { return ListTile( title: Text(suggestionsTags[index]['name']), @@ -626,6 +641,7 @@ class _MyHomePageState extends State { showInputSearch = true; showInputGeo = true; }); + await fetchPostsByLocation(); }, ); },