ItemMenu 100%

This commit is contained in:
2025-07-26 19:23:59 +02:00
parent b48483c9f0
commit b4b0199fc2
3 changed files with 44 additions and 22 deletions

View File

@@ -94,5 +94,11 @@
"email_sent": "Email has been sent", "email_sent": "Email has been sent",
"forgot_password": "Forgot password", "forgot_password": "Forgot password",
"enter_email": "Enter the email", "enter_email": "Enter the email",
"send_email": "Send email" "send_email": "Send email",
"invalid_cache": "Invalid cache",
"item_date": "Date : ",
"item_maps": "Maps : ",
"item_organizer": "Organizer : ",
"item_description": "Description : ",
"item_tags": "Tags : "
} }

View File

@@ -94,5 +94,11 @@
"email_sent": "Email a été envoyé", "email_sent": "Email a été envoyé",
"forgot_password": "Mot de passe oublié", "forgot_password": "Mot de passe oublié",
"enter_email": "Entrez l'email", "enter_email": "Entrez l'email",
"send_email": "Send email" "send_email": "Send email",
"invalid_cache": "Cache invalide",
"item_date": "Date : ",
"item_maps": "Carte : ",
"item_organizer": "Organisateurs : ",
"item_description": "Description : ",
"item_tags": "Tags : "
} }

View File

@@ -25,6 +25,11 @@ import '../classes/ad_helper.dart';
import 'package:google_mobile_ads/google_mobile_ads.dart'; import 'package:google_mobile_ads/google_mobile_ads.dart';
import '../classes/auth_service.dart'; import '../classes/auth_service.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:provider/provider.dart';
import '../locale_provider.dart'; //
void main() async { void main() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
await MobileAds.instance.initialize(); await MobileAds.instance.initialize();
@@ -109,7 +114,8 @@ class _ItemMenuState extends State<ItemMenu> with ShowAlertDialog {
final accessToken = prefs.getString("access_token") ?? ""; final accessToken = prefs.getString("access_token") ?? "";
if (accessToken.isEmpty) { if (accessToken.isEmpty) {
showAlertDialog(context, "Erreur serveur", "Cache invalide"); showAlertDialog(context, AppLocalizations.of(context)?.error ?? "Error",
AppLocalizations.of(context)?.invalid_cache ?? "Invalid cache");
return; return;
} }
@@ -119,11 +125,8 @@ class _ItemMenuState extends State<ItemMenu> with ShowAlertDialog {
headers: {HttpHeaders.cookieHeader: 'access_token=$accessToken'}, headers: {HttpHeaders.cookieHeader: 'access_token=$accessToken'},
); );
stderr.writeln('Response Get status: ${responseGet.statusCode}');
if (responseGet.statusCode == 200) { if (responseGet.statusCode == 200) {
final responseBody = utf8.decode(responseGet.bodyBytes); final responseBody = utf8.decode(responseGet.bodyBytes);
stderr.writeln('Username : $responseBody');
final event = Events.fromJson(jsonDecode(responseBody)); final event = Events.fromJson(jsonDecode(responseBody));
@@ -147,18 +150,23 @@ class _ItemMenuState extends State<ItemMenu> with ShowAlertDialog {
tags = List<String>.from(event.tags ?? []); tags = List<String>.from(event.tags ?? []);
}); });
} else { } else {
final errorMessages = { final messages = {
400: "Requête mal construite", 400: AppLocalizations.of(context)?.request_error ??
406: "Mot de passe incorrect", "Poorly constructed query",
404: "Utilisateur inconnu", 406: AppLocalizations.of(context)?.incorrect_password ??
403: "Vous n'avez pas l'autorisation de faire cette action", "Incorrect password",
410: "Token invalide", 404: AppLocalizations.of(context)?.unknown_user ?? "Unknown user",
500: "Problème interne du serveur", 403: AppLocalizations.of(context)?.disabled_user ?? "Disabled user",
410: AppLocalizations.of(context)?.invalid_token ?? "Invalid token",
500: AppLocalizations.of(context)?.internal_error_server ??
"Internal error server"
}; };
final errorMessage = errorMessages[responseGet.statusCode] ?? final errorMessage = messages[responseGet.statusCode] ??
"Problème d'authentification inconnu"; AppLocalizations.of(context)?.unknown_error_auth ??
showAlertDialog(context, "Erreur serveur", errorMessage); "Unknown error auth";
showAlertDialog(context, AppLocalizations.of(context)?.error ?? "Error",
errorMessage);
} }
} }
@@ -223,7 +231,7 @@ class _ItemMenuState extends State<ItemMenu> with ShowAlertDialog {
Row(children: [ Row(children: [
Icon(Icons.event), Icon(Icons.event),
Text( Text(
"Date : ", AppLocalizations.of(context)?.item_date ?? "Date : ",
style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.bold), style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.bold),
) )
]), ]),
@@ -237,7 +245,7 @@ class _ItemMenuState extends State<ItemMenu> with ShowAlertDialog {
Row(children: [ Row(children: [
Icon(Icons.explore), Icon(Icons.explore),
Text( Text(
"Carte : ", AppLocalizations.of(context)?.item_maps ?? "Maps : ",
style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.bold), style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.bold),
) )
]), ]),
@@ -260,7 +268,7 @@ class _ItemMenuState extends State<ItemMenu> with ShowAlertDialog {
Row(children: [ Row(children: [
Icon(Icons.group), Icon(Icons.group),
Text( Text(
"Organisateurs : ", AppLocalizations.of(context)?.item_organizer ?? "Organizers : ",
style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.bold), style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.bold),
) )
]), ]),
@@ -313,7 +321,9 @@ class _ItemMenuState extends State<ItemMenu> with ShowAlertDialog {
]), ]),
Row(children: [ Row(children: [
Icon(Icons.description), Icon(Icons.description),
Text("Description : ", Text(
AppLocalizations.of(context)?.item_description ??
"Description : ",
style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.bold)) style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.bold))
]), ]),
Row(children: [ Row(children: [
@@ -325,7 +335,7 @@ class _ItemMenuState extends State<ItemMenu> with ShowAlertDialog {
]), ]),
Row(children: [ Row(children: [
Icon(Icons.category), Icon(Icons.category),
Text("Tags : ", Text(AppLocalizations.of(context)?.item_tags ?? "Tags : ",
style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.bold)) style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.bold))
]), ]),
Row( Row(
@@ -394,7 +404,7 @@ class _ItemMenuState extends State<ItemMenu> with ShowAlertDialog {
); );
}, },
backgroundColor: Colors.blue, backgroundColor: Colors.blue,
tooltip: 'Recherche', tooltip: AppLocalizations.of(context)?.search ?? 'Search',
child: const Icon(Icons.edit, color: Colors.white), child: const Icon(Icons.edit, color: Colors.white),
), ),
); );