|
|
|
@@ -179,8 +179,11 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|
|
|
|
var accessToken = prefs.getString("access_token") ?? "";
|
|
|
|
|
|
|
|
|
|
if (accessToken.isEmpty) {
|
|
|
|
|
showAlertDialog(context, AppLocalizations.of(context)?.error ?? "Error",
|
|
|
|
|
"Token d'accès manquant");
|
|
|
|
|
showAlertDialog(
|
|
|
|
|
context,
|
|
|
|
|
AppLocalizations.of(context)?.error ?? "Error",
|
|
|
|
|
AppLocalizations.of(context)?.missing_token ??
|
|
|
|
|
"Missing access token");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -195,15 +198,18 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|
|
|
|
final searchboxResponse = await http.get(searchboxUrl);
|
|
|
|
|
|
|
|
|
|
if (searchboxResponse.statusCode != 200) {
|
|
|
|
|
showAlertDialog(context, AppLocalizations.of(context)?.error ?? "Error",
|
|
|
|
|
"Erreur lors de la géocodage avec Searchbox");
|
|
|
|
|
showAlertDialog(
|
|
|
|
|
context,
|
|
|
|
|
AppLocalizations.of(context)?.error ?? "Error",
|
|
|
|
|
AppLocalizations.of(context)?.geocoding_error ??
|
|
|
|
|
"Error when geocoding");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final searchboxData = json.decode(searchboxResponse.body);
|
|
|
|
|
if (searchboxData['results'].isEmpty) {
|
|
|
|
|
showAlertDialog(context, AppLocalizations.of(context)?.error ?? "Error",
|
|
|
|
|
"Lieu introuvable");
|
|
|
|
|
AppLocalizations.of(context)?.no_found_place ?? "No found place");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -247,8 +253,11 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|
|
|
|
await http.Response.fromStream(await imgbbRequest.send());
|
|
|
|
|
|
|
|
|
|
if (imgbbResponse.statusCode != 200) {
|
|
|
|
|
showAlertDialog(context, AppLocalizations.of(context)?.error ?? "Error",
|
|
|
|
|
"Erreur lors de l'upload d'image");
|
|
|
|
|
showAlertDialog(
|
|
|
|
|
context,
|
|
|
|
|
AppLocalizations.of(context)?.error ?? "Error",
|
|
|
|
|
AppLocalizations.of(context)?.upload_error ??
|
|
|
|
|
"Error when image uploading");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -279,13 +288,15 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (eventResponse.statusCode == 200 || eventResponse.statusCode == 201) {
|
|
|
|
|
showEventDialog(context, "Événement $name ajouté");
|
|
|
|
|
String event_message =
|
|
|
|
|
AppLocalizations.of(context)?.event_added ?? "Event added";
|
|
|
|
|
showEventDialog(context, "$event_message : $name");
|
|
|
|
|
} else {
|
|
|
|
|
handleHttpError(eventResponse.statusCode, context);
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
showAlertDialog(context, AppLocalizations.of(context)?.error ?? "Error",
|
|
|
|
|
"Erreur: ${e.toString()}");
|
|
|
|
|
AppLocalizations.of(context)?.app_error ?? "Error application");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -302,8 +313,12 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|
|
|
|
500: AppLocalizations.of(context)?.internal_error_server ??
|
|
|
|
|
"Internal error server"
|
|
|
|
|
};
|
|
|
|
|
showAlertDialog(context, AppLocalizations.of(context)?.error ?? "Error",
|
|
|
|
|
messages[statusCode] ?? "Unknown error");
|
|
|
|
|
showAlertDialog(
|
|
|
|
|
context,
|
|
|
|
|
AppLocalizations.of(context)?.error ?? "Error",
|
|
|
|
|
messages[statusCode] ??
|
|
|
|
|
AppLocalizations.of(context)?.unknown_error ??
|
|
|
|
|
"Unknown error");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void start() async {
|
|
|
|
@@ -342,7 +357,9 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|
|
|
|
|
|
|
|
|
final _formKey = GlobalKey<FormState>();
|
|
|
|
|
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 {
|
|
|
|
@@ -384,7 +401,7 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|
|
|
|
TextField(
|
|
|
|
|
controller: inputGeo,
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
labelText: 'Lieu',
|
|
|
|
|
labelText: AppLocalizations.of(context)?.location ?? 'Location',
|
|
|
|
|
border: OutlineInputBorder(),
|
|
|
|
|
suffixIcon: IconButton(
|
|
|
|
|
icon: const Icon(Icons.clear),
|
|
|
|
|