add parameter
This commit is contained in:
@@ -112,6 +112,15 @@ class _MyHomePageState extends State<ListItemMenu> {
|
||||
return body;
|
||||
}
|
||||
|
||||
String formatDate(String date) {
|
||||
var splitedDate = date.split("-");
|
||||
var day = splitedDate[0];
|
||||
var month = splitedDate[1];
|
||||
var year = splitedDate[2];
|
||||
|
||||
return "${year}-${month}-${day}";
|
||||
}
|
||||
|
||||
// Fetching events from API
|
||||
Future<List<Events>> getAllPosts() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
@@ -122,8 +131,9 @@ class _MyHomePageState extends State<ListItemMenu> {
|
||||
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()}");
|
||||
TimeOfDay time = TimeOfDay.now();
|
||||
var date = formatDate(Datepicker.text) + "T" + time.toString();
|
||||
url = Uri.parse("${globals.api}/events?date_event=${date}");
|
||||
}
|
||||
final response = await http.get(url, headers: {
|
||||
"Content-Type": "application/json",
|
||||
@@ -311,9 +321,12 @@ class _MyHomePageState extends State<ListItemMenu> {
|
||||
"?min_lat=$minLat&max_lat=$maxLat"
|
||||
"&min_lon=$minLon&max_lon=$maxLon¤t_datetime=${currentDate.toString()}");
|
||||
if (Datepicker.text.isNotEmpty) {
|
||||
TimeOfDay time = TimeOfDay.now();
|
||||
var date = formatDate(Datepicker.text) + "T" + time.toString();
|
||||
url = Uri.parse("${globals.api}/events/search"
|
||||
"?min_lat=$minLat&max_lat=$maxLat"
|
||||
"&min_lon=$minLon&max_lon=$maxLon");
|
||||
"?min_lat=$minLat&max_lat=$maxLat"
|
||||
"&min_lon=$minLon&max_lon=$maxLon&date_event=" +
|
||||
date);
|
||||
}
|
||||
|
||||
final response = await http.get(url, headers: {
|
||||
@@ -349,6 +362,8 @@ class _MyHomePageState extends State<ListItemMenu> {
|
||||
context: context, firstDate: dateEvent, lastDate: DateTime(2104));
|
||||
if (pickedDate == null) return;
|
||||
Datepicker.text = DateFormat("dd-MM-yyyy").format(pickedDate);
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
prefs.setString("date_event", Datepicker.text);
|
||||
if (inputGeo.text.isEmpty) {
|
||||
_fetchInitialData();
|
||||
} else {
|
||||
@@ -370,8 +385,8 @@ class _MyHomePageState extends State<ListItemMenu> {
|
||||
onPressed: () async {
|
||||
SharedPreferences prefs =
|
||||
await SharedPreferences.getInstance();
|
||||
prefs.remove("city_lat");
|
||||
prefs.remove("city_long");
|
||||
|
||||
prefs.remove("date_event");
|
||||
setState(() {
|
||||
Datepicker.text = '';
|
||||
});
|
||||
@@ -394,7 +409,11 @@ class _MyHomePageState extends State<ListItemMenu> {
|
||||
border: OutlineInputBorder(),
|
||||
suffixIcon: IconButton(
|
||||
icon: const Icon(Icons.clear),
|
||||
onPressed: () {
|
||||
onPressed: () async {
|
||||
SharedPreferences prefs =
|
||||
await SharedPreferences.getInstance();
|
||||
prefs.remove("city_lat");
|
||||
prefs.remove("city_long");
|
||||
setState(() {
|
||||
inputGeo.clear(); // Clear the text field
|
||||
geographicalZone = ''; // Reset the geographical zone state
|
||||
@@ -527,7 +546,6 @@ class _MyHomePageState extends State<ListItemMenu> {
|
||||
final startDate = DateTime.parse(post.startDate!);
|
||||
final date = DateFormat.yMd().format(startDate);
|
||||
final time = DateFormat.Hm().format(startDate);
|
||||
|
||||
return ListTile(
|
||||
title: Text('${post.name!}'),
|
||||
subtitle: Text('${post.place!}\n${date} ${time}'),
|
||||
|
Reference in New Issue
Block a user