import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import '../../../../core/di/injection.dart'; import '../../../../shared/theme/app_theme.dart'; import '../bloc/membres_bloc.dart'; import '../bloc/membres_event.dart'; import '../bloc/membres_state.dart'; class MembresDashboardPage extends StatefulWidget { const MembresDashboardPage({super.key}); @override State createState() => _MembresDashboardPageState(); } class _MembresDashboardPageState extends State { late MembresBloc _membresBloc; @override void initState() { super.initState(); _membresBloc = getIt(); _loadData(); } void _loadData() { _membresBloc.add(const LoadMembres()); } @override Widget build(BuildContext context) { return BlocProvider.value( value: _membresBloc, child: Scaffold( backgroundColor: AppTheme.backgroundLight, appBar: AppBar( title: const Text( 'Dashboard Membres', style: TextStyle( fontWeight: FontWeight.w600, fontSize: 20, ), ), backgroundColor: AppTheme.primaryColor, foregroundColor: Colors.white, elevation: 0, actions: [ IconButton( icon: const Icon(Icons.refresh), onPressed: _loadData, tooltip: 'Actualiser', ), ], ), body: BlocBuilder( builder: (context, state) { if (state is MembresLoading) { return const Center( child: CircularProgressIndicator(), ); } if (state is MembresError) { return Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon( Icons.error_outline, size: 64, color: AppTheme.errorColor, ), const SizedBox(height: 16), Text( 'Erreur de chargement', style: TextStyle( fontSize: 18, fontWeight: FontWeight.w600, color: AppTheme.textPrimary, ), ), const SizedBox(height: 8), Text( state.message, style: TextStyle( fontSize: 14, color: AppTheme.textSecondary, ), textAlign: TextAlign.center, ), const SizedBox(height: 24), ElevatedButton.icon( onPressed: _loadData, icon: const Icon(Icons.refresh), label: const Text('Réessayer'), style: ElevatedButton.styleFrom( backgroundColor: AppTheme.primaryColor, foregroundColor: Colors.white, ), ), ], ), ); } return _buildDashboard(); }, ), floatingActionButton: FloatingActionButton( onPressed: _loadData, backgroundColor: AppTheme.primaryColor, tooltip: 'Actualiser les données', child: const Icon(Icons.refresh, color: Colors.white), ), ), ); } Widget _buildDashboard() { return Container( padding: const EdgeInsets.all(16), child: const Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon( Icons.dashboard, size: 64, color: Colors.grey, ), SizedBox(height: 16), Text( 'Dashboard Vide', style: TextStyle( fontSize: 24, fontWeight: FontWeight.w600, color: Colors.grey, ), ), SizedBox(height: 8), Text( 'Prêt à être reconstruit pièce par pièce', style: TextStyle( fontSize: 16, color: Colors.grey, ), textAlign: TextAlign.center, ), ], ), ), ); } }