Merge pull request 'feature/getcurrentdate' (#12) from feature/getcurrentdate into main
Reviewed-on: #12
This commit is contained in:
commit
c8bcd254dd
@ -50,6 +50,7 @@ class _MyHomePageState extends State<ListItemMenu> {
|
|||||||
// Fetching events from API
|
// Fetching events from API
|
||||||
static Future<List<Events>> getPosts() async {
|
static Future<List<Events>> getPosts() async {
|
||||||
PermissionStatus status = await Permission.location.status;
|
PermissionStatus status = await Permission.location.status;
|
||||||
|
|
||||||
var url = Uri.parse("${globals.api}/events");
|
var url = Uri.parse("${globals.api}/events");
|
||||||
if (status.isGranted) {
|
if (status.isGranted) {
|
||||||
print("Location permission granted");
|
print("Location permission granted");
|
||||||
@ -74,10 +75,10 @@ class _MyHomePageState extends State<ListItemMenu> {
|
|||||||
double maxLat = position.latitude + latDistance;
|
double maxLat = position.latitude + latDistance;
|
||||||
double minLon = position.longitude - lonDistance;
|
double minLon = position.longitude - lonDistance;
|
||||||
double maxLon = position.longitude + lonDistance;
|
double maxLon = position.longitude + lonDistance;
|
||||||
|
DateTime currentDatetime = DateTime.now();
|
||||||
url = Uri.parse("${globals.api}/events/search"
|
url = Uri.parse("${globals.api}/events/search"
|
||||||
"?min_lat=$minLat&max_lat=$maxLat"
|
"?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();
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
var accessToken = prefs.getString("access_token") ?? "";
|
var accessToken = prefs.getString("access_token") ?? "";
|
||||||
@ -99,7 +100,9 @@ class _MyHomePageState extends State<ListItemMenu> {
|
|||||||
var accessToken = prefs.getString("access_token") ?? "";
|
var accessToken = prefs.getString("access_token") ?? "";
|
||||||
final List<Events> body = [];
|
final List<Events> body = [];
|
||||||
if (accessToken.isNotEmpty) {
|
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: {
|
final response = await http.get(url, headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
HttpHeaders.cookieHeader: "access_token=${accessToken}"
|
HttpHeaders.cookieHeader: "access_token=${accessToken}"
|
||||||
@ -262,10 +265,10 @@ class _MyHomePageState extends State<ListItemMenu> {
|
|||||||
double maxLat = latitude + latDistance;
|
double maxLat = latitude + latDistance;
|
||||||
double minLon = longitude - lonDistance;
|
double minLon = longitude - lonDistance;
|
||||||
double maxLon = longitude + lonDistance;
|
double maxLon = longitude + lonDistance;
|
||||||
|
DateTime currentDate = DateTime.now();
|
||||||
var url = Uri.parse("${globals.api}/events/search"
|
var url = Uri.parse("${globals.api}/events/search"
|
||||||
"?min_lat=$minLat&max_lat=$maxLat"
|
"?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: {
|
final response = await http.get(url, headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
@ -84,7 +84,9 @@ class SearchDelegateExample extends SearchDelegate {
|
|||||||
var accessToken = prefs.getString("access_token") ?? "";
|
var accessToken = prefs.getString("access_token") ?? "";
|
||||||
final List<Events> body = [];
|
final List<Events> body = [];
|
||||||
if (accessToken.isNotEmpty) {
|
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) {
|
if (geoQuery.isNotEmpty) {
|
||||||
await dotenv.load(
|
await dotenv.load(
|
||||||
fileName: ".env"); // Load your .env for the Mapbox access token
|
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
|
// Construct the search URL with the item query and latitude/longitude bounds
|
||||||
url = Uri.parse(
|
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()}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user