diff --git a/covas_mobile/lib/pages/ListItemMenu.dart b/covas_mobile/lib/pages/ListItemMenu.dart index e68fd8c..b4fcfd6 100644 --- a/covas_mobile/lib/pages/ListItemMenu.dart +++ b/covas_mobile/lib/pages/ListItemMenu.dart @@ -47,6 +47,7 @@ class _MyHomePageState extends State { String query = ''; List> suggestions = []; List> suggestionsItem = []; + List> suggestionsTags = []; TextEditingController inputGeo = TextEditingController(); TextEditingController startDatepicker = TextEditingController(); TextEditingController endDatepicker = TextEditingController(); @@ -358,6 +359,33 @@ class _MyHomePageState extends State { } } + Future searchSuggestionsByTag(String input) async { + SharedPreferences prefs = await SharedPreferences.getInstance(); + var accessToken = prefs.getString("access_token") ?? ""; + + if (accessToken.isNotEmpty) { + var url = Uri.parse("${globals.api}/tags?name=${input}"); + final response = await http.get(url, headers: { + "Content-Type": "application/json", + HttpHeaders.cookieHeader: "access_token=$accessToken" + }); + + if (response.statusCode == 200) { + final data = json.decode(utf8.decode(response.bodyBytes)); + setState(() { + suggestionsTags = (data as List) + .map((feature) => {'name': feature['name']}) + .toList(); + if (suggestionsItem.isNotEmpty) { + showDateFields = false; + showArrow = false; + } + }); + print("status code : ${response.statusCode}"); + } + } + } + Future fetchPostsByLocation() async { SharedPreferences prefs = await SharedPreferences.getInstance(); var accessToken = prefs.getString("access_token") ?? "";