|
|
|
@@ -18,6 +18,10 @@ import '../variable/globals.dart' as globals;
|
|
|
|
|
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();
|
|
|
|
@@ -104,7 +108,8 @@ class _EditProfileState extends State<EditProfile>
|
|
|
|
|
|
|
|
|
|
if ((password.isNotEmpty) && (confirmedPassword.isNotEmpty)) {
|
|
|
|
|
if (password != confirmedPassword) {
|
|
|
|
|
showAlertDialog(context, "Erreur", "Mot de passe different");
|
|
|
|
|
showAlertDialog(context, AppLocalizations.of(context)?.error ?? "Error",
|
|
|
|
|
"Mot de passe different");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -137,18 +142,22 @@ class _EditProfileState extends State<EditProfile>
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final errorMessages = {
|
|
|
|
|
400: "Requête mal construite",
|
|
|
|
|
406: "Mot de passe incorrect",
|
|
|
|
|
404: "Utilisateur inconnu",
|
|
|
|
|
403: "Utilisateur désactivé",
|
|
|
|
|
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"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
final text = errorMessages[responsePut.statusCode] ??
|
|
|
|
|
"Problème d'authentification inconnu";
|
|
|
|
|
showAlertDialog(context, "Erreur serveur", text);
|
|
|
|
|
final text = messages[responsePut.statusCode] ??
|
|
|
|
|
AppLocalizations.of(context)?.unknown_error_auth ??
|
|
|
|
|
"Unknown error auth";
|
|
|
|
|
showAlertDialog(
|
|
|
|
|
context, AppLocalizations.of(context)?.error ?? "Error", text);
|
|
|
|
|
} else {
|
|
|
|
|
Navigator.pushReplacement(
|
|
|
|
|
context, MaterialPageRoute(builder: (_) => LoginDemo()));
|
|
|
|
@@ -180,18 +189,22 @@ class _EditProfileState extends State<EditProfile>
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final errorMessages = {
|
|
|
|
|
400: "Requête mal construite",
|
|
|
|
|
406: "Mot de passe incorrect",
|
|
|
|
|
404: "Utilisateur inconnu",
|
|
|
|
|
403: "Utilisateur désactivé",
|
|
|
|
|
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"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
final text = errorMessages[responseGet.statusCode] ??
|
|
|
|
|
"Problème d'authentification inconnu";
|
|
|
|
|
showAlertDialog(context, "Erreur serveur", text);
|
|
|
|
|
final text = messages[responseGet.statusCode] ??
|
|
|
|
|
AppLocalizations.of(context)?.unknown_error_auth ??
|
|
|
|
|
"Unknown error auth";
|
|
|
|
|
showAlertDialog(
|
|
|
|
|
context, AppLocalizations.of(context)?.error ?? "Error", text);
|
|
|
|
|
} else {
|
|
|
|
|
Navigator.pushReplacement(
|
|
|
|
|
context, MaterialPageRoute(builder: (_) => LoginDemo()));
|
|
|
|
@@ -213,7 +226,9 @@ class _EditProfileState extends State<EditProfile>
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@@ -246,8 +261,9 @@ class _EditProfileState extends State<EditProfile>
|
|
|
|
|
validator: (value) => _validateField(value),
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
border: OutlineInputBorder(),
|
|
|
|
|
labelText: 'Pseudo',
|
|
|
|
|
hintText: 'Modifier le pseudo'),
|
|
|
|
|
labelText: AppLocalizations.of(context)?.name,
|
|
|
|
|
hintText: AppLocalizations.of(context)?.edit_pseudo ??
|
|
|
|
|
"Edit pseudo"),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Padding(
|
|
|
|
@@ -259,8 +275,11 @@ class _EditProfileState extends State<EditProfile>
|
|
|
|
|
obscureText: true,
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
border: OutlineInputBorder(),
|
|
|
|
|
labelText: 'Mot de passe',
|
|
|
|
|
hintText: 'Entrez le mot de passe'),
|
|
|
|
|
labelText: AppLocalizations.of(context)?.password ??
|
|
|
|
|
"Password",
|
|
|
|
|
hintText:
|
|
|
|
|
AppLocalizations.of(context)?.enter_password ??
|
|
|
|
|
"Enter a password"),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Padding(
|
|
|
|
@@ -272,8 +291,12 @@ class _EditProfileState extends State<EditProfile>
|
|
|
|
|
obscureText: true,
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
border: OutlineInputBorder(),
|
|
|
|
|
labelText: 'Confirmez le mot de passe',
|
|
|
|
|
hintText: 'Confirmez le mot de passe'),
|
|
|
|
|
labelText:
|
|
|
|
|
AppLocalizations.of(context)?.password_confirmed ??
|
|
|
|
|
"Must confirm password",
|
|
|
|
|
hintText:
|
|
|
|
|
AppLocalizations.of(context)?.password_confirmed ??
|
|
|
|
|
"Must confirm password"),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Padding(
|
|
|
|
@@ -285,8 +308,11 @@ class _EditProfileState extends State<EditProfile>
|
|
|
|
|
validator: (value) => _validateField(value),
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
border: OutlineInputBorder(),
|
|
|
|
|
labelText: 'Nom',
|
|
|
|
|
hintText: 'Modifier le nom'),
|
|
|
|
|
labelText: AppLocalizations.of(context)?.last_name ??
|
|
|
|
|
"Last name",
|
|
|
|
|
hintText:
|
|
|
|
|
AppLocalizations.of(context)?.edit_last_name ??
|
|
|
|
|
"Edit last name"),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Padding(
|
|
|
|
@@ -298,8 +324,11 @@ class _EditProfileState extends State<EditProfile>
|
|
|
|
|
validator: (value) => _validateField(value),
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
border: OutlineInputBorder(),
|
|
|
|
|
labelText: 'Prénom',
|
|
|
|
|
hintText: 'Modifier le prénom'),
|
|
|
|
|
labelText: AppLocalizations.of(context)?.first_name ??
|
|
|
|
|
"First name",
|
|
|
|
|
hintText:
|
|
|
|
|
AppLocalizations.of(context)?.edit_first_name ??
|
|
|
|
|
"Edit first name"),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Padding(
|
|
|
|
@@ -311,8 +340,10 @@ class _EditProfileState extends State<EditProfile>
|
|
|
|
|
validator: (value) => _validateField(value),
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
border: OutlineInputBorder(),
|
|
|
|
|
labelText: 'Email',
|
|
|
|
|
hintText: 'Modifier l\'adresse mail'),
|
|
|
|
|
labelText:
|
|
|
|
|
AppLocalizations.of(context)?.email ?? "Email",
|
|
|
|
|
hintText: AppLocalizations.of(context)?.edit_email ??
|
|
|
|
|
"Edit email"),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Padding(
|
|
|
|
@@ -325,8 +356,9 @@ class _EditProfileState extends State<EditProfile>
|
|
|
|
|
validator: (value) => _validateField(value),
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
border: OutlineInputBorder(),
|
|
|
|
|
labelText: 'Date de naissance',
|
|
|
|
|
hintText: 'Cliquez ici pour selectionner une date'),
|
|
|
|
|
labelText: AppLocalizations.of(context)?.birth_date,
|
|
|
|
|
hintText: AppLocalizations.of(context)?.edit_birth ??
|
|
|
|
|
"Click to select a birth date"),
|
|
|
|
|
onTap: () => onTapFunctionDatePicker(context: context)),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
@@ -345,7 +377,8 @@ class _EditProfileState extends State<EditProfile>
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
child: Text(
|
|
|
|
|
'Modifier le profil',
|
|
|
|
|
AppLocalizations.of(context)?.update_profile ??
|
|
|
|
|
"Update profile",
|
|
|
|
|
style: TextStyle(color: Colors.white, fontSize: 25),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|