refactor: Centralize error and notification handling using a dedicated _errorService across various components.
This commit is contained in:
@@ -63,6 +63,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
import 'package:image_picker/image_picker.dart';
|
import 'package:image_picker/image_picker.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:travel_mate/models/expense_split.dart';
|
import 'package:travel_mate/models/expense_split.dart';
|
||||||
|
import '../../services/error_service.dart';
|
||||||
import '../../blocs/expense/expense_bloc.dart';
|
import '../../blocs/expense/expense_bloc.dart';
|
||||||
import '../../blocs/expense/expense_event.dart';
|
import '../../blocs/expense/expense_event.dart';
|
||||||
import '../../blocs/expense/expense_state.dart';
|
import '../../blocs/expense/expense_state.dart';
|
||||||
@@ -191,11 +192,8 @@ class _AddExpenseDialogState extends State<AddExpenseDialog> {
|
|||||||
|
|
||||||
if (fileSize > 5 * 1024 * 1024) {
|
if (fileSize > 5 * 1024 * 1024) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ErrorService().showError(
|
||||||
const SnackBar(
|
message: 'L\'image ne doit pas dépasser 5 Mo',
|
||||||
content: Text('L\'image ne doit pas dépasser 5 Mo'),
|
|
||||||
backgroundColor: Colors.red,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -247,11 +245,8 @@ class _AddExpenseDialogState extends State<AddExpenseDialog> {
|
|||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
if (selectedSplits.isEmpty) {
|
if (selectedSplits.isEmpty) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ErrorService().showError(
|
||||||
const SnackBar(
|
message: 'Veuillez sélectionner au moins un participant',
|
||||||
content: Text('Veuillez sélectionner au moins un participant'),
|
|
||||||
backgroundColor: Colors.red,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -299,22 +294,16 @@ class _AddExpenseDialogState extends State<AddExpenseDialog> {
|
|||||||
|
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ErrorService().showSnackbar(
|
||||||
SnackBar(
|
message: widget.expenseToEdit == null
|
||||||
content: Text(
|
|
||||||
widget.expenseToEdit == null
|
|
||||||
? 'Dépense ajoutée'
|
? 'Dépense ajoutée'
|
||||||
: 'Dépense modifiée',
|
: 'Dépense modifiée',
|
||||||
),
|
isError: false,
|
||||||
backgroundColor: Colors.green,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ErrorService().showError(message: 'Erreur: $e');
|
||||||
SnackBar(content: Text('Erreur: $e'), backgroundColor: Colors.red),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import 'balances_tab.dart';
|
|||||||
import 'expenses_tab.dart';
|
import 'expenses_tab.dart';
|
||||||
import '../../models/user_balance.dart';
|
import '../../models/user_balance.dart';
|
||||||
import '../../models/expense.dart';
|
import '../../models/expense.dart';
|
||||||
|
import '../../services/error_service.dart';
|
||||||
|
|
||||||
class GroupExpensesPage extends StatefulWidget {
|
class GroupExpensesPage extends StatefulWidget {
|
||||||
final Account account;
|
final Account account;
|
||||||
@@ -93,20 +94,13 @@ class _GroupExpensesPageState extends State<GroupExpensesPage>
|
|||||||
BlocListener<ExpenseBloc, ExpenseState>(
|
BlocListener<ExpenseBloc, ExpenseState>(
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
if (state is ExpenseOperationSuccess) {
|
if (state is ExpenseOperationSuccess) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ErrorService().showSnackbar(
|
||||||
SnackBar(
|
message: state.message,
|
||||||
content: Text(state.message),
|
isError: false,
|
||||||
backgroundColor: Colors.green,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
_loadData(); // Recharger les données après une opération
|
_loadData(); // Recharger les données après une opération
|
||||||
} else if (state is ExpenseError) {
|
} else if (state is ExpenseError) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ErrorService().showError(message: state.message);
|
||||||
SnackBar(
|
|
||||||
content: Text(state.message),
|
|
||||||
backgroundColor: Colors.red,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else if (state is ExpensesLoaded) {
|
} else if (state is ExpensesLoaded) {
|
||||||
// Rafraîchir les balances quand les dépenses changent (ex: via stream)
|
// Rafraîchir les balances quand les dépenses changent (ex: via stream)
|
||||||
context.read<BalanceBloc>().add(
|
context.read<BalanceBloc>().add(
|
||||||
@@ -393,12 +387,7 @@ class _GroupExpensesPageState extends State<GroupExpensesPage>
|
|||||||
AddExpenseDialog(group: widget.group, currentUser: userState.user),
|
AddExpenseDialog(group: widget.group, currentUser: userState.user),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ErrorService().showError(message: 'Erreur: utilisateur non connecté');
|
||||||
const SnackBar(
|
|
||||||
content: Text('Erreur: utilisateur non connecté'),
|
|
||||||
backgroundColor: Colors.red,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,11 +79,7 @@ class ErrorContent extends StatelessWidget {
|
|||||||
color: defaultIconColor?.withValues(alpha: 0.1),
|
color: defaultIconColor?.withValues(alpha: 0.1),
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
),
|
),
|
||||||
child: Icon(
|
child: Icon(icon, size: 48, color: defaultIconColor),
|
||||||
icon,
|
|
||||||
size: 48,
|
|
||||||
color: defaultIconColor,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
@@ -167,9 +163,7 @@ void showErrorDialog(
|
|||||||
barrierDismissible: barrierDismissible,
|
barrierDismissible: barrierDismissible,
|
||||||
builder: (BuildContext dialogContext) {
|
builder: (BuildContext dialogContext) {
|
||||||
return Dialog(
|
return Dialog(
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
||||||
borderRadius: BorderRadius.circular(16),
|
|
||||||
),
|
|
||||||
child: ErrorContent(
|
child: ErrorContent(
|
||||||
title: title,
|
title: title,
|
||||||
message: message,
|
message: message,
|
||||||
@@ -187,70 +181,3 @@ void showErrorDialog(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fonction helper pour afficher l'erreur en bottom sheet
|
|
||||||
void showErrorBottomSheet(
|
|
||||||
BuildContext context, {
|
|
||||||
String title = 'Une erreur est survenue',
|
|
||||||
required String message,
|
|
||||||
VoidCallback? onRetry,
|
|
||||||
IconData icon = Icons.error_outline,
|
|
||||||
Color? iconColor,
|
|
||||||
bool isDismissible = true,
|
|
||||||
}) {
|
|
||||||
showModalBottomSheet(
|
|
||||||
context: context,
|
|
||||||
isDismissible: isDismissible,
|
|
||||||
enableDrag: isDismissible,
|
|
||||||
shape: const RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
|
||||||
),
|
|
||||||
builder: (BuildContext sheetContext) {
|
|
||||||
return SafeArea(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(16),
|
|
||||||
child: ErrorContent(
|
|
||||||
title: title,
|
|
||||||
message: message,
|
|
||||||
icon: icon,
|
|
||||||
iconColor: iconColor,
|
|
||||||
onRetry: onRetry != null
|
|
||||||
? () {
|
|
||||||
Navigator.of(sheetContext).pop();
|
|
||||||
onRetry();
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
onClose: () => Navigator.of(sheetContext).pop(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fonction helper pour afficher en SnackBar (pour erreurs mineures)
|
|
||||||
void showErrorSnackBar(
|
|
||||||
BuildContext context, {
|
|
||||||
required String message,
|
|
||||||
VoidCallback? onRetry,
|
|
||||||
Duration duration = const Duration(seconds: 4),
|
|
||||||
}) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
content: Text(message),
|
|
||||||
backgroundColor: Colors.red[400],
|
|
||||||
duration: duration,
|
|
||||||
action: onRetry != null
|
|
||||||
? SnackBarAction(
|
|
||||||
label: 'Réessayer',
|
|
||||||
textColor: Colors.white,
|
|
||||||
onPressed: onRetry,
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
behavior: SnackBarBehavior.floating,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -10,6 +10,7 @@ import '../../models/group.dart';
|
|||||||
import '../../models/group_member.dart';
|
import '../../models/group_member.dart';
|
||||||
import '../../models/message.dart';
|
import '../../models/message.dart';
|
||||||
import '../../repositories/group_repository.dart';
|
import '../../repositories/group_repository.dart';
|
||||||
|
import '../../services/error_service.dart';
|
||||||
|
|
||||||
/// Chat group content widget for group messaging functionality.
|
/// Chat group content widget for group messaging functionality.
|
||||||
///
|
///
|
||||||
@@ -220,12 +221,7 @@ class _ChatGroupContentState extends State<ChatGroupContent> {
|
|||||||
child: BlocConsumer<MessageBloc, MessageState>(
|
child: BlocConsumer<MessageBloc, MessageState>(
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
if (state is MessageError) {
|
if (state is MessageError) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ErrorService().showError(message: state.message);
|
||||||
SnackBar(
|
|
||||||
content: Text(state.message),
|
|
||||||
backgroundColor: Colors.red,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
@@ -871,20 +867,15 @@ class _ChatGroupContentState extends State<ChatGroupContent> {
|
|||||||
// Le stream listener va automatiquement mettre à jour les membres
|
// Le stream listener va automatiquement mettre à jour les membres
|
||||||
// Pas besoin de fermer le dialog ou de faire un refresh manuel
|
// Pas besoin de fermer le dialog ou de faire un refresh manuel
|
||||||
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ErrorService().showSnackbar(
|
||||||
SnackBar(
|
message: 'Pseudo modifié en "$newPseudo"',
|
||||||
content: Text('Pseudo modifié en "$newPseudo"'),
|
isError: false,
|
||||||
backgroundColor: Colors.green,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ErrorService().showError(
|
||||||
SnackBar(
|
message: 'Erreur lors de la modification du pseudo: $e',
|
||||||
content: Text('Erreur lors de la modification du pseudo: $e'),
|
|
||||||
backgroundColor: Colors.red,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -876,17 +876,16 @@ class _CreateTripContentState extends State<CreateTripContent> {
|
|||||||
final emailRegex = RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$');
|
final emailRegex = RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$');
|
||||||
if (!emailRegex.hasMatch(email)) {
|
if (!emailRegex.hasMatch(email)) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(
|
_errorService.showError(message: 'Email invalide');
|
||||||
context,
|
|
||||||
).showSnackBar(SnackBar(content: Text('Email invalide')));
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_participants.contains(email)) {
|
if (_participants.contains(email)) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
_errorService.showSnackbar(
|
||||||
SnackBar(content: Text('Ce participant est déjà ajouté')),
|
message: 'Ce participant est déjà ajouté',
|
||||||
|
isError: true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -962,11 +961,9 @@ class _CreateTripContentState extends State<CreateTripContent> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
_errorService.showSnackbar(
|
||||||
SnackBar(
|
message: 'Groupe et compte mis à jour avec succès !',
|
||||||
content: Text('Groupe et compte mis à jour avec succès !'),
|
isError: false,
|
||||||
backgroundColor: Colors.green,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
@@ -1048,11 +1045,9 @@ class _CreateTripContentState extends State<CreateTripContent> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
_errorService.showSnackbar(
|
||||||
SnackBar(
|
message: 'Voyage, groupe et compte créés avec succès !',
|
||||||
content: Text('Voyage, groupe et compte créés avec succès !'),
|
isError: false,
|
||||||
backgroundColor: Colors.green,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
@@ -1066,9 +1061,7 @@ class _CreateTripContentState extends State<CreateTripContent> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
_errorService.showError(message: 'Erreur: $e');
|
||||||
SnackBar(content: Text('Erreur: $e'), backgroundColor: Colors.red),
|
|
||||||
);
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
});
|
});
|
||||||
@@ -1083,8 +1076,9 @@ class _CreateTripContentState extends State<CreateTripContent> {
|
|||||||
|
|
||||||
if (_startDate == null || _endDate == null) {
|
if (_startDate == null || _endDate == null) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
_errorService.showSnackbar(
|
||||||
SnackBar(content: Text('Veuillez sélectionner les dates')),
|
message: 'Veuillez sélectionner les dates',
|
||||||
|
isError: true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -1129,14 +1123,10 @@ class _CreateTripContentState extends State<CreateTripContent> {
|
|||||||
// Continuer sans coordonnées en cas d'erreur
|
// Continuer sans coordonnées en cas d'erreur
|
||||||
tripWithCoordinates = trip;
|
tripWithCoordinates = trip;
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
_errorService.showSnackbar(
|
||||||
SnackBar(
|
message:
|
||||||
content: Text(
|
|
||||||
'Voyage créé sans géolocalisation (pas d\'impact sur les fonctionnalités)',
|
'Voyage créé sans géolocalisation (pas d\'impact sur les fonctionnalités)',
|
||||||
),
|
isError: true, // Warning displayed as error for now
|
||||||
backgroundColor: Colors.orange,
|
|
||||||
duration: Duration(seconds: 2),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1167,9 +1157,7 @@ class _CreateTripContentState extends State<CreateTripContent> {
|
|||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
_errorService.showError(message: 'Erreur: $e');
|
||||||
SnackBar(content: Text('Erreur: $e'), backgroundColor: Colors.red),
|
|
||||||
);
|
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
@@ -1200,11 +1188,9 @@ class _CreateTripContentState extends State<CreateTripContent> {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
_errorService.showSnackbar(
|
||||||
SnackBar(
|
message: 'Utilisateur non trouvé: $email',
|
||||||
content: Text('Utilisateur non trouvé: $email'),
|
isError: true,
|
||||||
backgroundColor: Colors.orange,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import '../../blocs/trip/trip_bloc.dart';
|
|||||||
import '../../blocs/trip/trip_state.dart';
|
import '../../blocs/trip/trip_state.dart';
|
||||||
import '../../blocs/trip/trip_event.dart';
|
import '../../blocs/trip/trip_event.dart';
|
||||||
import '../../models/trip.dart';
|
import '../../models/trip.dart';
|
||||||
|
import '../../services/error_service.dart';
|
||||||
|
|
||||||
/// Home content widget for the main application dashboard.
|
/// Home content widget for the main application dashboard.
|
||||||
///
|
///
|
||||||
@@ -79,26 +80,16 @@ class _HomeContentState extends State<HomeContent>
|
|||||||
return BlocConsumer<TripBloc, TripState>(
|
return BlocConsumer<TripBloc, TripState>(
|
||||||
listener: (context, tripState) {
|
listener: (context, tripState) {
|
||||||
if (tripState is TripOperationSuccess) {
|
if (tripState is TripOperationSuccess) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ErrorService().showSnackbar(
|
||||||
SnackBar(
|
message: tripState.message,
|
||||||
content: Text(tripState.message),
|
isError: false,
|
||||||
backgroundColor: Colors.green,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
} else if (tripState is TripError) {
|
} else if (tripState is TripError) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ErrorService().showError(message: tripState.message);
|
||||||
SnackBar(
|
|
||||||
content: Text(tripState.message),
|
|
||||||
backgroundColor: Colors.red,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else if (tripState is TripCreated) {
|
} else if (tripState is TripCreated) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ErrorService().showSnackbar(
|
||||||
SnackBar(
|
message: 'Voyage en cours de création...',
|
||||||
content: Text('Voyage en cours de création...'),
|
isError: false,
|
||||||
backgroundColor: Colors.blue,
|
|
||||||
duration: Duration(seconds: 1),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -547,11 +547,9 @@ class _ShowTripDetailsContentState extends State<ShowTripDetailsContent> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _showComingSoon(String feature) {
|
void _showComingSoon(String feature) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
_errorService.showSnackbar(
|
||||||
SnackBar(
|
message: '$feature - Fonctionnalité à venir',
|
||||||
content: Text('$feature - Fonctionnalité à venir'),
|
isError: false,
|
||||||
backgroundColor: Colors.blue,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -868,11 +866,8 @@ class _ShowTripDetailsContentState extends State<ShowTripDetailsContent> {
|
|||||||
_addParticipantByEmail(emailController.text);
|
_addParticipantByEmail(emailController.text);
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
} else {
|
} else {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
_errorService.showError(
|
||||||
const SnackBar(
|
message: 'Veuillez entrer un email valide',
|
||||||
content: Text('Veuillez entrer un email valide'),
|
|
||||||
backgroundColor: Colors.red,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -940,11 +935,9 @@ class _ShowTripDetailsContentState extends State<ShowTripDetailsContent> {
|
|||||||
TripUpdateRequested(trip: updatedTrip),
|
TripUpdateRequested(trip: updatedTrip),
|
||||||
);
|
);
|
||||||
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
_errorService.showSnackbar(
|
||||||
SnackBar(
|
message: '${user.prenom} a été ajouté au voyage',
|
||||||
content: Text('${user.prenom} a été ajouté au voyage'),
|
isError: false,
|
||||||
backgroundColor: Colors.green,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Rafraîchir la page
|
// Rafraîchir la page
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import 'dart:convert';
|
|||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'dart:ui' as ui;
|
import 'dart:ui' as ui;
|
||||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||||
|
import '../../services/error_service.dart';
|
||||||
|
|
||||||
class MapContent extends StatefulWidget {
|
class MapContent extends StatefulWidget {
|
||||||
final String? initialSearchQuery;
|
final String? initialSearchQuery;
|
||||||
@@ -416,13 +417,7 @@ class _MapContentState extends State<MapContent> {
|
|||||||
|
|
||||||
void _showError(String message) {
|
void _showError(String message) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ErrorService().showError(message: message);
|
||||||
SnackBar(
|
|
||||||
content: Text(message),
|
|
||||||
backgroundColor: Colors.red,
|
|
||||||
behavior: SnackBarBehavior.floating,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -502,11 +502,9 @@ class ProfileContent extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
|
|
||||||
Navigator.of(dialogContext).pop();
|
Navigator.of(dialogContext).pop();
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
_errorService.showSnackbar(
|
||||||
SnackBar(
|
message: 'Profil mis à jour !',
|
||||||
content: Text('Profil mis à jour !'),
|
isError: false,
|
||||||
backgroundColor: Colors.green,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -668,11 +666,9 @@ class ProfileContent extends StatelessWidget {
|
|||||||
|
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
LoggerService.info('DEBUG: Affichage du succès');
|
LoggerService.info('DEBUG: Affichage du succès');
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
_errorService.showSnackbar(
|
||||||
SnackBar(
|
message: 'Photo de profil mise à jour !',
|
||||||
content: Text('Photo de profil mise à jour !'),
|
isError: false,
|
||||||
backgroundColor: Colors.green,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (e, stackTrace) {
|
} catch (e, stackTrace) {
|
||||||
@@ -736,22 +732,16 @@ class ProfileContent extends StatelessWidget {
|
|||||||
if (currentPasswordController.text.isEmpty ||
|
if (currentPasswordController.text.isEmpty ||
|
||||||
newPasswordController.text.isEmpty ||
|
newPasswordController.text.isEmpty ||
|
||||||
confirmPasswordController.text.isEmpty) {
|
confirmPasswordController.text.isEmpty) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
_errorService.showError(
|
||||||
SnackBar(
|
message: 'Tous les champs sont requis',
|
||||||
content: Text('Tous les champs sont requis'),
|
|
||||||
backgroundColor: Colors.red,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newPasswordController.text !=
|
if (newPasswordController.text !=
|
||||||
confirmPasswordController.text) {
|
confirmPasswordController.text) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
_errorService.showError(
|
||||||
SnackBar(
|
message: 'Les mots de passe ne correspondent pas',
|
||||||
content: Text('Les mots de passe ne correspondent pas'),
|
|
||||||
backgroundColor: Colors.red,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -765,11 +755,9 @@ class ProfileContent extends StatelessWidget {
|
|||||||
|
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
Navigator.of(dialogContext).pop();
|
Navigator.of(dialogContext).pop();
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
_errorService.showSnackbar(
|
||||||
SnackBar(
|
message: 'Mot de passe changé !',
|
||||||
content: Text('Mot de passe changé !'),
|
isError: false,
|
||||||
backgroundColor: Colors.green,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -823,11 +811,8 @@ class ProfileContent extends StatelessWidget {
|
|||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
if (confirmationController.text != 'CONFIRMER') {
|
if (confirmationController.text != 'CONFIRMER') {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
_errorService.showError(
|
||||||
SnackBar(
|
message: 'Veuillez écrire CONFIRMER pour valider',
|
||||||
content: Text('Veuillez écrire CONFIRMER pour valider'),
|
|
||||||
backgroundColor: Colors.red,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -848,14 +833,10 @@ class ProfileContent extends StatelessWidget {
|
|||||||
if (e.code == 'requires-recent-login') {
|
if (e.code == 'requires-recent-login') {
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
Navigator.of(dialogContext).pop();
|
Navigator.of(dialogContext).pop();
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
_errorService.showSnackbar(
|
||||||
SnackBar(
|
message:
|
||||||
content: Text(
|
|
||||||
'Par sécurité, veuillez vous reconnecter avant de supprimer votre compte',
|
'Par sécurité, veuillez vous reconnecter avant de supprimer votre compte',
|
||||||
),
|
isError: true, // It's a warning/error
|
||||||
backgroundColor: Colors.orange,
|
|
||||||
duration: Duration(seconds: 4),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ class AuthService {
|
|||||||
],
|
],
|
||||||
// Configuration for Android/Web
|
// Configuration for Android/Web
|
||||||
webAuthenticationOptions: WebAuthenticationOptions(
|
webAuthenticationOptions: WebAuthenticationOptions(
|
||||||
clientId: 'be.devdayronvl.TravelMate.service',
|
clientId: 'be.devdayronvl.travel_mate.service',
|
||||||
redirectUri: Uri.parse(
|
redirectUri: Uri.parse(
|
||||||
'https://travelmate-a47f5.firebaseapp.com/__/auth/handler',
|
'https://travelmate-a47f5.firebaseapp.com/__/auth/handler',
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user