translate updateevent 50%
This commit is contained in:
@@ -20,6 +20,11 @@ import '../classes/ad_helper.dart';
|
||||
import 'package:google_mobile_ads/google_mobile_ads.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 {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await MobileAds.instance.initialize();
|
||||
@@ -165,7 +170,8 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
var endDate = "${endDateFormat}T${endTimepicker.text.replaceAll('-', ':')}";
|
||||
|
||||
if (!startDateCompare.isAfter(dateNow)) {
|
||||
showAlertDialog(context, "Erreur evenement", "Evenement non futur");
|
||||
showAlertDialog(context, AppLocalizations.of(context)?.error ?? "Error",
|
||||
AppLocalizations.of(context)?.no_future_event ?? "No future event");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -173,7 +179,8 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
var accessToken = prefs.getString("access_token") ?? "";
|
||||
|
||||
if (accessToken.isEmpty) {
|
||||
showAlertDialog(context, "Erreur token", "Token d'accès manquant");
|
||||
showAlertDialog(context, AppLocalizations.of(context)?.error ?? "Error",
|
||||
"Token d'accès manquant");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -188,14 +195,15 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
final searchboxResponse = await http.get(searchboxUrl);
|
||||
|
||||
if (searchboxResponse.statusCode != 200) {
|
||||
showAlertDialog(context, "Erreur map",
|
||||
showAlertDialog(context, AppLocalizations.of(context)?.error ?? "Error",
|
||||
"Erreur lors de la géocodage avec Searchbox");
|
||||
return;
|
||||
}
|
||||
|
||||
final searchboxData = json.decode(searchboxResponse.body);
|
||||
if (searchboxData['results'].isEmpty) {
|
||||
showAlertDialog(context, "Erreur", "Lieu introuvable");
|
||||
showAlertDialog(context, AppLocalizations.of(context)?.error ?? "Error",
|
||||
"Lieu introuvable");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -239,8 +247,8 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
await http.Response.fromStream(await imgbbRequest.send());
|
||||
|
||||
if (imgbbResponse.statusCode != 200) {
|
||||
showAlertDialog(
|
||||
context, "Erreur serveur", "Erreur lors de l'upload d'image");
|
||||
showAlertDialog(context, AppLocalizations.of(context)?.error ?? "Error",
|
||||
"Erreur lors de l'upload d'image");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -276,22 +284,26 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
handleHttpError(eventResponse.statusCode, context);
|
||||
}
|
||||
} catch (e) {
|
||||
showAlertDialog(context, "Erreur", "Erreur: ${e.toString()}");
|
||||
showAlertDialog(context, AppLocalizations.of(context)?.error ?? "Error",
|
||||
"Erreur: ${e.toString()}");
|
||||
}
|
||||
}
|
||||
|
||||
// Utility function to handle HTTP errors
|
||||
void handleHttpError(int statusCode, BuildContext context) {
|
||||
final errorMessages = {
|
||||
400: "Requête mal construite",
|
||||
403: "Utilisateur désactivé",
|
||||
404: "Utilisateur inconnu",
|
||||
406: "Mot de passe incorrect",
|
||||
410: "Token invalide",
|
||||
500: "Problème interne du serveur",
|
||||
final messages = {
|
||||
400: AppLocalizations.of(context)?.request_error ??
|
||||
"Poorly constructed query",
|
||||
406: AppLocalizations.of(context)?.incorrect_password ??
|
||||
"Incorrect password",
|
||||
404: AppLocalizations.of(context)?.unknown_user ?? "Unknown user",
|
||||
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"
|
||||
};
|
||||
showAlertDialog(context, "Erreur serveur",
|
||||
errorMessages[statusCode] ?? "Erreur inconnue");
|
||||
showAlertDialog(context, AppLocalizations.of(context)?.error ?? "Error",
|
||||
messages[statusCode] ?? "Unknown error");
|
||||
}
|
||||
|
||||
void start() async {
|
||||
@@ -344,11 +356,9 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
|
||||
// Perform the request
|
||||
final response = await http.get(searchboxUrl);
|
||||
print("response code suggestion: ${response.statusCode}");
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final data = json.decode(response.body);
|
||||
print("data suggestion: ${data}");
|
||||
|
||||
setState(() {
|
||||
// Map the results to extract name and full_address
|
||||
@@ -432,7 +442,8 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
appBar: AppBar(
|
||||
title: Text("Add or Update a event"),
|
||||
title: Text(AppLocalizations.of(context)?.add_event ??
|
||||
"Add or Update a event"),
|
||||
backgroundColor: Colors.blue,
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
@@ -467,8 +478,10 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
validator: (value) => _validateField(value),
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Nom',
|
||||
hintText: 'Modifier le nom de l\'évènement'),
|
||||
labelText: AppLocalizations.of(context)?.name ?? "Name",
|
||||
hintText:
|
||||
AppLocalizations.of(context)?.edit_event_name ??
|
||||
"Edit event name"),
|
||||
),
|
||||
),
|
||||
_buildGeographicalZoneSearchField(),
|
||||
@@ -482,8 +495,10 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
validator: (value) => _validateField(value),
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Date de debut',
|
||||
hintText: 'Cliquez ici pour selectionner une date'),
|
||||
labelText: AppLocalizations.of(context)?.start_date ??
|
||||
"Start date",
|
||||
hintText: AppLocalizations.of(context)?.select_date ??
|
||||
"Click to select a date"),
|
||||
onTap: () => onTapFunctionDatePicker(
|
||||
context: context, position: "start")),
|
||||
),
|
||||
@@ -497,8 +512,10 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
validator: (value) => _validateField(value),
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Heure de debut',
|
||||
hintText: 'Cliquez ici pour selectionner une heure'),
|
||||
labelText: AppLocalizations.of(context)?.start_time ??
|
||||
"Start time",
|
||||
hintText: AppLocalizations.of(context)?.select_time ??
|
||||
"Click to select a time"),
|
||||
onTap: () => onTapFunctionTimePicker(
|
||||
context: context, position: "start")),
|
||||
),
|
||||
@@ -512,8 +529,10 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
validator: (value) => _validateField(value),
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Date de fin',
|
||||
hintText: 'Cliquez ici pour selectionner une date'),
|
||||
labelText: AppLocalizations.of(context)?.end_date ??
|
||||
"End date",
|
||||
hintText: AppLocalizations.of(context)?.select_date ??
|
||||
"Click to select a date"),
|
||||
onTap: () => onTapFunctionDatePicker(
|
||||
context: context, position: "end")),
|
||||
),
|
||||
@@ -527,8 +546,10 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
validator: (value) => _validateField(value),
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Heure de fin',
|
||||
hintText: 'Cliquez ici pour selectionner une heure'),
|
||||
labelText: AppLocalizations.of(context)?.end_time ??
|
||||
"End time",
|
||||
hintText: AppLocalizations.of(context)?.select_time ??
|
||||
"Click to select a time"),
|
||||
onTap: () => onTapFunctionTimePicker(
|
||||
context: context, position: "end")),
|
||||
),
|
||||
@@ -538,7 +559,8 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
textSeparators: const [' ', ','],
|
||||
validator: (String tag) {
|
||||
if (_stringTagController.getTags!.contains(tag)) {
|
||||
return 'Tu as deja rentre ce tag';
|
||||
return AppLocalizations.of(context)?.already_tag ??
|
||||
'You have already entered this tag';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
@@ -553,10 +575,12 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
onSubmitted: inputFieldValues.onTagSubmitted,
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Tags',
|
||||
labelText:
|
||||
AppLocalizations.of(context)?.tag ?? 'Tags',
|
||||
hintText: inputFieldValues.tags.isNotEmpty
|
||||
? ''
|
||||
: "Enter tag...",
|
||||
: AppLocalizations.of(context)?.enter_tag ??
|
||||
"Enter tag...",
|
||||
errorText: inputFieldValues.error,
|
||||
prefixIcon: inputFieldValues.tags.isNotEmpty
|
||||
? SingleChildScrollView(
|
||||
@@ -633,7 +657,9 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
textSeparators: const [','],
|
||||
validator: (String tag) {
|
||||
if (_stringOrgaController.getTags!.contains(tag)) {
|
||||
return 'Cet organisateur est déjà rentré';
|
||||
return AppLocalizations.of(context)
|
||||
?.already_organiser ??
|
||||
'You have already entered this organizer';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
@@ -648,10 +674,14 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
onSubmitted: inputFieldValues.onTagSubmitted,
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Organisateurs',
|
||||
labelText:
|
||||
AppLocalizations.of(context)?.organizer ??
|
||||
'Organizers',
|
||||
hintText: inputFieldValues.tags.isNotEmpty
|
||||
? ''
|
||||
: "Enter un organisateur...",
|
||||
: AppLocalizations.of(context)
|
||||
?.enter_organizer ??
|
||||
"Enter un organisateur...",
|
||||
errorText: inputFieldValues.error,
|
||||
prefixIcon: inputFieldValues.tags.isNotEmpty
|
||||
? SingleChildScrollView(
|
||||
@@ -732,8 +762,11 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
maxLines: 10,
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Description',
|
||||
hintText: 'Décrire l\'evènement'),
|
||||
labelText: AppLocalizations.of(context)?.description ??
|
||||
'Description',
|
||||
hintText:
|
||||
AppLocalizations.of(context)?.describe_event ??
|
||||
'Describe the event'),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
@@ -752,7 +785,7 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
'Ajouter',
|
||||
AppLocalizations.of(context)?.add_event ?? 'Add',
|
||||
style: TextStyle(color: Colors.white, fontSize: 25),
|
||||
),
|
||||
),
|
||||
|
Reference in New Issue
Block a user