diff --git a/covas_mobile/lib/pages/ListItemMenu.dart b/covas_mobile/lib/pages/ListItemMenu.dart index 244b6d9..1391715 100644 --- a/covas_mobile/lib/pages/ListItemMenu.dart +++ b/covas_mobile/lib/pages/ListItemMenu.dart @@ -53,6 +53,7 @@ class _MyHomePageState extends State { bool showDateFields = false; // State to toggle date fields bool showArrow = true; + bool showInputSearch = true; // Fetching events from API static Future> getPosts() async { PermissionStatus status = await Permission.location.status; @@ -262,6 +263,7 @@ class _MyHomePageState extends State { .toList(); if (suggestions.isNotEmpty) { showArrow = false; + showInputSearch = false; } }); } else { @@ -336,11 +338,15 @@ class _MyHomePageState extends State { }); if (response.statusCode == 200) { - final data = json.decode(response.body); + final data = json.decode(utf8.decode(response.bodyBytes)); setState(() { suggestionsItem = (data as List) .map((feature) => {'name': feature['name']}) .toList(); + if (suggestionsItem.isNotEmpty) { + showDateFields = false; + showArrow = false; + } }); print("status code : ${response.statusCode}"); } @@ -449,7 +455,8 @@ class _MyHomePageState extends State { inputGeo.clear(); // Clear the text field geographicalZone = ''; // Reset the geographical zone state suggestions.clear(); - showArrow = true; // Optionally clear suggestions + showArrow = true; + showInputSearch = true; // Optionally clear suggestions /// Clear the filtered posts }); fetchPostsByLocation(); @@ -471,6 +478,7 @@ class _MyHomePageState extends State { geographicalZone = ''; // Reset the geographical zone state suggestions.clear(); // Optionally clear suggestions showArrow = true; + showInputSearch = true; /// Clear the filted posts }); @@ -502,6 +510,7 @@ class _MyHomePageState extends State { inputGeo.text = geographicalZone; suggestions.clear(); showArrow = true; + showInputSearch = true; }); SharedPreferences prefs = await SharedPreferences.getInstance(); @@ -534,7 +543,9 @@ class _MyHomePageState extends State { setState(() { inputItem.clear(); itemName = ''; // Reset the geographical zone state - suggestionsItem.clear(); // + suggestionsItem.clear(); + showDateFields = true; + showArrow = true; }); fetchPostsByLocation(); }, @@ -550,7 +561,9 @@ class _MyHomePageState extends State { setState(() { inputItem.clear(); // Clear the text field itemName = ''; // Reset the geographical zone state - suggestionsItem.clear(); // Optionally clear suggestions + suggestionsItem.clear(); + showDateFields = true; + showArrow = true; // Optionally clear suggestions /// Clear the filted posts }); @@ -575,6 +588,8 @@ class _MyHomePageState extends State { itemName = suggestionsItem[index]['name']; inputItem.text = itemName; suggestionsItem.clear(); + showDateFields = true; + showArrow = true; }); await fetchPostsByLocation(); }, @@ -602,7 +617,7 @@ class _MyHomePageState extends State { ), body: Column( children: [ - if (showArrow) _buildItemZoneSearchField(), + if (showInputSearch) _buildItemZoneSearchField(), if ((showDateFields) && (showArrow)) Row( mainAxisAlignment: MainAxisAlignment.spaceBetween,