translate editevent 50%
This commit is contained in:
parent
b4dc29aff6
commit
1df36987d9
@ -55,5 +55,16 @@
|
|||||||
"error_format": "Data format error given by AI",
|
"error_format": "Data format error given by AI",
|
||||||
"display_picture": "Display the Picture",
|
"display_picture": "Display the Picture",
|
||||||
"analyze_image": "Image Analyze in progress",
|
"analyze_image": "Image Analyze in progress",
|
||||||
"loading_progress": "Loading progress"
|
"loading_progress": "Loading progress",
|
||||||
|
"error_event": "Event error",
|
||||||
|
"no_future_event": "No future event",
|
||||||
|
"error_user": "Error user",
|
||||||
|
"empty_input": "Empty input",
|
||||||
|
"info_event": "Event info",
|
||||||
|
"event_already": "Event already exists",
|
||||||
|
"picture_error": "Picture error",
|
||||||
|
"no_picture_published": "No picture published",
|
||||||
|
"event_update": "Event updated",
|
||||||
|
"location": "Location",
|
||||||
|
"add_event": "Add or Update a event"
|
||||||
}
|
}
|
@ -55,6 +55,17 @@
|
|||||||
"error_format": "Erreur de format de donnée fourni par l'IA",
|
"error_format": "Erreur de format de donnée fourni par l'IA",
|
||||||
"display_picture": "Display the Picture",
|
"display_picture": "Display the Picture",
|
||||||
"analyze_image": "Analyse de l'image en cours",
|
"analyze_image": "Analyse de l'image en cours",
|
||||||
"loading_progress": "Chargement en cours"
|
"loading_progress": "Chargement en cours",
|
||||||
|
"error_event": "Erreur de l'évènement",
|
||||||
|
"no_future_event": "Évènement non futur",
|
||||||
|
"error_user": "Erreur de l'utilisateur",
|
||||||
|
"empty_input": "Champ vide",
|
||||||
|
"info_event": "Event info",
|
||||||
|
"event_already": "Event already exists",
|
||||||
|
"picture_error": "Erreur image",
|
||||||
|
"no_picture_published": "Image non publiée",
|
||||||
|
"event_update": "Évènement modifié",
|
||||||
|
"location": "Lieu",
|
||||||
|
"add_event": "Ajouter ou modifier un évènement"
|
||||||
|
|
||||||
}
|
}
|
@ -170,13 +170,19 @@ class _EditEventState extends State<EditEvent>
|
|||||||
|
|
||||||
Future<void> _updateEvent(BuildContext context) async {
|
Future<void> _updateEvent(BuildContext context) async {
|
||||||
if (!_isEventInFuture()) {
|
if (!_isEventInFuture()) {
|
||||||
_showErrorDialog(context, "Erreur evenement", "Evenement non futur");
|
_showErrorDialog(
|
||||||
|
context,
|
||||||
|
AppLocalizations.of(context)?.error_event ?? "Event error",
|
||||||
|
AppLocalizations.of(context)?.no_future_event ?? "No future event");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final accessToken = await _getAccessToken();
|
final accessToken = await _getAccessToken();
|
||||||
if (accessToken.isEmpty) {
|
if (accessToken.isEmpty) {
|
||||||
_showErrorDialog(context, "Erreur utilisateur", "Champ vide");
|
_showErrorDialog(
|
||||||
|
context,
|
||||||
|
AppLocalizations.of(context)?.error_user ?? "User error",
|
||||||
|
AppLocalizations.of(context)?.empty_input ?? "Empty input");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,27 +191,41 @@ class _EditEventState extends State<EditEvent>
|
|||||||
final geolocation = await _fetchGeolocation();
|
final geolocation = await _fetchGeolocation();
|
||||||
if (geolocation == null) {
|
if (geolocation == null) {
|
||||||
_showErrorDialog(
|
_showErrorDialog(
|
||||||
context, "Erreur serveur", "Aucune donnée geographique");
|
context,
|
||||||
|
AppLocalizations.of(context)?.error ?? "Error",
|
||||||
|
AppLocalizations.of(context)?.no_data_geo ??
|
||||||
|
"No geographical data");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await _isDuplicateEvent(accessToken, geolocation)) {
|
if (await _isDuplicateEvent(accessToken, geolocation)) {
|
||||||
_showErrorDialog(context, "Info evenement", "Evenement deja existant");
|
_showErrorDialog(
|
||||||
|
context,
|
||||||
|
AppLocalizations.of(context)?.info_event ?? "Event info",
|
||||||
|
AppLocalizations.of(context)?.event_already ??
|
||||||
|
"Event already exists");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (widget.imgPath.isNotEmpty) {
|
if (widget.imgPath.isNotEmpty) {
|
||||||
imgUrl = await _uploadImage(widget.imgPath);
|
imgUrl = await _uploadImage(widget.imgPath);
|
||||||
if (imgUrl.isEmpty) {
|
if (imgUrl.isEmpty) {
|
||||||
_showErrorDialog(context, "Erreur image", "Image non postée");
|
_showErrorDialog(
|
||||||
|
context,
|
||||||
|
AppLocalizations.of(context)?.picture_error ?? "Error picture",
|
||||||
|
AppLocalizations.of(context)?.no_picture_published ??
|
||||||
|
"No picture published");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await _updateEventData(accessToken, geolocation);
|
await _updateEventData(accessToken, geolocation);
|
||||||
showEventDialog(context, "Evenement ${inputName.text} modifie");
|
String message =
|
||||||
|
AppLocalizations.of(context)?.event_update ?? "Event updated";
|
||||||
|
showEventDialog(context, "${message} : ${inputName.text}");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
_showErrorDialog(context, "Erreur serveur", "$e");
|
_showErrorDialog(
|
||||||
|
context, AppLocalizations.of(context)?.error ?? "Error", "$e");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,15 +321,22 @@ class _EditEventState extends State<EditEvent>
|
|||||||
|
|
||||||
void _handleErrorResponse(BuildContext context, int statusCode) {
|
void _handleErrorResponse(BuildContext context, int statusCode) {
|
||||||
final messages = {
|
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: "Utilisateur désactivé",
|
"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"
|
||||||
};
|
};
|
||||||
_showErrorDialog(context, "Erreur serveur",
|
_showErrorDialog(
|
||||||
messages[statusCode] ?? "Problème d'authentification inconnu");
|
context,
|
||||||
|
AppLocalizations.of(context)?.error ?? "Error",
|
||||||
|
messages[statusCode] ??
|
||||||
|
AppLocalizations.of(context)?.unknown_error_auth ??
|
||||||
|
"Unknown error auth");
|
||||||
}
|
}
|
||||||
|
|
||||||
void _showErrorDialog(BuildContext context, String title, String message) {
|
void _showErrorDialog(BuildContext context, String title, String message) {
|
||||||
@ -353,7 +380,9 @@ class _EditEventState extends State<EditEvent>
|
|||||||
|
|
||||||
final _formKey = GlobalKey<FormState>();
|
final _formKey = GlobalKey<FormState>();
|
||||||
String? _validateField(String? value) {
|
String? _validateField(String? value) {
|
||||||
return value!.isEmpty ? 'Champ requis' : null;
|
return value!.isEmpty
|
||||||
|
? AppLocalizations.of(context)?.required_input ?? "Required input"
|
||||||
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> searchSuggestions(String input) async {
|
Future<void> searchSuggestions(String input) async {
|
||||||
@ -364,11 +393,9 @@ class _EditEventState extends State<EditEvent>
|
|||||||
'https://api.mapbox.com/geocoding/v5/mapbox.places/${input}.json?access_token=${mapboxAccessToken}&types=poi,address,place';
|
'https://api.mapbox.com/geocoding/v5/mapbox.places/${input}.json?access_token=${mapboxAccessToken}&types=poi,address,place';
|
||||||
var encoded = Uri.encodeFull(url);
|
var encoded = Uri.encodeFull(url);
|
||||||
final response = await http.get(Uri.parse(encoded));
|
final response = await http.get(Uri.parse(encoded));
|
||||||
print("response code suggesttion : ${response.statusCode}");
|
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
final data = json.decode(response.body);
|
final data = json.decode(response.body);
|
||||||
print("data suggestion : ${data}");
|
|
||||||
setState(() {
|
setState(() {
|
||||||
suggestions = (data['features'] as List)
|
suggestions = (data['features'] as List)
|
||||||
.map((feature) => {
|
.map((feature) => {
|
||||||
@ -393,7 +420,7 @@ class _EditEventState extends State<EditEvent>
|
|||||||
TextField(
|
TextField(
|
||||||
controller: inputGeo,
|
controller: inputGeo,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: 'Lieu',
|
labelText: AppLocalizations.of(context)?.location ?? "Location",
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
suffixIcon: IconButton(
|
suffixIcon: IconButton(
|
||||||
icon: const Icon(Icons.clear),
|
icon: const Icon(Icons.clear),
|
||||||
@ -463,7 +490,8 @@ class _EditEventState extends State<EditEvent>
|
|||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
drawer: MyDrawer(),
|
drawer: MyDrawer(),
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text("Add or Update a event"),
|
title: Text(AppLocalizations.of(context)?.add_event ??
|
||||||
|
"Add or Update a event"),
|
||||||
backgroundColor: Colors.blue,
|
backgroundColor: Colors.blue,
|
||||||
foregroundColor: Colors.white,
|
foregroundColor: Colors.white,
|
||||||
),
|
),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user