Compare commits
No commits in common. "8adcd803069d50b40a11360e9aa9084a9aa68f14" and "938b677b6ecc1ea5b189672bfd4074a3a6d59d59" have entirely different histories.
8adcd80306
...
938b677b6e
@ -1,7 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'alert.dart';
|
|
||||||
|
|
||||||
class MyDrawer extends StatelessWidget with ShowAlertDialog {
|
class MyDrawer extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Drawer(
|
return Drawer(
|
||||||
@ -40,8 +39,7 @@ class MyDrawer extends StatelessWidget with ShowAlertDialog {
|
|||||||
leading: Icon(Icons.info),
|
leading: Icon(Icons.info),
|
||||||
title: Text('About'),
|
title: Text('About'),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
showAlertDialog(
|
Navigator.pop(context); // Close the drawer
|
||||||
context, 'About', "Version 0.0.1"); // Close the drawer
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
mixin ShowAlertDialog {
|
mixin ShowErrorDialog<T extends StatefulWidget> on State<T> {
|
||||||
void showAlertDialog(BuildContext context, String title, String text) {
|
void showErrorDialog(BuildContext context, String text) {
|
||||||
// Create AlertDialog
|
// Create AlertDialog
|
||||||
AlertDialog dialog = AlertDialog(
|
AlertDialog dialog = AlertDialog(
|
||||||
title: Text(title),
|
title: Text("Error"),
|
||||||
content: Text(text),
|
content: Text(text),
|
||||||
actions: [
|
actions: [
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
|
@ -32,7 +32,7 @@ class LoginDemo extends StatefulWidget {
|
|||||||
_LoginDemoState createState() => _LoginDemoState();
|
_LoginDemoState createState() => _LoginDemoState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _LoginDemoState extends State<LoginDemo> with ShowAlertDialog {
|
class _LoginDemoState extends State<LoginDemo> with ShowErrorDialog {
|
||||||
TextEditingController inputPseudo = TextEditingController();
|
TextEditingController inputPseudo = TextEditingController();
|
||||||
TextEditingController inputPassword = TextEditingController();
|
TextEditingController inputPassword = TextEditingController();
|
||||||
Future<void> _login(BuildContext context) async {
|
Future<void> _login(BuildContext context) async {
|
||||||
@ -120,13 +120,13 @@ class _LoginDemoState extends State<LoginDemo> with ShowAlertDialog {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
showAlertDialog(context, "Erreur serveur", text);
|
showErrorDialog(context, text);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showAlertDialog(context, "Erreur", "${e}");
|
showErrorDialog(context, "${e}");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showAlertDialog(context, "Erreur", "Champ vide");
|
showErrorDialog(context, "Champ vide");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ class DisplayPictureScreen extends StatefulWidget {
|
|||||||
|
|
||||||
// A widget that displays the picture taken by the user.
|
// A widget that displays the picture taken by the user.
|
||||||
class DisplayPictureScreenState extends State<DisplayPictureScreen>
|
class DisplayPictureScreenState extends State<DisplayPictureScreen>
|
||||||
with ShowDescImageAdd, ShowAlertDialog, TickerProviderStateMixin {
|
with ShowDescImageAdd, ShowErrorDialog, TickerProviderStateMixin {
|
||||||
late AnimationController controller;
|
late AnimationController controller;
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -80,7 +80,7 @@ class DisplayPictureScreenState extends State<DisplayPictureScreen>
|
|||||||
|
|
||||||
Future<void> displayError(String e) async {
|
Future<void> displayError(String e) async {
|
||||||
print("problem gemini : ${e}");
|
print("problem gemini : ${e}");
|
||||||
showAlertDialog(context, 'Error IA',
|
showErrorDialog(context,
|
||||||
"L'IA de Google n'a pas su analyser l'image. Recommecer avec une autre");
|
"L'IA de Google n'a pas su analyser l'image. Recommecer avec une autre");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,15 +119,14 @@ class DisplayPictureScreenState extends State<DisplayPictureScreen>
|
|||||||
builder: (_) => ItemMenu(title: events[0]["id"])));
|
builder: (_) => ItemMenu(title: events[0]["id"])));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showAlertDialog(context, 'Erreur de reponse',
|
showErrorDialog(context,
|
||||||
"response status code update : ${responseGet.statusCode}");
|
"response status code update : ${responseGet.statusCode}");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showAlertDialog(context, "Erreur de reponse", "Erreur de token");
|
showErrorDialog(context, "Erreur de token");
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showAlertDialog(
|
showErrorDialog(context, "Erreur de format de donnée fourni par l'IA");
|
||||||
context, "Erreur IA", "Erreur de format de donnée fourni par l'IA");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//showDescImageAddDialog(context, message);
|
//showDescImageAddDialog(context, message);
|
||||||
|
@ -52,7 +52,7 @@ class EditEvent extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _EditEventState extends State<EditEvent>
|
class _EditEventState extends State<EditEvent>
|
||||||
with ShowAlertDialog, ShowEventDialog {
|
with ShowErrorDialog, ShowEventDialog {
|
||||||
TextEditingController inputName = TextEditingController();
|
TextEditingController inputName = TextEditingController();
|
||||||
|
|
||||||
TextEditingController inputDate = TextEditingController();
|
TextEditingController inputDate = TextEditingController();
|
||||||
@ -208,8 +208,7 @@ class _EditEventState extends State<EditEvent>
|
|||||||
var events = jsonDecode(utf8.decode(responseGet.bodyBytes));
|
var events = jsonDecode(utf8.decode(responseGet.bodyBytes));
|
||||||
if (events.length > 0) {
|
if (events.length > 0) {
|
||||||
if (events[0]["id"] != widget.events!.id) {
|
if (events[0]["id"] != widget.events!.id) {
|
||||||
showAlertDialog(
|
showErrorDialog(context, "Evenement deja existant");
|
||||||
context, "Info evenement", "Evenement deja existant");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -237,7 +236,7 @@ class _EditEventState extends State<EditEvent>
|
|||||||
final status = res.statusCode;
|
final status = res.statusCode;
|
||||||
print("code status imgbb ${status}");
|
print("code status imgbb ${status}");
|
||||||
if (status != 200) {
|
if (status != 200) {
|
||||||
showAlertDialog(context, "Erreur image", "Image non posté");
|
showErrorDialog(context, "Image non posté");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var body = json.decode(utf8.decode(res.bodyBytes));
|
var body = json.decode(utf8.decode(res.bodyBytes));
|
||||||
@ -307,23 +306,22 @@ class _EditEventState extends State<EditEvent>
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
showAlertDialog(context, "Erreur serveur", text);
|
showErrorDialog(context, text);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showAlertDialog(
|
showErrorDialog(context, "Aucune donnée geographique");
|
||||||
context, "Erreur serveur", "Aucune donnée geographique");
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showAlertDialog(context, "Erreur serveur", "Mapbox non accessible");
|
showErrorDialog(context, "Mapbox non accessible");
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showAlertDialog(context, "Erreur serveur", "${e}");
|
showErrorDialog(context, "${e}");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showAlertDialog(context, "Erreur utilisateur", "Champ vide");
|
showErrorDialog(context, "Champ vide");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showAlertDialog(context, "Erreur evenement", "Evenement non futur");
|
showErrorDialog(context, "Evenement non futur");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ class ItemMenu extends StatefulWidget {
|
|||||||
State<ItemMenu> createState() => _ItemMenuState();
|
State<ItemMenu> createState() => _ItemMenuState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ItemMenuState extends State<ItemMenu> with ShowAlertDialog {
|
class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
|
||||||
String listUser = "";
|
String listUser = "";
|
||||||
String eventName = "";
|
String eventName = "";
|
||||||
String eventStartDate = "";
|
String eventStartDate = "";
|
||||||
@ -169,10 +169,10 @@ class _ItemMenuState extends State<ItemMenu> with ShowAlertDialog {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
showAlertDialog(context, "Erreur serveur", text);
|
showErrorDialog(context, text);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showAlertDialog(context, "Erreur serveur", "Cache invalide");
|
showErrorDialog(context, "Cache invalide");
|
||||||
}
|
}
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
|
@ -42,7 +42,7 @@ class MapboxPages extends StatefulWidget {
|
|||||||
State<MapboxPages> createState() => _MapboxPagesState();
|
State<MapboxPages> createState() => _MapboxPagesState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MapboxPagesState extends State<MapboxPages> with ShowAlertDialog {
|
class _MapboxPagesState extends State<MapboxPages> with ShowErrorDialog {
|
||||||
late MapboxMapController mapController;
|
late MapboxMapController mapController;
|
||||||
late String mapboxAccessToken;
|
late String mapboxAccessToken;
|
||||||
List<LatLng> routeCoordinates = [];
|
List<LatLng> routeCoordinates = [];
|
||||||
@ -63,8 +63,7 @@ class _MapboxPagesState extends State<MapboxPages> with ShowAlertDialog {
|
|||||||
void _initToken() {
|
void _initToken() {
|
||||||
mapboxAccessToken = dotenv.env['MAPBOX_ACCESS_TOKEN'] ?? '';
|
mapboxAccessToken = dotenv.env['MAPBOX_ACCESS_TOKEN'] ?? '';
|
||||||
if (mapboxAccessToken.isEmpty) {
|
if (mapboxAccessToken.isEmpty) {
|
||||||
showAlertDialog(
|
showErrorDialog(context, "Mapbox Access Token is not available.");
|
||||||
context, "Erreur Mapbox", "Mapbox Access Token is not available.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +88,7 @@ class _MapboxPagesState extends State<MapboxPages> with ShowAlertDialog {
|
|||||||
_handleErrorResponse(responseGet.statusCode);
|
_handleErrorResponse(responseGet.statusCode);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showAlertDialog(context, "Erreur serveur", "Invalid cache.");
|
showErrorDialog(context, "Invalid cache.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,15 +116,14 @@ class _MapboxPagesState extends State<MapboxPages> with ShowAlertDialog {
|
|||||||
default:
|
default:
|
||||||
text = "Unknown error.";
|
text = "Unknown error.";
|
||||||
}
|
}
|
||||||
showAlertDialog(context, "Erreur serveur", text);
|
showErrorDialog(context, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _getUserLocation() async {
|
Future<void> _getUserLocation() async {
|
||||||
try {
|
try {
|
||||||
bool serviceEnabled = await Geolocator.isLocationServiceEnabled();
|
bool serviceEnabled = await Geolocator.isLocationServiceEnabled();
|
||||||
if (!serviceEnabled) {
|
if (!serviceEnabled) {
|
||||||
showAlertDialog(
|
showErrorDialog(context, "Location services are disabled.");
|
||||||
context, "Erreur de service", "Location services are disabled.");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,14 +131,13 @@ class _MapboxPagesState extends State<MapboxPages> with ShowAlertDialog {
|
|||||||
if (permission == LocationPermission.denied) {
|
if (permission == LocationPermission.denied) {
|
||||||
permission = await Geolocator.requestPermission();
|
permission = await Geolocator.requestPermission();
|
||||||
if (permission == LocationPermission.denied) {
|
if (permission == LocationPermission.denied) {
|
||||||
showAlertDialog(context, "Erreur de permission",
|
showErrorDialog(context, "Location permissions are denied.");
|
||||||
"Location permissions are denied.");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (permission == LocationPermission.deniedForever) {
|
if (permission == LocationPermission.deniedForever) {
|
||||||
showAlertDialog(context, "Erreur de permission",
|
showErrorDialog(context,
|
||||||
"Location permissions are permanently denied. Enable them in settings.");
|
"Location permissions are permanently denied. Enable them in settings.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -174,7 +171,7 @@ class _MapboxPagesState extends State<MapboxPages> with ShowAlertDialog {
|
|||||||
_initToken();
|
_initToken();
|
||||||
_getEventInfo();
|
_getEventInfo();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showAlertDialog(context, "Erreur geo", "Failed to get user location: $e");
|
showErrorDialog(context, "Failed to get user location: $e");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,8 +191,8 @@ class _MapboxPagesState extends State<MapboxPages> with ShowAlertDialog {
|
|||||||
}).toList();
|
}).toList();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
showAlertDialog(context, "Erreur serveur",
|
showErrorDialog(
|
||||||
"Failed to fetch the route: ${response.statusCode}");
|
context, "Failed to fetch the route: ${response.statusCode}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,8 +244,8 @@ class _MapboxPagesState extends State<MapboxPages> with ShowAlertDialog {
|
|||||||
currentRouteLine = null;
|
currentRouteLine = null;
|
||||||
}
|
}
|
||||||
if (!isUserPositionInitialized) {
|
if (!isUserPositionInitialized) {
|
||||||
showAlertDialog(context, "Erreur de position",
|
showErrorDialog(
|
||||||
"User position is not yet initialized. Try again.");
|
context, "User position is not yet initialized. Try again.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,8 +284,7 @@ class _MapboxPagesState extends State<MapboxPages> with ShowAlertDialog {
|
|||||||
_zoomToFitRoute(routeCoordinates);
|
_zoomToFitRoute(routeCoordinates);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showAlertDialog(context, "Erreur de coordonée",
|
showErrorDialog(context, "Invalid coordinates or user position.");
|
||||||
"Invalid coordinates or user position.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ class UpdateeventImage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _UpdateeventImageState extends State<UpdateeventImage>
|
class _UpdateeventImageState extends State<UpdateeventImage>
|
||||||
with ShowAlertDialog, ShowEventDialog {
|
with ShowErrorDialog, ShowEventDialog {
|
||||||
TextEditingController inputName = TextEditingController();
|
TextEditingController inputName = TextEditingController();
|
||||||
|
|
||||||
TextEditingController inputDate = TextEditingController();
|
TextEditingController inputDate = TextEditingController();
|
||||||
@ -156,7 +156,7 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
var endDate = "${endDateFormat}T${endTimepicker.text.replaceAll('-', ':')}";
|
var endDate = "${endDateFormat}T${endTimepicker.text.replaceAll('-', ':')}";
|
||||||
|
|
||||||
if (!startDateCompare.isAfter(dateNow)) {
|
if (!startDateCompare.isAfter(dateNow)) {
|
||||||
showAlertDialog(context, "Erreur evenement", "Evenement non futur");
|
showErrorDialog(context, "Evenement non futur");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
var accessToken = prefs.getString("access_token") ?? "";
|
var accessToken = prefs.getString("access_token") ?? "";
|
||||||
|
|
||||||
if (accessToken.isEmpty) {
|
if (accessToken.isEmpty) {
|
||||||
showAlertDialog(context, "Erreur token", "Token d'accès manquant");
|
showErrorDialog(context, "Token d'accès manquant");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,14 +179,13 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
final searchboxResponse = await http.get(searchboxUrl);
|
final searchboxResponse = await http.get(searchboxUrl);
|
||||||
|
|
||||||
if (searchboxResponse.statusCode != 200) {
|
if (searchboxResponse.statusCode != 200) {
|
||||||
showAlertDialog(context, "Erreur map",
|
showErrorDialog(context, "Erreur lors de la géocodage avec Searchbox");
|
||||||
"Erreur lors de la géocodage avec Searchbox");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final searchboxData = json.decode(searchboxResponse.body);
|
final searchboxData = json.decode(searchboxResponse.body);
|
||||||
if (searchboxData['results'].isEmpty) {
|
if (searchboxData['results'].isEmpty) {
|
||||||
showAlertDialog(context, "Erreur", "Lieu introuvable");
|
showErrorDialog(context, "Lieu introuvable");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,8 +229,7 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
await http.Response.fromStream(await imgbbRequest.send());
|
await http.Response.fromStream(await imgbbRequest.send());
|
||||||
|
|
||||||
if (imgbbResponse.statusCode != 200) {
|
if (imgbbResponse.statusCode != 200) {
|
||||||
showAlertDialog(
|
showErrorDialog(context, "Erreur lors de l'upload d'image");
|
||||||
context, "Erreur serveur", "Erreur lors de l'upload d'image");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,7 +265,7 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
handleHttpError(eventResponse.statusCode, context);
|
handleHttpError(eventResponse.statusCode, context);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showAlertDialog(context, "Erreur", "Erreur: ${e.toString()}");
|
showErrorDialog(context, "Erreur: ${e.toString()}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,8 +279,7 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
410: "Token invalide",
|
410: "Token invalide",
|
||||||
500: "Problème interne du serveur",
|
500: "Problème interne du serveur",
|
||||||
};
|
};
|
||||||
showAlertDialog(context, "Erreur serveur",
|
showErrorDialog(context, errorMessages[statusCode] ?? "Erreur inconnue");
|
||||||
errorMessages[statusCode] ?? "Erreur inconnue");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void start() async {
|
void start() async {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user