diff --git a/covas_mobile/lib/pages/ListItemMenu.dart b/covas_mobile/lib/pages/ListItemMenu.dart index c280419..7539574 100644 --- a/covas_mobile/lib/pages/ListItemMenu.dart +++ b/covas_mobile/lib/pages/ListItemMenu.dart @@ -50,6 +50,7 @@ class _MyHomePageState extends State { // Fetching events from API static Future> getPosts() async { PermissionStatus status = await Permission.location.status; + var url = Uri.parse("${globals.api}/events"); if (status.isGranted) { print("Location permission granted"); @@ -74,10 +75,10 @@ class _MyHomePageState extends State { double maxLat = position.latitude + latDistance; double minLon = position.longitude - lonDistance; double maxLon = position.longitude + lonDistance; - + DateTime currentDatetime = DateTime.now(); url = Uri.parse("${globals.api}/events/search" "?min_lat=$minLat&max_lat=$maxLat" - "&min_lon=$minLon&max_lon=$maxLon"); + "&min_lon=$minLon&max_lon=$maxLon¤t_datetime=${currentDatetime.toString()}"); } SharedPreferences prefs = await SharedPreferences.getInstance(); var accessToken = prefs.getString("access_token") ?? ""; @@ -99,7 +100,9 @@ class _MyHomePageState extends State { var accessToken = prefs.getString("access_token") ?? ""; final List body = []; if (accessToken.isNotEmpty) { - var url = Uri.parse("${globals.api}/events"); + DateTime currentDateTime = new DateTime.now(); + var url = Uri.parse( + "${globals.api}/events?current_datetime=${currentDateTime.toString()}"); final response = await http.get(url, headers: { "Content-Type": "application/json", HttpHeaders.cookieHeader: "access_token=${accessToken}" @@ -262,10 +265,10 @@ class _MyHomePageState extends State { double maxLat = latitude + latDistance; double minLon = longitude - lonDistance; double maxLon = longitude + lonDistance; - + DateTime currentDate = DateTime.now(); var url = Uri.parse("${globals.api}/events/search" "?min_lat=$minLat&max_lat=$maxLat" - "&min_lon=$minLon&max_lon=$maxLon"); + "&min_lon=$minLon&max_lon=$maxLon¤t_datetime=${currentDate.toString()}"); final response = await http.get(url, headers: { "Content-Type": "application/json", diff --git a/covas_mobile/lib/pages/SearchDelegate.dart b/covas_mobile/lib/pages/SearchDelegate.dart index 6c870ea..e49b17e 100644 --- a/covas_mobile/lib/pages/SearchDelegate.dart +++ b/covas_mobile/lib/pages/SearchDelegate.dart @@ -84,7 +84,9 @@ class SearchDelegateExample extends SearchDelegate { var accessToken = prefs.getString("access_token") ?? ""; final List body = []; if (accessToken.isNotEmpty) { - var url = Uri.parse("${globals.api}/events/search?item=$query"); + DateTime currentDate = DateTime.now(); + var url = Uri.parse( + "${globals.api}/events/search?item=${query}¤t_dateime=${currentDate.toString()}"); if (geoQuery.isNotEmpty) { await dotenv.load( fileName: ".env"); // Load your .env for the Mapbox access token @@ -113,7 +115,7 @@ class SearchDelegateExample extends SearchDelegate { // Construct the search URL with the item query and latitude/longitude bounds url = Uri.parse( - "${globals.api}/events/search?item=$query&min_lat=$minLat&max_lat=$maxLat&min_lon=$minLon&max_lon=$maxLon"); + "${globals.api}/events/search?item=${query}&min_lat=${minLat}&max_lat=${maxLat}&min_lon=${minLon}&max_lon=${maxLon}¤t_dateime=${currentDate.toString()}"); } } }