change alert message
This commit is contained in:
parent
938b677b6e
commit
43d77f778b
@ -1,10 +1,10 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
mixin ShowErrorDialog<T extends StatefulWidget> on State<T> {
|
mixin ShowAlertDialog<T extends StatefulWidget> on State<T> {
|
||||||
void showErrorDialog(BuildContext context, String text) {
|
void showAlertDialog(BuildContext context, String title, String text) {
|
||||||
// Create AlertDialog
|
// Create AlertDialog
|
||||||
AlertDialog dialog = AlertDialog(
|
AlertDialog dialog = AlertDialog(
|
||||||
title: Text("Error"),
|
title: Text(title),
|
||||||
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 ShowErrorDialog {
|
class _LoginDemoState extends State<LoginDemo> with ShowAlertDialog {
|
||||||
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 ShowErrorDialog {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
showErrorDialog(context, text);
|
showAlertDialog(context, "Erreur serveur", text);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showErrorDialog(context, "${e}");
|
showAlertDialog(context, "Erreur", "${e}");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showErrorDialog(context, "Champ vide");
|
showAlertDialog(context, "Erreur", "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, ShowErrorDialog, TickerProviderStateMixin {
|
with ShowDescImageAdd, ShowAlertDialog, 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}");
|
||||||
showErrorDialog(context,
|
showAlertDialog(context, 'Error IA',
|
||||||
"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,14 +119,15 @@ class DisplayPictureScreenState extends State<DisplayPictureScreen>
|
|||||||
builder: (_) => ItemMenu(title: events[0]["id"])));
|
builder: (_) => ItemMenu(title: events[0]["id"])));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showErrorDialog(context,
|
showAlertDialog(context, 'Erreur de reponse',
|
||||||
"response status code update : ${responseGet.statusCode}");
|
"response status code update : ${responseGet.statusCode}");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showErrorDialog(context, "Erreur de token");
|
showAlertDialog(context, "Erreur de reponse", "Erreur de token");
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showErrorDialog(context, "Erreur de format de donnée fourni par l'IA");
|
showAlertDialog(
|
||||||
|
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 ShowErrorDialog, ShowEventDialog {
|
with ShowAlertDialog, ShowEventDialog {
|
||||||
TextEditingController inputName = TextEditingController();
|
TextEditingController inputName = TextEditingController();
|
||||||
|
|
||||||
TextEditingController inputDate = TextEditingController();
|
TextEditingController inputDate = TextEditingController();
|
||||||
@ -208,7 +208,8 @@ 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) {
|
||||||
showErrorDialog(context, "Evenement deja existant");
|
showAlertDialog(
|
||||||
|
context, "Info evenement", "Evenement deja existant");
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -236,7 +237,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) {
|
||||||
showErrorDialog(context, "Image non posté");
|
showAlertDialog(context, "Erreur image", "Image non posté");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var body = json.decode(utf8.decode(res.bodyBytes));
|
var body = json.decode(utf8.decode(res.bodyBytes));
|
||||||
@ -306,22 +307,23 @@ class _EditEventState extends State<EditEvent>
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
showErrorDialog(context, text);
|
showAlertDialog(context, "Erreur serveur", text);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showErrorDialog(context, "Aucune donnée geographique");
|
showAlertDialog(
|
||||||
|
context, "Erreur serveur", "Aucune donnée geographique");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showErrorDialog(context, "Mapbox non accessible");
|
showAlertDialog(context, "Erreur serveur", "Mapbox non accessible");
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showErrorDialog(context, "${e}");
|
showAlertDialog(context, "Erreur serveur", "${e}");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showErrorDialog(context, "Champ vide");
|
showAlertDialog(context, "Erreur utilisateur", "Champ vide");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showErrorDialog(context, "Evenement non futur");
|
showAlertDialog(context, "Erreur evenement", "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 ShowErrorDialog {
|
class _ItemMenuState extends State<ItemMenu> with ShowAlertDialog {
|
||||||
String listUser = "";
|
String listUser = "";
|
||||||
String eventName = "";
|
String eventName = "";
|
||||||
String eventStartDate = "";
|
String eventStartDate = "";
|
||||||
@ -169,10 +169,10 @@ class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
showErrorDialog(context, text);
|
showAlertDialog(context, "Erreur serveur", text);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showErrorDialog(context, "Cache invalide");
|
showAlertDialog(context, "Erreur serveur", "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 ShowErrorDialog {
|
class _MapboxPagesState extends State<MapboxPages> with ShowAlertDialog {
|
||||||
late MapboxMapController mapController;
|
late MapboxMapController mapController;
|
||||||
late String mapboxAccessToken;
|
late String mapboxAccessToken;
|
||||||
List<LatLng> routeCoordinates = [];
|
List<LatLng> routeCoordinates = [];
|
||||||
@ -63,7 +63,8 @@ class _MapboxPagesState extends State<MapboxPages> with ShowErrorDialog {
|
|||||||
void _initToken() {
|
void _initToken() {
|
||||||
mapboxAccessToken = dotenv.env['MAPBOX_ACCESS_TOKEN'] ?? '';
|
mapboxAccessToken = dotenv.env['MAPBOX_ACCESS_TOKEN'] ?? '';
|
||||||
if (mapboxAccessToken.isEmpty) {
|
if (mapboxAccessToken.isEmpty) {
|
||||||
showErrorDialog(context, "Mapbox Access Token is not available.");
|
showAlertDialog(
|
||||||
|
context, "Erreur Mapbox", "Mapbox Access Token is not available.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +89,7 @@ class _MapboxPagesState extends State<MapboxPages> with ShowErrorDialog {
|
|||||||
_handleErrorResponse(responseGet.statusCode);
|
_handleErrorResponse(responseGet.statusCode);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showErrorDialog(context, "Invalid cache.");
|
showAlertDialog(context, "Erreur serveur", "Invalid cache.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,14 +117,15 @@ class _MapboxPagesState extends State<MapboxPages> with ShowErrorDialog {
|
|||||||
default:
|
default:
|
||||||
text = "Unknown error.";
|
text = "Unknown error.";
|
||||||
}
|
}
|
||||||
showErrorDialog(context, text);
|
showAlertDialog(context, "Erreur serveur", 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) {
|
||||||
showErrorDialog(context, "Location services are disabled.");
|
showAlertDialog(
|
||||||
|
context, "Erreur de service", "Location services are disabled.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,13 +133,14 @@ class _MapboxPagesState extends State<MapboxPages> with ShowErrorDialog {
|
|||||||
if (permission == LocationPermission.denied) {
|
if (permission == LocationPermission.denied) {
|
||||||
permission = await Geolocator.requestPermission();
|
permission = await Geolocator.requestPermission();
|
||||||
if (permission == LocationPermission.denied) {
|
if (permission == LocationPermission.denied) {
|
||||||
showErrorDialog(context, "Location permissions are denied.");
|
showAlertDialog(context, "Erreur de permission",
|
||||||
|
"Location permissions are denied.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (permission == LocationPermission.deniedForever) {
|
if (permission == LocationPermission.deniedForever) {
|
||||||
showErrorDialog(context,
|
showAlertDialog(context, "Erreur de permission",
|
||||||
"Location permissions are permanently denied. Enable them in settings.");
|
"Location permissions are permanently denied. Enable them in settings.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -171,7 +174,7 @@ class _MapboxPagesState extends State<MapboxPages> with ShowErrorDialog {
|
|||||||
_initToken();
|
_initToken();
|
||||||
_getEventInfo();
|
_getEventInfo();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showErrorDialog(context, "Failed to get user location: $e");
|
showAlertDialog(context, "Erreur geo", "Failed to get user location: $e");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,8 +194,8 @@ class _MapboxPagesState extends State<MapboxPages> with ShowErrorDialog {
|
|||||||
}).toList();
|
}).toList();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
showErrorDialog(
|
showAlertDialog(context, "Erreur serveur",
|
||||||
context, "Failed to fetch the route: ${response.statusCode}");
|
"Failed to fetch the route: ${response.statusCode}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,8 +247,8 @@ class _MapboxPagesState extends State<MapboxPages> with ShowErrorDialog {
|
|||||||
currentRouteLine = null;
|
currentRouteLine = null;
|
||||||
}
|
}
|
||||||
if (!isUserPositionInitialized) {
|
if (!isUserPositionInitialized) {
|
||||||
showErrorDialog(
|
showAlertDialog(context, "Erreur de position",
|
||||||
context, "User position is not yet initialized. Try again.");
|
"User position is not yet initialized. Try again.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,7 +287,8 @@ class _MapboxPagesState extends State<MapboxPages> with ShowErrorDialog {
|
|||||||
_zoomToFitRoute(routeCoordinates);
|
_zoomToFitRoute(routeCoordinates);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showErrorDialog(context, "Invalid coordinates or user position.");
|
showAlertDialog(context, "Erreur de coordonée",
|
||||||
|
"Invalid coordinates or user position.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ class UpdateeventImage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _UpdateeventImageState extends State<UpdateeventImage>
|
class _UpdateeventImageState extends State<UpdateeventImage>
|
||||||
with ShowErrorDialog, ShowEventDialog {
|
with ShowAlertDialog, 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)) {
|
||||||
showErrorDialog(context, "Evenement non futur");
|
showAlertDialog(context, "Erreur evenement", "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) {
|
||||||
showErrorDialog(context, "Token d'accès manquant");
|
showAlertDialog(context, "Erreur token", "Token d'accès manquant");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,13 +179,14 @@ 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) {
|
||||||
showErrorDialog(context, "Erreur lors de la géocodage avec Searchbox");
|
showAlertDialog(context, "Erreur map",
|
||||||
|
"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) {
|
||||||
showErrorDialog(context, "Lieu introuvable");
|
showAlertDialog(context, "Erreur", "Lieu introuvable");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,7 +230,8 @@ 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) {
|
||||||
showErrorDialog(context, "Erreur lors de l'upload d'image");
|
showAlertDialog(
|
||||||
|
context, "Erreur serveur", "Erreur lors de l'upload d'image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,7 +267,7 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
handleHttpError(eventResponse.statusCode, context);
|
handleHttpError(eventResponse.statusCode, context);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showErrorDialog(context, "Erreur: ${e.toString()}");
|
showAlertDialog(context, "Erreur", "Erreur: ${e.toString()}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,7 +281,8 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
410: "Token invalide",
|
410: "Token invalide",
|
||||||
500: "Problème interne du serveur",
|
500: "Problème interne du serveur",
|
||||||
};
|
};
|
||||||
showErrorDialog(context, errorMessages[statusCode] ?? "Erreur inconnue");
|
showAlertDialog(context, "Erreur serveur",
|
||||||
|
errorMessages[statusCode] ?? "Erreur inconnue");
|
||||||
}
|
}
|
||||||
|
|
||||||
void start() async {
|
void start() async {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user