Add displaypicture

This commit is contained in:
Valentin CZERYBA 2025-07-18 19:38:10 +02:00
parent 413807f039
commit 79563e829c
4 changed files with 47 additions and 10 deletions

View File

@ -47,6 +47,13 @@
"birth_date": "Birth date",
"edit_birth": "Edit birth date",
"create_profile_button": "Create profile",
"take_picture": "Take a picture"
"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"
}

View File

@ -47,5 +47,11 @@
"birth_date": "Date de naissance",
"edit_birth": "Modifier la date de naissance",
"create_profile_button": "Créer le profil",
"take_picture": "Take a picture"
"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"
}

View File

@ -8,6 +8,10 @@ import 'EditEvent.dart';
import 'package:camera/camera.dart';
import 'package:flutter/material.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 {
// Ensure that plugin services are initialized so that `availableCameras()`
@ -94,7 +98,9 @@ class CameraEditState extends State<CameraEdit> {
@override
Widget build(BuildContext context) {
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
// camera preview. Use a FutureBuilder to display a loading spinner until the
// controller has finished initializing.

View File

@ -17,6 +17,10 @@ import '../classes/MyDrawer.dart';
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'; // Créé
void main() async {
WidgetsFlutterBinding.ensureInitialized();
@ -98,8 +102,11 @@ class DisplayPictureScreenState extends State<DisplayPictureScreen>
Future<void> displayError(String e) async {
print("problem gemini : ${e}");
showAlertDialog(context, 'Error IA',
"L'IA de Google n'a pas su analyser l'image. Recommecer avec une autre");
showAlertDialog(
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) {
@ -154,7 +161,10 @@ class DisplayPictureScreenState extends State<DisplayPictureScreen>
final location = await _fetchGeolocation(place);
if (location == null) {
_showErrorDialog(
context, "Erreur serveur", "Aucune donnée geographique");
context,
AppLocalizations.of(context)?.error ?? 'Error',
AppLocalizations.of(context)?.no_data_geo ??
'No geographical data');
return;
}
@ -181,15 +191,23 @@ class DisplayPictureScreenState extends State<DisplayPictureScreen>
builder: (_) => ItemMenu(title: events[0]["id"])));
}
} else {
showAlertDialog(context, 'Erreur de reponse',
"response status code update : ${response.statusCode}");
String error = AppLocalizations.of(context)?.response_status_update ??
'Response status update : ${response.statusCode}';
showAlertDialog(
context,
AppLocalizations.of(context)?.error ?? 'Error',
"${error} : ${response.statusCode}");
}
} 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) {
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);