Compare commits

..

No commits in common. "c8bcd254ddc8ef0fa1daccd731d9bcf5f0104786" and "c1e85c255e3af6a32919492ab30eed2d200ce240" have entirely different histories.

2 changed files with 7 additions and 12 deletions

View File

@ -50,7 +50,6 @@ class _MyHomePageState extends State<ListItemMenu> {
// Fetching events from API
static Future<List<Events>> getPosts() async {
PermissionStatus status = await Permission.location.status;
var url = Uri.parse("${globals.api}/events");
if (status.isGranted) {
print("Location permission granted");
@ -75,10 +74,10 @@ class _MyHomePageState extends State<ListItemMenu> {
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&current_datetime=${currentDatetime.toString()}");
"&min_lon=$minLon&max_lon=$maxLon");
}
SharedPreferences prefs = await SharedPreferences.getInstance();
var accessToken = prefs.getString("access_token") ?? "";
@ -100,9 +99,7 @@ class _MyHomePageState extends State<ListItemMenu> {
var accessToken = prefs.getString("access_token") ?? "";
final List<Events> body = [];
if (accessToken.isNotEmpty) {
DateTime currentDateTime = new DateTime.now();
var url = Uri.parse(
"${globals.api}/events?current_datetime=${currentDateTime.toString()}");
var url = Uri.parse("${globals.api}/events");
final response = await http.get(url, headers: {
"Content-Type": "application/json",
HttpHeaders.cookieHeader: "access_token=${accessToken}"
@ -265,10 +262,10 @@ class _MyHomePageState extends State<ListItemMenu> {
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&current_datetime=${currentDate.toString()}");
"&min_lon=$minLon&max_lon=$maxLon");
final response = await http.get(url, headers: {
"Content-Type": "application/json",

View File

@ -84,9 +84,7 @@ class SearchDelegateExample extends SearchDelegate {
var accessToken = prefs.getString("access_token") ?? "";
final List<Events> body = [];
if (accessToken.isNotEmpty) {
DateTime currentDate = DateTime.now();
var url = Uri.parse(
"${globals.api}/events/search?item=${query}&current_dateime=${currentDate.toString()}");
var url = Uri.parse("${globals.api}/events/search?item=$query");
if (geoQuery.isNotEmpty) {
await dotenv.load(
fileName: ".env"); // Load your .env for the Mapbox access token
@ -115,7 +113,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}&current_dateime=${currentDate.toString()}");
"${globals.api}/events/search?item=$query&min_lat=$minLat&max_lat=$maxLat&min_lon=$minLon&max_lon=$maxLon");
}
}
}