diff --git a/covas_mobile/android/app/src/main/AndroidManifest.xml b/covas_mobile/android/app/src/main/AndroidManifest.xml
index 289462e..71290e3 100644
--- a/covas_mobile/android/app/src/main/AndroidManifest.xml
+++ b/covas_mobile/android/app/src/main/AndroidManifest.xml
@@ -1,5 +1,7 @@
+
+
+
diff --git a/covas_mobile/android/app/src/profile/AndroidManifest.xml b/covas_mobile/android/app/src/profile/AndroidManifest.xml
index 6e10330..323e1c6 100644
--- a/covas_mobile/android/app/src/profile/AndroidManifest.xml
+++ b/covas_mobile/android/app/src/profile/AndroidManifest.xml
@@ -5,4 +5,16 @@
to allow setting breakpoints, to provide hot reload, etc.
-->
+
+
+
+
+
+
+
+
diff --git a/covas_mobile/ios/Runner/Info.plist b/covas_mobile/ios/Runner/Info.plist
index cf192c9..436567c 100644
--- a/covas_mobile/ios/Runner/Info.plist
+++ b/covas_mobile/ios/Runner/Info.plist
@@ -45,5 +45,7 @@
CADisableMinimumFrameDurationOnPhone
+ NSLocationWhenInUseUsageDescription
+ Your location is needed for showing nearby events
diff --git a/covas_mobile/lib/main.dart b/covas_mobile/lib/main.dart
index 1db7c0d..be4b083 100644
--- a/covas_mobile/lib/main.dart
+++ b/covas_mobile/lib/main.dart
@@ -11,6 +11,7 @@ import 'pages/ListItemMenu.dart';
import 'classes/alert.dart';
import 'variable/globals.dart' as globals;
+import 'package:permission_handler/permission_handler.dart';
void main() {
runApp(MyApp());
@@ -153,10 +154,49 @@ class _LoginDemoState extends State with ShowErrorDialog {
@override
void initState() {
+ _checkLocationPermission();
start();
super.initState();
}
+ Future _checkLocationPermission() async {
+ PermissionStatus status = await Permission.location.status;
+
+ if (status.isGranted) {
+ print("Location permission granted");
+ } else if (status.isDenied) {
+ print("Location permission denied");
+ _requestLocationPermission();
+ } else if (status.isPermanentlyDenied) {
+ print("Location permission permanently denied");
+ openAppSettings();
+ }
+ }
+
+ // Request location permission
+ Future _requestLocationPermission() async {
+ PermissionStatus status = await Permission.location.request();
+
+ if (status.isGranted) {
+ print("Location permission granted");
+ } else if (status.isDenied) {
+ print("Location permission denied");
+ } else if (status.isPermanentlyDenied) {
+ print("Location permission permanently denied");
+ openAppSettings();
+ }
+ }
+
+ // Open app settings to allow user to grant permission manually
+ Future _openAppSettings() async {
+ bool opened = await openAppSettings();
+ if (opened) {
+ print("App settings opened");
+ } else {
+ print("Failed to open app settings");
+ }
+ }
+
@override
Widget build(BuildContext context) {
return Scaffold(
diff --git a/covas_mobile/lib/pages/DisplayPictureScreen.dart b/covas_mobile/lib/pages/DisplayPictureScreen.dart
index 0c6d18a..32413a6 100644
--- a/covas_mobile/lib/pages/DisplayPictureScreen.dart
+++ b/covas_mobile/lib/pages/DisplayPictureScreen.dart
@@ -85,37 +85,43 @@ class DisplayPictureScreenState extends State
}
Future searchEvents(String json, String imagePath) async {
- print(json);
+ print(json.replaceAll("'''json", '').replaceAll("'''", ""));
SharedPreferences prefs = await SharedPreferences.getInstance();
+ try {
+ Map jsonData =
+ jsonDecode(json.replaceAll("```json", '').replaceAll("```", ""));
+ print("json : ${jsonData}");
+ var name = jsonData["name"];
+ print("name : ${name}");
+ var place = jsonData["place"];
+ var accessToken = prefs.getString("access_token") ?? "";
- Map jsonData = jsonDecode(json);
- var name = jsonData["name"];
- var place = jsonData["place"];
- var accessToken = prefs.getString("access_token") ?? "";
+ if (accessToken.isNotEmpty) {
+ var urlGet = Uri.parse("${globals.api}/events?name=${name}");
- if (accessToken.isNotEmpty) {
- var urlGet = Uri.parse("${globals.api}/events?name=${name}");
-
- var responseGet = await http.get(urlGet,
- headers: {HttpHeaders.cookieHeader: 'access_token=${accessToken}'});
- if (responseGet.statusCode == 200) {
- var events = jsonDecode(utf8.decode(responseGet.bodyBytes));
- print("reponse http : ${events.length}");
- if (events.length == 0) {
- Navigator.push(
- context,
- MaterialPageRoute(
- builder: (_) => UpdateeventImage(
- events: jsonData, imagePath: imagePath)));
- } else {
- Navigator.push(
- context,
- MaterialPageRoute(
- builder: (_) => ItemMenu(title: events[0]["id"])));
+ var responseGet = await http.get(urlGet,
+ headers: {HttpHeaders.cookieHeader: 'access_token=${accessToken}'});
+ if (responseGet.statusCode == 200) {
+ var events = jsonDecode(utf8.decode(responseGet.bodyBytes));
+ print("reponse http : ${events.length}");
+ if (events.length == 0) {
+ Navigator.push(
+ context,
+ MaterialPageRoute(
+ builder: (_) => UpdateeventImage(
+ events: jsonData, imagePath: imagePath)));
+ } else {
+ Navigator.push(
+ context,
+ MaterialPageRoute(
+ builder: (_) => ItemMenu(title: events[0]["id"])));
+ }
}
+ } else {
+ showErrorDialog(context, "Erreur de token");
}
- } else {
- showErrorDialog(context, "Erreur de token");
+ } catch (e) {
+ showErrorDialog(context, "Erreur de format de donnée fourni par l'IA");
}
//showDescImageAddDialog(context, message);
@@ -132,7 +138,7 @@ class DisplayPictureScreenState extends State
gemini
.textAndImage(
text:
- "Peux-tu donner le nom, la date avec l'année actuelle ou d'une année future proche et le lieu de l'évènement sous format JSON avec les valeurs suivantes : name, address, city, zip_code, country, description, tags (tableau sans espace), organizers (tableau), start_date et end_date sous le format en YYYY-MM-DD HH:mm:ssZ, et sans la présence du mot json dans la chaîne de caractère",
+ "Peux-tu donner le nom, la date avec l'année actuelle ou d'une année future proche et le lieu de l'évènement sous format JSON (sans le caratère json au début de la chaine de caractère) avec les valeurs suivantes : name, place, description, tags (tableau sans espace), organizers (tableau), start_date et end_date (si le end_date est vide, alors donnez une valeur de six de plus par rapport à start_date) sous le format en YYYY-MM-DD HH:mm:ssZ",
images: [file.readAsBytesSync()],
modelName: "models/gemini-1.5-pro-latest")
.then((value) => searchEvents(
diff --git a/covas_mobile/lib/pages/ListItemMenu.dart b/covas_mobile/lib/pages/ListItemMenu.dart
index 2f31a10..c280419 100644
--- a/covas_mobile/lib/pages/ListItemMenu.dart
+++ b/covas_mobile/lib/pages/ListItemMenu.dart
@@ -1,21 +1,23 @@
+import 'package:flutter/material.dart';
+import 'package:http/http.dart' as http;
+import 'package:flutter_dotenv/flutter_dotenv.dart'; // Import dotenv
import 'dart:convert';
import 'dart:io';
-import "ItemMenu.dart";
-import "Camera.dart";
-
-import 'package:http/http.dart' as http;
-import 'package:flutter/material.dart';
+import 'ItemMenu.dart';
+import 'SearchDelegate.dart';
import '../classes/events.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:intl/intl.dart';
import 'package:intl/date_symbol_data_local.dart';
+import 'dart:math';
+import 'package:geolocator/geolocator.dart';
+import '../variable/globals.dart' as globals;
+import 'package:permission_handler/permission_handler.dart';
+import "Camera.dart";
import 'package:camera/camera.dart';
-import '../variable/globals.dart' as globals;
-
-// app starting point
void main() {
- initializeDateFormatting("fr_FR", null).then((_) => (const MyApp()));
+ initializeDateFormatting("fr_FR", null).then((_) => runApp(const MyApp()));
}
class MyApp extends StatelessWidget {
@@ -30,7 +32,6 @@ class MyApp extends StatelessWidget {
}
}
-// homepage class
class ListItemMenu extends StatefulWidget {
const ListItemMenu({super.key});
@@ -38,13 +39,62 @@ class ListItemMenu extends StatefulWidget {
State createState() => _MyHomePageState();
}
-// homepage state
class _MyHomePageState extends State {
- // variable to call and store future list of posts
Future> postsFuture = getPosts();
+ List filteredPosts = [];
+ String geographicalZone = '';
+ String query = '';
+ List