refactor: Centralize error and notification handling using a dedicated _errorService across various components.
This commit is contained in:
@@ -502,11 +502,9 @@ class ProfileContent extends StatelessWidget {
|
||||
);
|
||||
|
||||
Navigator.of(dialogContext).pop();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('Profil mis à jour !'),
|
||||
backgroundColor: Colors.green,
|
||||
),
|
||||
_errorService.showSnackbar(
|
||||
message: 'Profil mis à jour !',
|
||||
isError: false,
|
||||
);
|
||||
}
|
||||
},
|
||||
@@ -668,11 +666,9 @@ class ProfileContent extends StatelessWidget {
|
||||
|
||||
if (context.mounted) {
|
||||
LoggerService.info('DEBUG: Affichage du succès');
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('Photo de profil mise à jour !'),
|
||||
backgroundColor: Colors.green,
|
||||
),
|
||||
_errorService.showSnackbar(
|
||||
message: 'Photo de profil mise à jour !',
|
||||
isError: false,
|
||||
);
|
||||
}
|
||||
} catch (e, stackTrace) {
|
||||
@@ -736,22 +732,16 @@ class ProfileContent extends StatelessWidget {
|
||||
if (currentPasswordController.text.isEmpty ||
|
||||
newPasswordController.text.isEmpty ||
|
||||
confirmPasswordController.text.isEmpty) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('Tous les champs sont requis'),
|
||||
backgroundColor: Colors.red,
|
||||
),
|
||||
_errorService.showError(
|
||||
message: 'Tous les champs sont requis',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (newPasswordController.text !=
|
||||
confirmPasswordController.text) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('Les mots de passe ne correspondent pas'),
|
||||
backgroundColor: Colors.red,
|
||||
),
|
||||
_errorService.showError(
|
||||
message: 'Les mots de passe ne correspondent pas',
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -765,11 +755,9 @@ class ProfileContent extends StatelessWidget {
|
||||
|
||||
if (context.mounted) {
|
||||
Navigator.of(dialogContext).pop();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('Mot de passe changé !'),
|
||||
backgroundColor: Colors.green,
|
||||
),
|
||||
_errorService.showSnackbar(
|
||||
message: 'Mot de passe changé !',
|
||||
isError: false,
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -823,11 +811,8 @@ class ProfileContent extends StatelessWidget {
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
if (confirmationController.text != 'CONFIRMER') {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('Veuillez écrire CONFIRMER pour valider'),
|
||||
backgroundColor: Colors.red,
|
||||
),
|
||||
_errorService.showError(
|
||||
message: 'Veuillez écrire CONFIRMER pour valider',
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -848,14 +833,10 @@ class ProfileContent extends StatelessWidget {
|
||||
if (e.code == 'requires-recent-login') {
|
||||
if (context.mounted) {
|
||||
Navigator.of(dialogContext).pop();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
_errorService.showSnackbar(
|
||||
message:
|
||||
'Par sécurité, veuillez vous reconnecter avant de supprimer votre compte',
|
||||
),
|
||||
backgroundColor: Colors.orange,
|
||||
duration: Duration(seconds: 4),
|
||||
),
|
||||
isError: true, // It's a warning/error
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user