Compare commits

...

17 Commits

Author SHA1 Message Date
b4dc29aff6 translate displaypicturescreen 100% 2025-07-21 22:50:56 +02:00
79563e829c Add displaypicture 2025-07-18 19:38:10 +02:00
413807f039 Add camera dart 2025-07-18 19:06:38 +02:00
26372368b2 full translate for AddProfile pages 100% 2025-07-17 20:53:07 +02:00
f81a8c264c full translate for AddProfile pages 28% 2025-07-16 23:32:35 +02:00
c5985f2954 full translate for AddProfile pages 26% 2025-07-16 23:05:49 +02:00
1f8d18343c full translate for AddProfile pages 25% 2025-07-16 22:58:01 +02:00
c3b8b0df14 full translate for AddProfile pages 20% 2025-07-16 22:46:41 +02:00
ec8ce404ab full translate for AddProfile pages 16% 2025-07-16 22:08:08 +02:00
1208982b15 full translate for AddProfile pages 15% 2025-07-14 23:20:22 +02:00
479ab76fb7 full translate for AddProfile pages 10% 2025-07-14 22:53:34 +02:00
1646a0b6e3 full translate for ItemListMenu pages 50% 2025-07-09 23:33:04 +02:00
e21b03d13c full translate for ItemListMenu pages 2025-07-09 23:05:50 +02:00
45cdb253e4 internationlization wip 2025-07-06 20:59:57 +02:00
75b443758a changement de langue ok sur drawer 2025-07-02 22:35:53 +02:00
e2195e6500 change language ok 2025-07-02 22:03:51 +02:00
4f41aff572 change button language 2025-06-30 23:25:56 +02:00
14 changed files with 386 additions and 74 deletions

4
covas_mobile/l10n.yaml Normal file
View File

@ -0,0 +1,4 @@
arb-dir: lib/l10n
template-arb-file: app_en.arb
output-localization-file: app_localizations.dart
output-class: AppLocalizations

View File

@ -13,6 +13,10 @@ import '../pages/LoginDemo.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart'; // Import dotenv import 'package:flutter_dotenv/flutter_dotenv.dart'; // Import dotenv
import 'package:encrypt_shared_preferences/provider.dart'; import 'package:encrypt_shared_preferences/provider.dart';
import 'package:provider/provider.dart';
import '../locale_provider.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class MyDrawer extends StatelessWidget with ShowAlertDialog { class MyDrawer extends StatelessWidget with ShowAlertDialog {
Future<void> logout(BuildContext context) async { Future<void> logout(BuildContext context) async {
SharedPreferences prefs = await SharedPreferences.getInstance(); SharedPreferences prefs = await SharedPreferences.getInstance();
@ -87,6 +91,8 @@ class MyDrawer extends StatelessWidget with ShowAlertDialog {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final loc = AppLocalizations.of(context);
final localeProvider = Provider.of<LocaleProvider>(context);
return Drawer( return Drawer(
child: ListView( child: ListView(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
@ -107,7 +113,7 @@ class MyDrawer extends StatelessWidget with ShowAlertDialog {
// Drawer Items // Drawer Items
ListTile( ListTile(
leading: Icon(Icons.home), leading: Icon(Icons.home),
title: Text('Home'), title: Text(loc?.home ?? "Home"),
onTap: () { onTap: () {
Navigator.pushReplacement( Navigator.pushReplacement(
context, MaterialPageRoute(builder: (_) => ListItemMenu())); context, MaterialPageRoute(builder: (_) => ListItemMenu()));
@ -117,7 +123,7 @@ class MyDrawer extends StatelessWidget with ShowAlertDialog {
), ),
ListTile( ListTile(
leading: Icon(Icons.settings), leading: Icon(Icons.settings),
title: Text('Settings'), title: Text(loc?.settings ?? 'Settings'),
onTap: () { onTap: () {
Navigator.pushReplacement( Navigator.pushReplacement(
context, context,
@ -127,7 +133,7 @@ class MyDrawer extends StatelessWidget with ShowAlertDialog {
), ),
ListTile( ListTile(
leading: Icon(Icons.account_circle), leading: Icon(Icons.account_circle),
title: Text('Update profile'), title: Text(loc?.update_profile ?? 'Update profile'),
onTap: () { onTap: () {
Navigator.pushReplacement( Navigator.pushReplacement(
context, context,
@ -136,16 +142,52 @@ class MyDrawer extends StatelessWidget with ShowAlertDialog {
}, },
), ),
ListTile( ListTile(
leading: Icon(Icons.info), leading: Icon(Icons.language),
title: Text('About'), title: Text(loc?.language ?? 'Language'),
onTap: () { onTap: () {
showAlertDialog( showDialog(
context, 'About', "Version 0.0.1"); // Close the drawer context: context,
builder: (_) => AlertDialog(
title: Text(loc?.select_language ?? 'Select Language'),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
ListTile(
leading: Icon(Icons.flag),
title: Text(loc?.french ?? 'Français'),
onTap: () {
Provider.of<LocaleProvider>(context, listen: false)
.setLocale(const Locale('fr'));
Navigator.of(context).pop();
},
),
ListTile(
leading: Icon(Icons.flag_outlined),
title: Text(loc?.english ?? 'English'),
onTap: () {
Provider.of<LocaleProvider>(context, listen: false)
.setLocale(const Locale('en'));
Navigator.of(context).pop();
},
),
],
),
),
);
},
),
ListTile(
leading: Icon(Icons.info),
title: Text(loc?.about ?? 'About'),
onTap: () {
showAlertDialog(context, loc?.about ?? 'About',
"Version 0.0.1"); // Close the drawer
}, },
), ),
ListTile( ListTile(
leading: Icon(Icons.logout), leading: Icon(Icons.logout),
title: Text('Log out'), title: Text(loc?.log_out ?? 'Log out'),
onTap: () async { onTap: () async {
logout(context); logout(context);
// Close the drawer // Close the drawer

View File

@ -0,0 +1,59 @@
{
"@@locale": "en",
"menu_list": "Event list menu",
"language": "Language",
"home": "Home",
"settings": "Settings",
"update_profile": "Update profile",
"about": "About",
"log_out": "Log out",
"french": "French",
"english": "English",
"select_language": "Select language",
"search_item": "Search by item",
"search_tag": "Search by tags",
"search_geographical": "Search by geographical zone",
"show_date_field": "Show Date Fields",
"hide_date_field": "Hide Date Fields",
"no_data": "No data available",
"search": "Search",
"no_events": "No events available for this location.",
"start_date": "Start date",
"end_date": "End date",
"failed_suggestions": "Failed to load suggestions",
"error":"Error",
"password_different":"Must write a different password",
"create": "Creation",
"user_create": "Your user created",
"request_error": "Poorly constructed query",
"incorrect_password": "Incorrect password",
"unknown_user": "Unknown user",
"disabled_user": "User disabled",
"invalid_token": "Invalid token",
"internal_error_server": "Internal error server",
"unknown_error_auth": "Unknown error authentification",
"required_input": "Required input",
"create_profile": "Create profile",
"edit_pseudo": "Edit pseudo",
"password":"Password",
"enter_password": "Enter the passord",
"password_confirmed": "Password confirmed",
"last_name": "Last name",
"first_name": "First name",
"email": "Mail",
"edit_last_name": "Edit name",
"edit_first_name": "Edit first name",
"edit_email": "Edit email address",
"birth_date": "Birth date",
"edit_birth": "Edit birth date",
"create_profile_button": "Create profile",
"take_picture": "Take a picture",
"error_ia": "Google AI failed to analyze picture. Retry with another one",
"no_data_geo": "No geographical data",
"response_status_update": "response status code update",
"error_token": "Token error",
"error_format": "Data format error given by AI",
"display_picture": "Display the Picture",
"analyze_image": "Image Analyze in progress",
"loading_progress": "Loading progress"
}

View File

@ -0,0 +1,60 @@
{
"@@locale": "fr",
"menu_list": "Liste d'évènement",
"language": "Langue",
"home": "Accueil",
"settings": "Paramètres",
"update_profile": "Modifier profil",
"about": "À propos",
"log_out": "Se déconnecter",
"french": "Français",
"english": "Anglais",
"select_language": "Selectionne la langue",
"search_item": "Recherche par item",
"search_tag": "Recherche par tags",
"search_geographical": "Recherche par zone géographique",
"show_date_field": "Afficher champ date",
"hide_date_field": "Cacher Date Fields",
"no_data": "Aucune donnée disponible",
"search": "Recherche",
"no_events": "Pas d'évènements dans cette localisation",
"start_date": "Date de début",
"end_date": "Date de fin",
"failed_suggestions": "Echec de chargement des suggestions",
"error":"Erreur",
"password_different":"Tu dois écrire un mot de passe different",
"create": "Création",
"user_create": "Votre utilisateur a été créé",
"request_error": "Requête mal construite",
"incorrect_password": "Mot de passe incorrect",
"unknown_user": "Utilisateur inconnu",
"disabled_user": "Utilisateur désactivé",
"invalid_token": "Token invalide",
"internal_error_server": "Erreur interne de serveur",
"unknown_error_auth": "Problème d'authentification inconnu",
"required_input": "Champ requis",
"create_profile": "Creation profil",
"edit_pseudo": "Modifier le pseudo",
"password":"Mot de passe",
"enter_password": "Entrez le password",
"password_confirmed": "Confirmez le mot de passe",
"last_name": "Nom",
"first_name": "Prénom",
"email": "Email",
"edit_last_name": "Modifier le nom",
"edit_first_name": "Modifier le prénom",
"edit_email": "Modifier l'email",
"birth_date": "Date de naissance",
"edit_birth": "Modifier la date de naissance",
"create_profile_button": "Créer le profil",
"take_picture": "Take a picture",
"error_ia": "L'IA de Google n'a pas su analyser l'image. Recommencer avec une autre",
"no_data_geo": "Aucune donnée géographique",
"response_status_update": "Code du statut de réponse de la modification",
"error_token": "Erreur de token",
"error_format": "Erreur de format de donnée fourni par l'IA",
"display_picture": "Display the Picture",
"analyze_image": "Analyse de l'image en cours",
"loading_progress": "Chargement en cours"
}

View File

@ -0,0 +1,21 @@
import 'package:flutter/material.dart';
class LocaleProvider with ChangeNotifier {
Locale _locale = const Locale('en');
Locale get locale => _locale;
void setLocale(Locale locale) {
if (!L10n.all.contains(locale)) return;
_locale = locale;
notifyListeners();
}
}
class L10n {
static final all = [
const Locale('en'),
const Locale('fr'),
];
}

View File

@ -1,19 +1,36 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:google_mobile_ads/google_mobile_ads.dart'; import 'package:google_mobile_ads/google_mobile_ads.dart';
import 'package:provider/provider.dart';
import 'pages/LoginDemo.dart'; import 'pages/LoginDemo.dart';
import 'locale_provider.dart'; // <-- à adapter selon ton arborescence
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
void main() async { void main() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
await MobileAds.instance.initialize(); await MobileAds.instance.initialize();
runApp(MyApp()); runApp(
ChangeNotifierProvider(
create: (_) => LocaleProvider(),
child: MyApp(),
),
);
} }
class MyApp extends StatelessWidget { class MyApp extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final localeProvider = Provider.of<LocaleProvider>(
context); // écoute les changements de langue
return MaterialApp( return MaterialApp(
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,
locale: localeProvider.locale, // <-- utilise la locale courante
supportedLocales: const [
Locale('en'),
Locale('fr'),
],
localizationsDelegates: AppLocalizations.localizationsDelegates,
home: LoginDemo(), home: LoginDemo(),
); );
} }

View File

@ -13,6 +13,10 @@ import '../variable/globals.dart' as globals;
import '../classes/ad_helper.dart'; import '../classes/ad_helper.dart';
import 'package:google_mobile_ads/google_mobile_ads.dart'; import 'package:google_mobile_ads/google_mobile_ads.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'; // Créé plus loin
void main() async { void main() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
@ -95,7 +99,11 @@ class _AddProfileState extends State<AddProfile> with ShowAlertDialog {
if ((password.isNotEmpty) && (confirmedPassword.isNotEmpty)) { if ((password.isNotEmpty) && (confirmedPassword.isNotEmpty)) {
if (password != confirmedPassword) { if (password != confirmedPassword) {
showAlertDialog(context, "Erreur", "Mot de passe different"); showAlertDialog(
context,
AppLocalizations.of(context)?.error ?? "Error",
AppLocalizations.of(context)?.password_different ??
"Must write a different password");
return; return;
} }
} }
@ -117,24 +125,32 @@ class _AddProfileState extends State<AddProfile> with ShowAlertDialog {
})); }));
print(responsePost.statusCode); print(responsePost.statusCode);
if (responsePost.statusCode == 200) { if (responsePost.statusCode == 200) {
showAlertDialog(context, "Creation", "Votre utilisateur a été créé"); showAlertDialog(
context,
AppLocalizations.of(context)?.create ?? "Creation",
AppLocalizations.of(context)?.user_create ?? "Your user created");
Navigator.pushReplacement( Navigator.pushReplacement(
context, MaterialPageRoute(builder: (_) => LoginDemo())); context, MaterialPageRoute(builder: (_) => LoginDemo()));
return; return;
} }
final errorMessages = { final errorMessages = {
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"
}; };
final text = errorMessages[responsePost.statusCode] ?? final text = errorMessages[responsePost.statusCode] ??
"Problème d'authentification inconnu"; AppLocalizations.of(context)?.unknown_error_auth ??
showAlertDialog(context, "Erreur serveur", text); "Unknown error auth";
showAlertDialog(
context, AppLocalizations.of(context)?.error ?? "Error", text);
} }
@override @override
@ -150,7 +166,9 @@ class _AddProfileState extends State<AddProfile> with ShowAlertDialog {
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;
} }
@override @override
@ -158,7 +176,8 @@ class _AddProfileState extends State<AddProfile> with ShowAlertDialog {
return Scaffold( return Scaffold(
backgroundColor: Colors.white, backgroundColor: Colors.white,
appBar: AppBar( appBar: AppBar(
title: Text("Create profile"), title: Text(
AppLocalizations.of(context)?.create_profile ?? "Create profile"),
backgroundColor: Colors.blue, backgroundColor: Colors.blue,
foregroundColor: Colors.white, foregroundColor: Colors.white,
), ),
@ -183,7 +202,8 @@ class _AddProfileState extends State<AddProfile> with ShowAlertDialog {
decoration: InputDecoration( decoration: InputDecoration(
border: OutlineInputBorder(), border: OutlineInputBorder(),
labelText: 'Pseudo', labelText: 'Pseudo',
hintText: 'Modifier le pseudo'), hintText: AppLocalizations.of(context)?.edit_pseudo ??
'Edit pseudo'),
), ),
), ),
Padding( Padding(
@ -196,8 +216,11 @@ class _AddProfileState extends State<AddProfile> with ShowAlertDialog {
obscureText: true, obscureText: true,
decoration: InputDecoration( decoration: InputDecoration(
border: OutlineInputBorder(), border: OutlineInputBorder(),
labelText: 'Mot de passe', labelText: AppLocalizations.of(context)?.password ??
hintText: 'Entrez le mot de passe'), 'Password',
hintText:
AppLocalizations.of(context)?.enter_password ??
'Enter the password'),
), ),
), ),
Padding( Padding(
@ -209,9 +232,14 @@ class _AddProfileState extends State<AddProfile> with ShowAlertDialog {
validator: (value) => _validateField(value), validator: (value) => _validateField(value),
obscureText: true, obscureText: true,
decoration: InputDecoration( decoration: InputDecoration(
border: OutlineInputBorder(), border: OutlineInputBorder(),
labelText: 'Confirmez le mot de passe', labelText:
hintText: 'Confirmez le mot de passe'), AppLocalizations.of(context)?.password_confirmed ??
'Password confirmed',
hintText:
AppLocalizations.of(context)?.password_confirmed ??
'Password confirmed',
),
), ),
), ),
Padding( Padding(
@ -223,8 +251,11 @@ class _AddProfileState extends State<AddProfile> with ShowAlertDialog {
validator: (value) => _validateField(value), validator: (value) => _validateField(value),
decoration: InputDecoration( decoration: InputDecoration(
border: OutlineInputBorder(), border: OutlineInputBorder(),
labelText: 'Nom', labelText: AppLocalizations.of(context)?.last_name ??
hintText: 'Modifier le nom'), 'Last name',
hintText:
AppLocalizations.of(context)?.edit_last_name ??
'Edit last name'),
), ),
), ),
Padding( Padding(
@ -236,8 +267,11 @@ class _AddProfileState extends State<AddProfile> with ShowAlertDialog {
validator: (value) => _validateField(value), validator: (value) => _validateField(value),
decoration: InputDecoration( decoration: InputDecoration(
border: OutlineInputBorder(), border: OutlineInputBorder(),
labelText: 'Prénom', labelText: AppLocalizations.of(context)?.first_name ??
hintText: 'Modifier le prénom'), 'First name',
hintText:
AppLocalizations.of(context)?.edit_first_name ??
'Edit first name'),
), ),
), ),
Padding( Padding(
@ -249,8 +283,10 @@ class _AddProfileState extends State<AddProfile> with ShowAlertDialog {
validator: (value) => _validateField(value), validator: (value) => _validateField(value),
decoration: InputDecoration( decoration: InputDecoration(
border: OutlineInputBorder(), border: OutlineInputBorder(),
labelText: 'Email', labelText:
hintText: 'Modifier l\'adresse mail'), AppLocalizations.of(context)?.email ?? 'Email',
hintText: AppLocalizations.of(context)?.edit_email ??
'Edit email'),
), ),
), ),
Padding( Padding(
@ -263,8 +299,10 @@ class _AddProfileState extends State<AddProfile> with ShowAlertDialog {
validator: (value) => _validateField(value), validator: (value) => _validateField(value),
decoration: InputDecoration( decoration: InputDecoration(
border: OutlineInputBorder(), border: OutlineInputBorder(),
labelText: 'Date de naissance', labelText: AppLocalizations.of(context)?.birth_date ??
hintText: 'Cliquez ici pour selectionner une date'), 'Birth date',
hintText: AppLocalizations.of(context)?.edit_birth ??
'Edit birth date'),
onTap: () => onTapFunctionDatePicker(context: context)), onTap: () => onTapFunctionDatePicker(context: context)),
), ),
SizedBox( SizedBox(
@ -283,7 +321,8 @@ class _AddProfileState extends State<AddProfile> with ShowAlertDialog {
} }
}, },
child: Text( child: Text(
'Créer le profil', AppLocalizations.of(context)?.create_profile_button ??
"Create profile",
style: TextStyle(color: Colors.white, fontSize: 25), style: TextStyle(color: Colors.white, fontSize: 25),
), ),
), ),

View File

@ -7,6 +7,10 @@ import 'DisplayPictureScreen.dart';
import 'package:camera/camera.dart'; import 'package:camera/camera.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.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'; // Créé plus loin
Future<void> main() async { Future<void> main() async {
// Ensure that plugin services are initialized so that `availableCameras()` // Ensure that plugin services are initialized so that `availableCameras()`
@ -92,7 +96,9 @@ class CameraState extends State<Camera> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar(title: const Text('Take a picture')), appBar: AppBar(
title: Text(AppLocalizations.of(context)?.take_picture ??
"Take a picture")),
// You must wait until the controller is initialized before displaying the // You must wait until the controller is initialized before displaying the
// camera preview. Use a FutureBuilder to display a loading spinner until the // camera preview. Use a FutureBuilder to display a loading spinner until the
// controller has finished initializing. // controller has finished initializing.

View File

@ -8,6 +8,10 @@ import 'EditEvent.dart';
import 'package:camera/camera.dart'; import 'package:camera/camera.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.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'; // Créé
Future<void> main() async { Future<void> main() async {
// Ensure that plugin services are initialized so that `availableCameras()` // Ensure that plugin services are initialized so that `availableCameras()`
@ -94,7 +98,9 @@ class CameraEditState extends State<CameraEdit> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar(title: const Text('Take a picture')), appBar: AppBar(
title: Text(AppLocalizations.of(context)?.take_picture ??
'Take a picture')),
// You must wait until the controller is initialized before displaying the // You must wait until the controller is initialized before displaying the
// camera preview. Use a FutureBuilder to display a loading spinner until the // camera preview. Use a FutureBuilder to display a loading spinner until the
// controller has finished initializing. // controller has finished initializing.

View File

@ -17,6 +17,10 @@ import '../classes/MyDrawer.dart';
import '../classes/ad_helper.dart'; 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'; // Créé
void main() async { void main() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
@ -98,8 +102,11 @@ 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}");
showAlertDialog(context, 'Error IA', showAlertDialog(
"L'IA de Google n'a pas su analyser l'image. Recommecer avec une autre"); context,
AppLocalizations.of(context)?.error ?? 'Error',
AppLocalizations.of(context)?.error_ia ??
'Google AI failed to analyze picture. Retry with another one');
} }
void _showErrorDialog(BuildContext context, String title, String message) { void _showErrorDialog(BuildContext context, String title, String message) {
@ -154,7 +161,10 @@ class DisplayPictureScreenState extends State<DisplayPictureScreen>
final location = await _fetchGeolocation(place); final location = await _fetchGeolocation(place);
if (location == null) { if (location == 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;
} }
@ -181,15 +191,23 @@ class DisplayPictureScreenState extends State<DisplayPictureScreen>
builder: (_) => ItemMenu(title: events[0]["id"]))); builder: (_) => ItemMenu(title: events[0]["id"])));
} }
} else { } else {
showAlertDialog(context, 'Erreur de reponse', String error = AppLocalizations.of(context)?.response_status_update ??
"response status code update : ${response.statusCode}"); 'Response status update : ${response.statusCode}';
showAlertDialog(
context,
AppLocalizations.of(context)?.error ?? 'Error',
"${error} : ${response.statusCode}");
} }
} else { } else {
showAlertDialog(context, "Erreur de reponse", "Erreur de token"); showAlertDialog(context, AppLocalizations.of(context)?.error ?? 'Error',
AppLocalizations.of(context)?.error_token ?? "Token error");
} }
} catch (e) { } catch (e) {
showAlertDialog( showAlertDialog(
context, "Erreur IA", "Erreur de format de donnée fourni par l'IA"); context,
AppLocalizations.of(context)?.error ?? "Error",
AppLocalizations.of(context)?.error_format ??
"Data format error given by AI");
} }
//showDescImageAddDialog(context, message); //showDescImageAddDialog(context, message);
@ -217,7 +235,9 @@ class DisplayPictureScreenState extends State<DisplayPictureScreen>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar(title: const Text('Display the Picture')), appBar: AppBar(
title: Text(AppLocalizations.of(context)?.display_picture ??
"Display The Picture")),
// The image is stored as a file on the device. Use the `Image.file` // The image is stored as a file on the device. Use the `Image.file`
// constructor with the given path to display the image. // constructor with the given path to display the image.
drawer: MyDrawer(), drawer: MyDrawer(),
@ -233,12 +253,15 @@ class DisplayPictureScreenState extends State<DisplayPictureScreen>
width: _bannerAd!.size.width.toDouble(), width: _bannerAd!.size.width.toDouble(),
child: AdWidget(ad: _bannerAd!)), child: AdWidget(ad: _bannerAd!)),
Text( Text(
'Analyse de l\'image en cours', AppLocalizations.of(context)?.analyze_image ??
'Image analyze in progress',
style: Theme.of(context).textTheme.titleLarge, style: Theme.of(context).textTheme.titleLarge,
), ),
CircularProgressIndicator( CircularProgressIndicator(
value: controller.value, value: controller.value,
semanticsLabel: 'Loading progress', semanticsLabel:
AppLocalizations.of(context)?.loading_progress ??
'Loading progress',
), ),
]))); ])));
} }

View File

@ -22,6 +22,10 @@ import '../variable/globals.dart' as globals;
import '../classes/ad_helper.dart'; 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'; // Créé
void main() async { void main() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();

View File

@ -20,6 +20,9 @@ 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_localizations/flutter_localizations.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:provider/provider.dart';
import '../locale_provider.dart'; // Créé plus loin
void main() async { void main() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
@ -27,7 +30,10 @@ void main() async {
await MobileAds.instance.initialize(); await MobileAds.instance.initialize();
await initializeDateFormatting("fr_FR", null); await initializeDateFormatting("fr_FR", null);
runApp(const MyApp()); runApp(ChangeNotifierProvider(
create: (_) => LocaleProvider(),
child: const MyApp(),
));
} }
class MyApp extends StatelessWidget { class MyApp extends StatelessWidget {
@ -35,16 +41,17 @@ class MyApp extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final localeProvider = Provider.of<LocaleProvider>(context);
return MaterialApp( return MaterialApp(
localizationsDelegates: [ localizationsDelegates: [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate, GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate, GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate, GlobalCupertinoLocalizations.delegate,
], ],
supportedLocales: [ supportedLocales: [const Locale('fr', 'FR'), const Locale('en')],
const Locale('fr', 'FR'), locale: localeProvider.locale,
], home: Builder(builder: (context) => ListItemMenu()),
home: const ListItemMenu(),
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,
); );
} }
@ -296,7 +303,6 @@ class _MyHomePageState extends State<ListItemMenu> {
} }
} catch (e) { } catch (e) {
fetchPostsByLocation(); fetchPostsByLocation();
print("Error getting city and country: $e");
} }
} }
@ -347,7 +353,8 @@ class _MyHomePageState extends State<ListItemMenu> {
} }
}); });
} else { } else {
throw Exception('Failed to load suggestions'); throw Exception(AppLocalizations.of(context)?.failed_suggestions ??
'Failed to load suggestions');
} }
} }
@ -445,16 +452,13 @@ class _MyHomePageState extends State<ListItemMenu> {
"Content-Type": "application/json", "Content-Type": "application/json",
HttpHeaders.cookieHeader: "access_token=$accessToken" HttpHeaders.cookieHeader: "access_token=$accessToken"
}); });
print("status code tags : ${response.statusCode}");
if (response.statusCode == 200) { if (response.statusCode == 200) {
final data = json.decode(utf8.decode(response.bodyBytes)); final data = json.decode(utf8.decode(response.bodyBytes));
print("tags ${data}");
setState(() { setState(() {
suggestionsTags = (data as List) suggestionsTags = (data as List)
.map((feature) => {'name': feature['name']}) .map((feature) => {'name': feature['name']})
.toList(); .toList();
print("suggesttion tag : ${suggestionsTags}");
if (suggestionsTags.isNotEmpty) { if (suggestionsTags.isNotEmpty) {
showInputGeo = false; showInputGeo = false;
showInputSearch = false; showInputSearch = false;
@ -520,10 +524,10 @@ class _MyHomePageState extends State<ListItemMenu> {
Padding _buildDateField(String position) { Padding _buildDateField(String position) {
TextEditingController datePicker = startDatepicker; TextEditingController datePicker = startDatepicker;
String hintText = "Date de début"; String hintText = AppLocalizations.of(context)?.start_date ?? "Start date";
if (position == "end") { if (position == "end") {
datePicker = endDatepicker; datePicker = endDatepicker;
hintText = "Date de fin"; hintText = AppLocalizations.of(context)?.end_date ?? "End date";
} }
return Padding( return Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
@ -608,9 +612,11 @@ class _MyHomePageState extends State<ListItemMenu> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final loc = AppLocalizations.of(context);
final localeProvider = Provider.of<LocaleProvider>(context);
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: const Text("Item list menu"), title: Text(loc?.menu_list ?? "Item list menu"),
backgroundColor: Colors.blue, backgroundColor: Colors.blue,
foregroundColor: Colors.white, foregroundColor: Colors.white,
), ),
@ -627,7 +633,7 @@ class _MyHomePageState extends State<ListItemMenu> {
if (showInputSearch) if (showInputSearch)
_buildSearchField( _buildSearchField(
controller: inputItem, controller: inputItem,
labelText: 'Search by item', labelText: loc?.search_item ?? "Search by item",
onChanged: (value) { onChanged: (value) {
_fetchCount = 0; _fetchCount = 0;
if (value.isNotEmpty) { if (value.isNotEmpty) {
@ -673,7 +679,7 @@ class _MyHomePageState extends State<ListItemMenu> {
if ((showDateFields) && (showInputTag)) if ((showDateFields) && (showInputTag))
_buildSearchField( _buildSearchField(
controller: inputTags, controller: inputTags,
labelText: 'Search by tags', labelText: loc?.search_tag ?? "Search by tags",
onChanged: (value) { onChanged: (value) {
_fetchCount = 0; _fetchCount = 0;
if (value.isNotEmpty) { if (value.isNotEmpty) {
@ -724,7 +730,8 @@ class _MyHomePageState extends State<ListItemMenu> {
if ((showDateFields) && (showInputGeo)) if ((showDateFields) && (showInputGeo))
_buildSearchField( _buildSearchField(
controller: inputGeo, controller: inputGeo,
labelText: 'Search by geographical zone', labelText:
loc?.search_geographical ?? 'Search by geographical zone',
onChanged: (value) async { onChanged: (value) async {
_fetchCount = 0; _fetchCount = 0;
@ -795,21 +802,26 @@ class _MyHomePageState extends State<ListItemMenu> {
: Icons.keyboard_arrow_down, : Icons.keyboard_arrow_down,
color: Colors.blue, color: Colors.blue,
), ),
tooltip: showDateFields ? 'Show Date Fields' : 'Hide Date Fields', tooltip: showDateFields
? loc?.show_date_field ?? 'Show Date Fields'
: loc?.hide_date_field ?? 'Hide Date Fields',
), ),
Expanded( Expanded(
child: FutureBuilder<List<Events>>( child: FutureBuilder<List<Events>>(
future: postsFuture, future: postsFuture,
builder: (context, snapshot) { builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) { if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(child: CircularProgressIndicator()); return Center(child: CircularProgressIndicator());
} else if (snapshot.hasData) { } else if (snapshot.hasData) {
final posts = snapshot.data!; final posts = snapshot.data!;
final displayedPosts = final displayedPosts =
filteredPosts.isEmpty ? posts : filteredPosts; filteredPosts.isEmpty ? posts : filteredPosts;
return buildPosts(displayedPosts); return buildPosts(displayedPosts);
} else { } else {
return const Text("No data available"); return Center(
child: Text(AppLocalizations.of(context)?.no_data ??
"No data available"),
);
} }
}, },
), ),
@ -819,7 +831,7 @@ class _MyHomePageState extends State<ListItemMenu> {
floatingActionButton: FloatingActionButton( floatingActionButton: FloatingActionButton(
onPressed: popCamera, onPressed: popCamera,
backgroundColor: Colors.blue, backgroundColor: Colors.blue,
tooltip: 'Recherche', tooltip: loc?.search ?? 'Recherche',
child: const Icon(Icons.photo_camera, color: Colors.white), child: const Icon(Icons.photo_camera, color: Colors.white),
), ),
); );
@ -827,14 +839,13 @@ class _MyHomePageState extends State<ListItemMenu> {
// Function to display fetched data on screen // Function to display fetched data on screen
Widget buildPosts(List<Events> posts) { Widget buildPosts(List<Events> posts) {
print("posts : ${posts}");
print("filteredposts : ${filteredPosts}");
final displayedPosts = filteredPosts; final displayedPosts = filteredPosts;
print("results ${displayedPosts}");
// If filteredPosts is empty, show a message saying no data is available // If filteredPosts is empty, show a message saying no data is available
if (displayedPosts.isEmpty) { if (displayedPosts.isEmpty) {
return const Center( return Center(
child: Text('No events available for this location.', child: Text(
AppLocalizations.of(context)?.no_events ??
'No events available for this location.',
style: TextStyle(fontSize: 18, color: Colors.grey)), style: TextStyle(fontSize: 18, color: Colors.grey)),
); );
} }
@ -855,8 +866,11 @@ class _MyHomePageState extends State<ListItemMenu> {
final startDate = DateTime.parse(post.startDate!); final startDate = DateTime.parse(post.startDate!);
//final date = DateFormat.yMd().format(startDate); //final date = DateFormat.yMd().format(startDate);
//final time = DateFormat.Hm().format(startDate); //final time = DateFormat.Hm().format(startDate);
final locale =
Provider.of<LocaleProvider>(context).locale?.toString() ??
'en_US';
final dateLongue = final dateLongue =
DateFormat('EEEE d MMMM y', 'fr_FR').format(startDate); DateFormat('EEEE d MMMM y', locale).format(startDate);
return ListTile( return ListTile(
title: Text('${post.name!}'), title: Text('${post.name!}'),
subtitle: Text('${post.place!}\n${dateLongue}'), subtitle: Text('${post.place!}\n${dateLongue}'),

View File

@ -565,6 +565,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.0.6" version: "1.0.6"
nested:
dependency: transitive
description:
name: nested
sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20"
url: "https://pub.dev"
source: hosted
version: "1.0.0"
path: path:
dependency: "direct main" dependency: "direct main"
description: description:
@ -701,6 +709,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.9.1" version: "3.9.1"
provider:
dependency: "direct main"
description:
name: provider
sha256: "4abbd070a04e9ddc287673bf5a030c7ca8b685ff70218720abab8b092f53dd84"
url: "https://pub.dev"
source: hosted
version: "6.1.5"
shared_preferences: shared_preferences:
dependency: "direct main" dependency: "direct main"
description: description:

View File

@ -55,6 +55,7 @@ dependencies:
mapbox_gl: ^0.16.0 mapbox_gl: ^0.16.0
google_mobile_ads: ^5.3.1 google_mobile_ads: ^5.3.1
encrypt_shared_preferences: ^0.8.8 encrypt_shared_preferences: ^0.8.8
provider: ^6.1.2 # ou la dernière version
dev_dependencies: dev_dependencies:
flutter_test: flutter_test: