feat: integrate ErrorService for consistent error display and standardize bloc error messages.

This commit is contained in:
Van Leemput Dayron
2025-12-02 13:59:40 +01:00
parent 1e70b9e09f
commit 6757cb013a
24 changed files with 927 additions and 608 deletions

View File

@@ -11,6 +11,7 @@ import '../blocs/user/user_bloc.dart';
import '../blocs/user/user_event.dart';
import '../blocs/auth/auth_bloc.dart';
import '../blocs/auth/auth_event.dart';
import '../services/error_service.dart';
class HomePage extends StatefulWidget {
const HomePage({super.key});
@@ -119,12 +120,7 @@ class _HomePageState extends State<HomePage> {
);
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Erreur lors de la déconnexion: $e'),
backgroundColor: Colors.red,
),
);
ErrorService().showError(message: 'Erreur lors de la déconnexion: $e');
}
}
}
@@ -132,38 +128,51 @@ class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(titles[_currentIndex]),
),
appBar: AppBar(title: Text(titles[_currentIndex])),
drawer: Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: [
DrawerHeader(
decoration: BoxDecoration(
color: Theme.of(context).brightness == Brightness.dark
? Colors.black
: Colors.white,
color: Theme.of(context).brightness == Brightness.dark
? Colors.black
: Colors.white,
),
child: Text(
"Travel Mate",
style: TextStyle(
color: Theme.of(context).brightness == Brightness.dark
? Colors.white
: Colors.black,
color: Theme.of(context).brightness == Brightness.dark
? Colors.white
: Colors.black,
fontSize: 24,
),
),
),
_buildDrawerItem(icon: Icons.home, title: "Mes voyages", index: 0),
_buildDrawerItem(icon: Icons.settings, title: "Paramètres", index: 1),
_buildDrawerItem(
icon: Icons.settings,
title: "Paramètres",
index: 1,
),
_buildDrawerItem(icon: Icons.map, title: "Carte", index: 2),
_buildDrawerItem(icon: Icons.group, title: "Chat de groupe", index: 3),
_buildDrawerItem(icon: Icons.account_balance_wallet, title: "Comptes", index: 4),
_buildDrawerItem(
icon: Icons.group,
title: "Chat de groupe",
index: 3,
),
_buildDrawerItem(
icon: Icons.account_balance_wallet,
title: "Comptes",
index: 4,
),
const Divider(),
ListTile(
leading: const Icon(Icons.logout, color: Colors.red),
title: const Text("Déconnexion", style: TextStyle(color: Colors.red)),
title: const Text(
"Déconnexion",
style: TextStyle(color: Colors.red),
),
onTap: _handleLogout, // Utiliser la nouvelle méthode
),
],
@@ -191,7 +200,9 @@ class _HomePageState extends State<HomePage> {
leading: Icon(icon),
title: Text(title),
selected: _currentIndex == index,
selectedTileColor: Theme.of(context).colorScheme.primary.withValues(alpha: 0.1),
selectedTileColor: Theme.of(
context,
).colorScheme.primary.withValues(alpha: 0.1),
onTap: () => _onNavigationTap(index),
);
}
@@ -201,4 +212,4 @@ class _HomePageState extends State<HomePage> {
_pageCache.clear();
super.dispose();
}
}
}