diff --git a/covas_mobile/lib/pages/ListItemMenu.dart b/covas_mobile/lib/pages/ListItemMenu.dart index e29ba66..f3dd37d 100644 --- a/covas_mobile/lib/pages/ListItemMenu.dart +++ b/covas_mobile/lib/pages/ListItemMenu.dart @@ -172,6 +172,9 @@ class _MyHomePageState extends State { // Reverse geocode: Get city and country from latitude and longitude using Mapbox Search API if (position != null) { _getCityAndCountry(position!.latitude, position!.longitude); + SharedPreferences prefs = await SharedPreferences.getInstance(); + prefs.setDouble("city_lat", position!.latitude); + prefs.setDouble("city_long", position!.longitude); } } } @@ -335,6 +338,9 @@ class _MyHomePageState extends State { context: context, firstDate: dateEvent, lastDate: DateTime(2104)); if (pickedDate == null) return; Datepicker.text = DateFormat("dd-MM-yyyy").format(pickedDate); + if (inputGeo.text.isEmpty) { + _fetchInitialData(); + } else {} } Padding _BuildDateField() { @@ -345,7 +351,16 @@ class _MyHomePageState extends State { controller: Datepicker, readOnly: true, decoration: InputDecoration( - border: OutlineInputBorder(), hintText: 'Recherche par date'), + border: OutlineInputBorder(), + suffixIcon: IconButton( + icon: const Icon(Icons.clear), + onPressed: () { + setState(() { + Datepicker.text = ''; + }); + }, + ), + hintText: 'Recherche par date'), onTap: () => onTapFunctionDatePicker(context: context)), ); } @@ -405,6 +420,10 @@ class _MyHomePageState extends State { }); await fetchPostsByLocation(latitude, longitude); + SharedPreferences prefs = + await SharedPreferences.getInstance(); + prefs.setDouble("city_lat", latitude); + prefs.setDouble("city_long", longitude); }, ); },