From 23aec689f13469043b80a6cff97c9b6b9eed73fa Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Sat, 23 Nov 2024 13:14:24 +0100 Subject: [PATCH] add condition --- covas_mobile/lib/pages/ListItemMenu.dart | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/covas_mobile/lib/pages/ListItemMenu.dart b/covas_mobile/lib/pages/ListItemMenu.dart index 5020fcb..6012b06 100644 --- a/covas_mobile/lib/pages/ListItemMenu.dart +++ b/covas_mobile/lib/pages/ListItemMenu.dart @@ -1,4 +1,3 @@ -import 'package:covas_mobile/classes/alert.dart'; import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; import 'package:flutter_dotenv/flutter_dotenv.dart'; // Import dotenv @@ -122,6 +121,10 @@ class _MyHomePageState extends State { DateTime currentDateTime = DateTime.now(); var url = Uri.parse( "${globals.api}/events?current_datetime=${currentDateTime.toString()}"); + if (Datepicker.text.isNotEmpty) { + 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}" @@ -307,6 +310,11 @@ class _MyHomePageState extends State { var url = Uri.parse("${globals.api}/events/search" "?min_lat=$minLat&max_lat=$maxLat" "&min_lon=$minLon&max_lon=$maxLon¤t_datetime=${currentDate.toString()}"); + if (Datepicker.text.isNotEmpty) { + url = Uri.parse("${globals.api}/events/search" + "?min_lat=$minLat&max_lat=$maxLat" + "&min_lon=$minLon&max_lon=$maxLon"); + } final response = await http.get(url, headers: { "Content-Type": "application/json", @@ -343,7 +351,9 @@ class _MyHomePageState extends State { Datepicker.text = DateFormat("dd-MM-yyyy").format(pickedDate); if (inputGeo.text.isEmpty) { _fetchInitialData(); - } else {} + } else { + fetchPostsByLocation(); + } } Padding _BuildDateField() {