Appli Flutter se connecte bien à l'API.

This commit is contained in:
DahoudG
2025-09-12 03:15:21 +00:00
parent 8184bc77bb
commit 3df010add7
33 changed files with 3124 additions and 339 deletions

View File

@@ -6,7 +6,6 @@ import '../../../../core/auth/bloc/auth_event.dart';
import '../../../../core/auth/models/auth_state.dart';
import '../../../../core/auth/models/login_request.dart';
import '../../../../shared/theme/app_theme.dart';
import '../../../../shared/widgets/buttons/buttons.dart';
import '../widgets/login_form.dart';
import '../widgets/login_header.dart';
import '../widgets/login_footer.dart';
@@ -48,12 +47,12 @@ class _LoginPageState extends State<LoginPage>
duration: const Duration(milliseconds: 1200),
vsync: this,
);
_shakeController = AnimationController(
duration: const Duration(milliseconds: 600),
vsync: this,
);
_fadeAnimation = Tween<double>(
begin: 0.0,
end: 1.0,
@@ -61,7 +60,7 @@ class _LoginPageState extends State<LoginPage>
parent: _animationController,
curve: const Interval(0.0, 0.6, curve: Curves.easeOut),
));
_slideAnimation = Tween<double>(
begin: 50.0,
end: 0.0,
@@ -69,22 +68,23 @@ class _LoginPageState extends State<LoginPage>
parent: _animationController,
curve: const Interval(0.2, 0.8, curve: Curves.easeOut),
));
_shakeAnimation = Tween<double>(
begin: 0.0,
end: 1.0,
).animate(CurvedAnimation(
parent: _shakeController,
curve: Curves.elasticInOut,
curve: Curves.elasticIn,
));
}
void _startEntryAnimation() {
Future.delayed(const Duration(milliseconds: 100), () {
if (mounted) {
_animationController.forward();
}
});
_animationController.forward();
}
void _startShakeAnimation() {
_shakeController.reset();
_shakeController.forward();
}
@override
@@ -100,170 +100,187 @@ class _LoginPageState extends State<LoginPage>
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppTheme.backgroundLight,
body: BlocListener<AuthBloc, AuthState>(
listener: _handleAuthStateChange,
child: SafeArea(
child: AnimatedBuilder(
animation: _animationController,
builder: (context, child) {
return FadeTransition(
opacity: _fadeAnimation,
child: Transform.translate(
offset: Offset(0, _slideAnimation.value),
child: _buildLoginContent(),
),
);
},
),
),
body: BlocConsumer<AuthBloc, AuthState>(
listener: (context, state) {
setState(() {
_isLoading = state.status == AuthStatus.checking;
});
if (state.status == AuthStatus.error) {
_startShakeAnimation();
_showErrorSnackBar(state.errorMessage ?? 'Erreur de connexion');
} else if (state.status == AuthStatus.authenticated) {
_showSuccessSnackBar('Connexion réussie !');
}
},
builder: (context, state) {
return SafeArea(
child: _buildLoginContent(),
);
},
),
);
}
Widget _buildLoginContent() {
return SingleChildScrollView(
padding: const EdgeInsets.all(24),
child: Column(
children: [
const SizedBox(height: 60),
// Header avec logo et titre
LoginHeader(
onAnimationComplete: () {},
),
const SizedBox(height: 60),
// Formulaire de connexion
AnimatedBuilder(
animation: _shakeAnimation,
builder: (context, child) {
return Transform.translate(
offset: Offset(
_shakeAnimation.value * 10 *
(1 - _shakeAnimation.value) *
(1 - _shakeAnimation.value),
0,
),
child: LoginForm(
formKey: _formKey,
emailController: _emailController,
passwordController: _passwordController,
obscurePassword: _obscurePassword,
rememberMe: _rememberMe,
isLoading: _isLoading,
onObscureToggle: () {
setState(() {
_obscurePassword = !_obscurePassword;
});
HapticFeedback.selectionClick();
},
onRememberMeToggle: (value) {
setState(() {
_rememberMe = value;
});
HapticFeedback.selectionClick();
},
onSubmit: _handleLogin,
),
return AnimatedBuilder(
animation: _animationController,
builder: (context, child) {
return Transform.translate(
offset: Offset(0, _slideAnimation.value),
child: Opacity(
opacity: _fadeAnimation.value,
child: SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: Column(
children: [
const SizedBox(height: 60),
// Header avec logo et titre
const LoginHeader(),
const SizedBox(height: 40),
// Formulaire de connexion
AnimatedBuilder(
animation: _shakeAnimation,
builder: (context, child) {
return Transform.translate(
offset: Offset(
_shakeAnimation.value * 10 *
(1 - _shakeAnimation.value) *
((_shakeAnimation.value * 10).round() % 2 == 0 ? 1 : -1),
0,
),
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
blurRadius: 20,
offset: const Offset(0, 10),
),
],
),
child: Padding(
padding: const EdgeInsets.all(24),
child: LoginForm(
formKey: _formKey,
emailController: _emailController,
passwordController: _passwordController,
obscurePassword: _obscurePassword,
rememberMe: _rememberMe,
isLoading: _isLoading,
onObscureToggle: () {
setState(() {
_obscurePassword = !_obscurePassword;
});
HapticFeedback.selectionClick();
},
onRememberMeToggle: (value) {
setState(() {
_rememberMe = value;
});
HapticFeedback.selectionClick();
},
onSubmit: _handleLogin,
),
),
),
);
},
),
const SizedBox(height: 40),
// Footer avec liens et informations
const LoginFooter(),
const SizedBox(height: 20),
],
),
),
),
const SizedBox(height: 40),
// Footer avec liens et informations
const LoginFooter(),
const SizedBox(height: 20),
],
),
);
},
);
}
void _handleAuthStateChange(BuildContext context, AuthState state) {
setState(() {
_isLoading = state.isLoading;
});
if (state.status == AuthStatus.authenticated) {
// Connexion réussie - navigation gérée par l'app principal
_showSuccessMessage();
HapticFeedback.heavyImpact();
} else if (state.status == AuthStatus.error) {
// Erreur de connexion
_handleLoginError(state.errorMessage ?? 'Erreur inconnue');
} else if (state.status == AuthStatus.unauthenticated && state.errorMessage != null) {
// Échec de connexion
_handleLoginError(state.errorMessage!);
}
}
void _handleLogin() {
if (!_formKey.currentState!.validate()) {
_triggerShakeAnimation();
HapticFeedback.mediumImpact();
_startShakeAnimation();
return;
}
final email = _emailController.text.trim();
final password = _passwordController.text;
if (email.isEmpty || password.isEmpty) {
_showErrorMessage('Veuillez remplir tous les champs');
_triggerShakeAnimation();
return;
}
// Déclencher la connexion
HapticFeedback.lightImpact();
final loginRequest = LoginRequest(
email: email,
password: password,
email: _emailController.text.trim(),
password: _passwordController.text,
rememberMe: _rememberMe,
);
context.read<AuthBloc>().add(AuthLoginRequested(loginRequest));
// Feedback haptique
HapticFeedback.lightImpact();
}
void _handleLoginError(String errorMessage) {
_showErrorMessage(errorMessage);
_triggerShakeAnimation();
HapticFeedback.mediumImpact();
// Effacer l'erreur après affichage
Future.delayed(const Duration(seconds: 3), () {
if (mounted) {
context.read<AuthBloc>().add(const AuthErrorCleared());
}
});
}
void _triggerShakeAnimation() {
_shakeController.reset();
_shakeController.forward();
}
void _showSuccessMessage() {
void _showErrorSnackBar(String message) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Row(
children: [
Icon(
Icons.check_circle,
const Icon(
Icons.error_outline,
color: Colors.white,
size: 24,
),
const SizedBox(width: 12),
const Text(
'Connexion réussie !',
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 16,
Expanded(
child: Text(
message,
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
),
),
),
],
),
backgroundColor: AppTheme.errorColor,
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
margin: const EdgeInsets.all(16),
duration: const Duration(seconds: 4),
action: SnackBarAction(
label: 'Fermer',
textColor: Colors.white,
onPressed: () {
ScaffoldMessenger.of(context).hideCurrentSnackBar();
},
),
),
);
}
void _showSuccessSnackBar(String message) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Row(
children: [
const Icon(
Icons.check_circle_outline,
color: Colors.white,
),
const SizedBox(width: 12),
Expanded(
child: Text(
message,
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
),
),
),
],
@@ -278,44 +295,4 @@ class _LoginPageState extends State<LoginPage>
),
);
}
void _showErrorMessage(String message) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Row(
children: [
Icon(
Icons.error_outline,
color: Colors.white,
size: 24,
),
const SizedBox(width: 12),
Expanded(
child: Text(
message,
style: const TextStyle(
fontWeight: FontWeight.w600,
fontSize: 14,
),
),
),
],
),
backgroundColor: AppTheme.errorColor,
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
margin: const EdgeInsets.all(16),
duration: const Duration(seconds: 4),
action: SnackBarAction(
label: 'OK',
textColor: Colors.white,
onPressed: () {
ScaffoldMessenger.of(context).hideCurrentSnackBar();
},
),
),
);
}
}
}

View File

@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import '../../../../shared/theme/app_theme.dart';
import '../widgets/kpi_card.dart';
import '../widgets/clickable_kpi_card.dart';
import '../widgets/chart_card.dart';
import '../widgets/activity_feed.dart';

View File

@@ -0,0 +1,76 @@
import 'package:injectable/injectable.dart';
import '../../../../core/models/membre_model.dart';
import '../../../../core/services/api_service.dart';
import '../../domain/repositories/membre_repository.dart';
import '../../../../core/errors/failures.dart';
/// Implémentation du repository des membres
@LazySingleton(as: MembreRepository)
class MembreRepositoryImpl implements MembreRepository {
final ApiService _apiService;
MembreRepositoryImpl(this._apiService);
@override
Future<List<MembreModel>> getMembres() async {
try {
return await _apiService.getMembres();
} catch (e) {
throw ServerFailure(message: e.toString());
}
}
@override
Future<MembreModel> getMembreById(String id) async {
try {
return await _apiService.getMembreById(id);
} catch (e) {
throw ServerFailure(message: e.toString());
}
}
@override
Future<MembreModel> createMembre(MembreModel membre) async {
try {
return await _apiService.createMembre(membre);
} catch (e) {
throw ServerFailure(message: e.toString());
}
}
@override
Future<MembreModel> updateMembre(String id, MembreModel membre) async {
try {
return await _apiService.updateMembre(id, membre);
} catch (e) {
throw ServerFailure(message: e.toString());
}
}
@override
Future<void> deleteMembre(String id) async {
try {
await _apiService.deleteMembre(id);
} catch (e) {
throw ServerFailure(message: e.toString());
}
}
@override
Future<List<MembreModel>> searchMembres(String query) async {
try {
return await _apiService.searchMembres(query);
} catch (e) {
throw ServerFailure(message: e.toString());
}
}
@override
Future<Map<String, dynamic>> getMembresStats() async {
try {
return await _apiService.getMembresStats();
} catch (e) {
throw ServerFailure(message: e.toString());
}
}
}

View File

@@ -0,0 +1,26 @@
import '../../../../core/models/membre_model.dart';
/// Interface du repository des membres
/// Définit les opérations disponibles pour la gestion des membres
abstract class MembreRepository {
/// Récupère la liste de tous les membres actifs
Future<List<MembreModel>> getMembres();
/// Récupère un membre par son ID
Future<MembreModel> getMembreById(String id);
/// Crée un nouveau membre
Future<MembreModel> createMembre(MembreModel membre);
/// Met à jour un membre existant
Future<MembreModel> updateMembre(String id, MembreModel membre);
/// Désactive un membre
Future<void> deleteMembre(String id);
/// Recherche des membres par nom ou prénom
Future<List<MembreModel>> searchMembres(String query);
/// Récupère les statistiques des membres
Future<Map<String, dynamic>> getMembresStats();
}

View File

@@ -0,0 +1,244 @@
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:injectable/injectable.dart';
import '../../domain/repositories/membre_repository.dart';
import '../../../../core/errors/failures.dart';
import '../../../../core/models/membre_model.dart';
import 'membres_event.dart';
import 'membres_state.dart';
/// BLoC pour la gestion des membres
@injectable
class MembresBloc extends Bloc<MembresEvent, MembresState> {
final MembreRepository _membreRepository;
MembresBloc(this._membreRepository) : super(const MembresInitial()) {
// Enregistrement des handlers d'événements
on<LoadMembres>(_onLoadMembres);
on<RefreshMembres>(_onRefreshMembres);
on<SearchMembres>(_onSearchMembres);
on<LoadMembreById>(_onLoadMembreById);
on<CreateMembre>(_onCreateMembre);
on<UpdateMembre>(_onUpdateMembre);
on<DeleteMembre>(_onDeleteMembre);
on<LoadMembresStats>(_onLoadMembresStats);
on<ClearMembresError>(_onClearMembresError);
on<ResetMembresState>(_onResetMembresState);
}
/// Handler pour charger la liste des membres
Future<void> _onLoadMembres(
LoadMembres event,
Emitter<MembresState> emit,
) async {
emit(const MembresLoading());
try {
final membres = await _membreRepository.getMembres();
emit(MembresLoaded(membres: membres));
} catch (e) {
final failure = _mapExceptionToFailure(e);
emit(MembresError(failure: failure));
}
}
/// Handler pour rafraîchir la liste des membres
Future<void> _onRefreshMembres(
RefreshMembres event,
Emitter<MembresState> emit,
) async {
// Conserver les données actuelles pendant le refresh
final currentState = state;
List<MembreModel> currentMembres = [];
if (currentState is MembresLoaded) {
currentMembres = currentState.membres;
emit(MembresRefreshing(currentMembres));
} else {
emit(const MembresLoading());
}
try {
final membres = await _membreRepository.getMembres();
emit(MembresLoaded(membres: membres));
} catch (e) {
final failure = _mapExceptionToFailure(e);
// Si on avait des données, les conserver avec l'erreur
if (currentMembres.isNotEmpty) {
emit(MembresErrorWithData(
failure: failure,
membres: currentMembres,
));
} else {
emit(MembresError(failure: failure));
}
}
}
/// Handler pour rechercher des membres
Future<void> _onSearchMembres(
SearchMembres event,
Emitter<MembresState> emit,
) async {
if (event.query.trim().isEmpty) {
// Si la recherche est vide, recharger tous les membres
add(const LoadMembres());
return;
}
emit(const MembresLoading());
try {
final membres = await _membreRepository.searchMembres(event.query);
emit(MembresLoaded(
membres: membres,
isSearchResult: true,
searchQuery: event.query,
));
} catch (e) {
final failure = _mapExceptionToFailure(e);
emit(MembresError(failure: failure));
}
}
/// Handler pour charger un membre par ID
Future<void> _onLoadMembreById(
LoadMembreById event,
Emitter<MembresState> emit,
) async {
emit(const MembresLoading());
try {
final membre = await _membreRepository.getMembreById(event.id);
emit(MembreDetailLoaded(membre));
} catch (e) {
final failure = _mapExceptionToFailure(e);
emit(MembresError(failure: failure));
}
}
/// Handler pour créer un membre
Future<void> _onCreateMembre(
CreateMembre event,
Emitter<MembresState> emit,
) async {
emit(const MembresLoading());
try {
final nouveauMembre = await _membreRepository.createMembre(event.membre);
emit(MembreCreated(nouveauMembre));
// Recharger la liste après création
add(const LoadMembres());
} catch (e) {
final failure = _mapExceptionToFailure(e);
emit(MembresError(failure: failure));
}
}
/// Handler pour mettre à jour un membre
Future<void> _onUpdateMembre(
UpdateMembre event,
Emitter<MembresState> emit,
) async {
emit(const MembresLoading());
try {
final membreMisAJour = await _membreRepository.updateMembre(
event.id,
event.membre,
);
emit(MembreUpdated(membreMisAJour));
// Recharger la liste après mise à jour
add(const LoadMembres());
} catch (e) {
final failure = _mapExceptionToFailure(e);
emit(MembresError(failure: failure));
}
}
/// Handler pour supprimer un membre
Future<void> _onDeleteMembre(
DeleteMembre event,
Emitter<MembresState> emit,
) async {
emit(const MembresLoading());
try {
await _membreRepository.deleteMembre(event.id);
emit(MembreDeleted(event.id));
// Recharger la liste après suppression
add(const LoadMembres());
} catch (e) {
final failure = _mapExceptionToFailure(e);
emit(MembresError(failure: failure));
}
}
/// Handler pour charger les statistiques
Future<void> _onLoadMembresStats(
LoadMembresStats event,
Emitter<MembresState> emit,
) async {
emit(const MembresLoading());
try {
final stats = await _membreRepository.getMembresStats();
emit(MembresStatsLoaded(stats));
} catch (e) {
final failure = _mapExceptionToFailure(e);
emit(MembresError(failure: failure));
}
}
/// Handler pour effacer les erreurs
void _onClearMembresError(
ClearMembresError event,
Emitter<MembresState> emit,
) {
final currentState = state;
if (currentState is MembresError && currentState.previousState != null) {
emit(currentState.previousState!);
} else if (currentState is MembresErrorWithData) {
emit(MembresLoaded(
membres: currentState.membres,
isSearchResult: currentState.isSearchResult,
searchQuery: currentState.searchQuery,
));
} else {
emit(const MembresInitial());
}
}
/// Handler pour réinitialiser l'état
void _onResetMembresState(
ResetMembresState event,
Emitter<MembresState> emit,
) {
emit(const MembresInitial());
}
/// Convertit une exception en Failure approprié
Failure _mapExceptionToFailure(dynamic exception) {
if (exception is Failure) {
return exception;
}
final message = exception.toString();
if (message.contains('connexion') || message.contains('network')) {
return NetworkFailure(message: message);
} else if (message.contains('401') || message.contains('unauthorized')) {
return const AuthFailure(message: 'Session expirée. Veuillez vous reconnecter.');
} else if (message.contains('400') || message.contains('validation')) {
return ValidationFailure(message: message);
} else if (message.contains('500') || message.contains('server')) {
return ServerFailure(message: message);
}
return ServerFailure(message: message);
}
}

View File

@@ -0,0 +1,86 @@
import 'package:equatable/equatable.dart';
import '../../../../core/models/membre_model.dart';
/// Événements pour le BLoC des membres
abstract class MembresEvent extends Equatable {
const MembresEvent();
@override
List<Object?> get props => [];
}
/// Événement pour charger la liste des membres
class LoadMembres extends MembresEvent {
const LoadMembres();
}
/// Événement pour rafraîchir la liste des membres
class RefreshMembres extends MembresEvent {
const RefreshMembres();
}
/// Événement pour rechercher des membres
class SearchMembres extends MembresEvent {
const SearchMembres(this.query);
final String query;
@override
List<Object?> get props => [query];
}
/// Événement pour charger un membre spécifique
class LoadMembreById extends MembresEvent {
const LoadMembreById(this.id);
final String id;
@override
List<Object?> get props => [id];
}
/// Événement pour créer un nouveau membre
class CreateMembre extends MembresEvent {
const CreateMembre(this.membre);
final MembreModel membre;
@override
List<Object?> get props => [membre];
}
/// Événement pour mettre à jour un membre
class UpdateMembre extends MembresEvent {
const UpdateMembre(this.id, this.membre);
final String id;
final MembreModel membre;
@override
List<Object?> get props => [id, membre];
}
/// Événement pour supprimer un membre
class DeleteMembre extends MembresEvent {
const DeleteMembre(this.id);
final String id;
@override
List<Object?> get props => [id];
}
/// Événement pour charger les statistiques des membres
class LoadMembresStats extends MembresEvent {
const LoadMembresStats();
}
/// Événement pour effacer les erreurs
class ClearMembresError extends MembresEvent {
const ClearMembresError();
}
/// Événement pour réinitialiser l'état
class ResetMembresState extends MembresEvent {
const ResetMembresState();
}

View File

@@ -0,0 +1,163 @@
import 'package:equatable/equatable.dart';
import '../../../../core/models/membre_model.dart';
import '../../../../core/errors/failures.dart';
/// États pour le BLoC des membres
abstract class MembresState extends Equatable {
const MembresState();
@override
List<Object?> get props => [];
}
/// État initial
class MembresInitial extends MembresState {
const MembresInitial();
}
/// État de chargement
class MembresLoading extends MembresState {
const MembresLoading();
}
/// État de chargement avec données existantes (pour le refresh)
class MembresRefreshing extends MembresState {
const MembresRefreshing(this.currentMembres);
final List<MembreModel> currentMembres;
@override
List<Object?> get props => [currentMembres];
}
/// État de succès avec liste des membres
class MembresLoaded extends MembresState {
const MembresLoaded({
required this.membres,
this.isSearchResult = false,
this.searchQuery,
});
final List<MembreModel> membres;
final bool isSearchResult;
final String? searchQuery;
@override
List<Object?> get props => [membres, isSearchResult, searchQuery];
/// Copie avec modifications
MembresLoaded copyWith({
List<MembreModel>? membres,
bool? isSearchResult,
String? searchQuery,
}) {
return MembresLoaded(
membres: membres ?? this.membres,
isSearchResult: isSearchResult ?? this.isSearchResult,
searchQuery: searchQuery ?? this.searchQuery,
);
}
}
/// État de succès pour un membre spécifique
class MembreDetailLoaded extends MembresState {
const MembreDetailLoaded(this.membre);
final MembreModel membre;
@override
List<Object?> get props => [membre];
}
/// État de succès pour les statistiques
class MembresStatsLoaded extends MembresState {
const MembresStatsLoaded(this.stats);
final Map<String, dynamic> stats;
@override
List<Object?> get props => [stats];
}
/// État de succès pour la création d'un membre
class MembreCreated extends MembresState {
const MembreCreated(this.membre);
final MembreModel membre;
@override
List<Object?> get props => [membre];
}
/// État de succès pour la mise à jour d'un membre
class MembreUpdated extends MembresState {
const MembreUpdated(this.membre);
final MembreModel membre;
@override
List<Object?> get props => [membre];
}
/// État de succès pour la suppression d'un membre
class MembreDeleted extends MembresState {
const MembreDeleted(this.membreId);
final String membreId;
@override
List<Object?> get props => [membreId];
}
/// État d'erreur
class MembresError extends MembresState {
const MembresError({
required this.failure,
this.previousState,
});
final Failure failure;
final MembresState? previousState;
@override
List<Object?> get props => [failure, previousState];
/// Message d'erreur formaté
String get message => failure.message;
/// Code d'erreur
String? get code => failure.code;
/// Indique si c'est une erreur réseau
bool get isNetworkError => failure is NetworkFailure;
/// Indique si c'est une erreur serveur
bool get isServerError => failure is ServerFailure;
/// Indique si c'est une erreur d'authentification
bool get isAuthError => failure is AuthFailure;
/// Indique si c'est une erreur de validation
bool get isValidationError => failure is ValidationFailure;
}
/// État d'erreur avec données existantes (pour les erreurs non critiques)
class MembresErrorWithData extends MembresState {
const MembresErrorWithData({
required this.failure,
required this.membres,
this.isSearchResult = false,
this.searchQuery,
});
final Failure failure;
final List<MembreModel> membres;
final bool isSearchResult;
final String? searchQuery;
@override
List<Object?> get props => [failure, membres, isSearchResult, searchQuery];
/// Message d'erreur formaté
String get message => failure.message;
}

View File

@@ -0,0 +1,358 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import '../../../../core/di/injection.dart';
import '../../../../shared/theme/app_theme.dart';
import '../../../../shared/widgets/coming_soon_page.dart';
import '../bloc/membres_bloc.dart';
import '../bloc/membres_event.dart';
import '../bloc/membres_state.dart';
import '../widgets/membre_card.dart';
import '../widgets/membres_search_bar.dart';
/// Page de liste des membres avec fonctionnalités avancées
class MembresListPage extends StatefulWidget {
const MembresListPage({super.key});
@override
State<MembresListPage> createState() => _MembresListPageState();
}
class _MembresListPageState extends State<MembresListPage> {
final RefreshController _refreshController = RefreshController();
final TextEditingController _searchController = TextEditingController();
late MembresBloc _membresBloc;
@override
void initState() {
super.initState();
_membresBloc = getIt<MembresBloc>();
_membresBloc.add(const LoadMembres());
}
@override
void dispose() {
_refreshController.dispose();
_searchController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return BlocProvider.value(
value: _membresBloc,
child: Scaffold(
backgroundColor: AppTheme.backgroundLight,
appBar: AppBar(
title: const Text(
'Membres',
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 20,
),
),
backgroundColor: AppTheme.primaryColor,
foregroundColor: Colors.white,
elevation: 0,
actions: [
IconButton(
icon: const Icon(Icons.add_circle_outline),
onPressed: () => _showAddMemberDialog(),
tooltip: 'Ajouter un membre',
),
IconButton(
icon: const Icon(Icons.analytics_outlined),
onPressed: () => _showStatsDialog(),
tooltip: 'Statistiques',
),
],
),
body: Column(
children: [
// Barre de recherche
Container(
color: AppTheme.primaryColor,
child: Padding(
padding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
child: MembresSearchBar(
controller: _searchController,
onSearch: (query) {
_membresBloc.add(SearchMembres(query));
},
onClear: () {
_searchController.clear();
_membresBloc.add(const LoadMembres());
},
),
),
),
// Liste des membres
Expanded(
child: BlocConsumer<MembresBloc, MembresState>(
listener: (context, state) {
if (state is MembresError) {
_showErrorSnackBar(state.message);
} else if (state is MembresErrorWithData) {
_showErrorSnackBar(state.message);
}
// Arrêter le refresh
if (state is! MembresRefreshing && state is! MembresLoading) {
_refreshController.refreshCompleted();
}
},
builder: (context, state) {
if (state is MembresLoading) {
return const Center(
child: CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(AppTheme.primaryColor),
),
);
}
if (state is MembresError) {
return _buildErrorWidget(state);
}
if (state is MembresLoaded || state is MembresErrorWithData) {
final membres = state is MembresLoaded
? state.membres
: (state as MembresErrorWithData).membres;
final isSearchResult = state is MembresLoaded
? state.isSearchResult
: (state as MembresErrorWithData).isSearchResult;
return SmartRefresher(
controller: _refreshController,
onRefresh: () => _membresBloc.add(const RefreshMembres()),
header: const WaterDropHeader(
waterDropColor: AppTheme.primaryColor,
),
child: membres.isEmpty
? _buildEmptyWidget(isSearchResult)
: ListView.builder(
padding: const EdgeInsets.all(16),
itemCount: membres.length,
itemBuilder: (context, index) {
return Padding(
padding: const EdgeInsets.only(bottom: 12),
child: MembreCard(
membre: membres[index],
onTap: () => _showMemberDetails(membres[index]),
onEdit: () => _showEditMemberDialog(membres[index]),
onDelete: () => _showDeleteConfirmation(membres[index]),
),
);
},
),
);
}
return const Center(
child: Text(
'Aucune donnée disponible',
style: TextStyle(
fontSize: 16,
color: AppTheme.textSecondary,
),
),
);
},
),
),
],
),
),
);
}
/// Widget d'erreur avec bouton de retry
Widget _buildErrorWidget(MembresError state) {
return Center(
child: Padding(
padding: const EdgeInsets.all(24),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
state.isNetworkError ? Icons.wifi_off : Icons.error_outline,
size: 64,
color: AppTheme.errorColor,
),
const SizedBox(height: 16),
Text(
state.isNetworkError
? 'Problème de connexion'
: 'Une erreur est survenue',
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
color: AppTheme.textPrimary,
),
),
const SizedBox(height: 8),
Text(
state.message,
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 14,
color: AppTheme.textSecondary,
),
),
const SizedBox(height: 24),
ElevatedButton.icon(
onPressed: () => _membresBloc.add(const LoadMembres()),
icon: const Icon(Icons.refresh),
label: const Text('Réessayer'),
style: ElevatedButton.styleFrom(
backgroundColor: AppTheme.primaryColor,
foregroundColor: Colors.white,
),
),
],
),
),
);
}
/// Widget vide (aucun membre trouvé)
Widget _buildEmptyWidget(bool isSearchResult) {
return Center(
child: Padding(
padding: const EdgeInsets.all(24),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
isSearchResult ? Icons.search_off : Icons.people_outline,
size: 64,
color: AppTheme.textHint,
),
const SizedBox(height: 16),
Text(
isSearchResult
? 'Aucun membre trouvé'
: 'Aucun membre enregistré',
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
color: AppTheme.textPrimary,
),
),
const SizedBox(height: 8),
Text(
isSearchResult
? 'Essayez avec d\'autres termes de recherche'
: 'Commencez par ajouter votre premier membre',
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 14,
color: AppTheme.textSecondary,
),
),
if (!isSearchResult) ...[
const SizedBox(height: 24),
ElevatedButton.icon(
onPressed: _showAddMemberDialog,
icon: const Icon(Icons.add),
label: const Text('Ajouter un membre'),
style: ElevatedButton.styleFrom(
backgroundColor: AppTheme.primaryColor,
foregroundColor: Colors.white,
),
),
],
],
),
),
);
}
/// Affiche une snackbar d'erreur
void _showErrorSnackBar(String message) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(message),
backgroundColor: AppTheme.errorColor,
action: SnackBarAction(
label: 'Fermer',
textColor: Colors.white,
onPressed: () => ScaffoldMessenger.of(context).hideCurrentSnackBar(),
),
),
);
}
/// Affiche les détails d'un membre
void _showMemberDetails(membre) {
// TODO: Implémenter la page de détails
showDialog(
context: context,
builder: (context) => const ComingSoonPage(
title: 'Détails du membre',
description: 'La page de détails du membre sera bientôt disponible.',
icon: Icons.person,
color: AppTheme.primaryColor,
),
);
}
/// Affiche le dialog d'ajout de membre
void _showAddMemberDialog() {
// TODO: Implémenter le formulaire d'ajout
showDialog(
context: context,
builder: (context) => const ComingSoonPage(
title: 'Ajouter un membre',
description: 'Le formulaire d\'ajout de membre sera bientôt disponible.',
icon: Icons.person_add,
color: AppTheme.successColor,
),
);
}
/// Affiche le dialog d'édition de membre
void _showEditMemberDialog(membre) {
// TODO: Implémenter le formulaire d'édition
showDialog(
context: context,
builder: (context) => const ComingSoonPage(
title: 'Modifier le membre',
description: 'Le formulaire de modification sera bientôt disponible.',
icon: Icons.edit,
color: AppTheme.warningColor,
),
);
}
/// Affiche la confirmation de suppression
void _showDeleteConfirmation(membre) {
// TODO: Implémenter la confirmation de suppression
showDialog(
context: context,
builder: (context) => const ComingSoonPage(
title: 'Supprimer le membre',
description: 'La confirmation de suppression sera bientôt disponible.',
icon: Icons.delete,
color: AppTheme.errorColor,
),
);
}
/// Affiche les statistiques
void _showStatsDialog() {
// TODO: Implémenter les statistiques
showDialog(
context: context,
builder: (context) => const ComingSoonPage(
title: 'Statistiques',
description: 'Les statistiques des membres seront bientôt disponibles.',
icon: Icons.analytics,
color: AppTheme.infoColor,
),
);
}
}

View File

@@ -0,0 +1,282 @@
import 'package:flutter/material.dart';
import '../../../../core/models/membre_model.dart';
import '../../../../shared/theme/app_theme.dart';
/// Card pour afficher un membre dans la liste
class MembreCard extends StatelessWidget {
const MembreCard({
super.key,
required this.membre,
this.onTap,
this.onEdit,
this.onDelete,
});
final MembreModel membre;
final VoidCallback? onTap;
final VoidCallback? onEdit;
final VoidCallback? onDelete;
@override
Widget build(BuildContext context) {
return Card(
elevation: 2,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
child: InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(12),
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Header avec avatar et actions
Row(
children: [
// Avatar
CircleAvatar(
radius: 24,
backgroundColor: AppTheme.primaryColor,
child: Text(
membre.initiales,
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.w600,
fontSize: 16,
),
),
),
const SizedBox(width: 12),
// Informations principales
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
membre.nomComplet,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: AppTheme.textPrimary,
),
),
const SizedBox(height: 2),
Text(
membre.numeroMembre,
style: const TextStyle(
fontSize: 12,
color: AppTheme.textSecondary,
fontFamily: 'monospace',
),
),
],
),
),
// Badge de statut
Container(
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 4,
),
decoration: BoxDecoration(
color: _getStatusColor(membre.statut).withOpacity(0.1),
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: _getStatusColor(membre.statut),
width: 1,
),
),
child: Text(
_getStatusLabel(membre.statut),
style: TextStyle(
fontSize: 10,
fontWeight: FontWeight.w600,
color: _getStatusColor(membre.statut),
),
),
),
// Menu d'actions
PopupMenuButton<String>(
icon: const Icon(
Icons.more_vert,
color: AppTheme.textSecondary,
),
onSelected: (value) {
switch (value) {
case 'edit':
onEdit?.call();
break;
case 'delete':
onDelete?.call();
break;
}
},
itemBuilder: (context) => [
const PopupMenuItem(
value: 'edit',
child: Row(
children: [
Icon(Icons.edit, size: 16),
SizedBox(width: 8),
Text('Modifier'),
],
),
),
const PopupMenuItem(
value: 'delete',
child: Row(
children: [
Icon(Icons.delete, size: 16, color: AppTheme.errorColor),
SizedBox(width: 8),
Text('Supprimer', style: TextStyle(color: AppTheme.errorColor)),
],
),
),
],
),
],
),
const SizedBox(height: 12),
// Informations de contact
Row(
children: [
Expanded(
child: _buildInfoItem(
icon: Icons.email_outlined,
text: membre.email,
),
),
const SizedBox(width: 16),
Expanded(
child: _buildInfoItem(
icon: Icons.phone_outlined,
text: membre.telephone,
),
),
],
),
// Adresse si disponible
if (membre.adresseComplete.isNotEmpty) ...[
const SizedBox(height: 8),
_buildInfoItem(
icon: Icons.location_on_outlined,
text: membre.adresseComplete,
),
],
// Profession si disponible
if (membre.profession?.isNotEmpty == true) ...[
const SizedBox(height: 8),
_buildInfoItem(
icon: Icons.work_outline,
text: membre.profession!,
),
],
const SizedBox(height: 8),
// Footer avec date d'adhésion
Row(
children: [
Icon(
Icons.calendar_today_outlined,
size: 14,
color: AppTheme.textHint,
),
const SizedBox(width: 4),
Text(
'Membre depuis ${_formatDate(membre.dateAdhesion)}',
style: const TextStyle(
fontSize: 12,
color: AppTheme.textHint,
),
),
],
),
],
),
),
),
);
}
/// Widget pour afficher une information avec icône
Widget _buildInfoItem({
required IconData icon,
required String text,
}) {
return Row(
children: [
Icon(
icon,
size: 14,
color: AppTheme.textSecondary,
),
const SizedBox(width: 4),
Expanded(
child: Text(
text,
style: const TextStyle(
fontSize: 12,
color: AppTheme.textSecondary,
),
overflow: TextOverflow.ellipsis,
),
),
],
);
}
/// Retourne la couleur associée au statut
Color _getStatusColor(String statut) {
switch (statut.toUpperCase()) {
case 'ACTIF':
return AppTheme.successColor;
case 'INACTIF':
return AppTheme.warningColor;
case 'SUSPENDU':
return AppTheme.errorColor;
default:
return AppTheme.textSecondary;
}
}
/// Retourne le label du statut
String _getStatusLabel(String statut) {
switch (statut.toUpperCase()) {
case 'ACTIF':
return 'ACTIF';
case 'INACTIF':
return 'INACTIF';
case 'SUSPENDU':
return 'SUSPENDU';
default:
return statut.toUpperCase();
}
}
/// Formate une date pour l'affichage
String _formatDate(DateTime date) {
final now = DateTime.now();
final difference = now.difference(date);
if (difference.inDays < 30) {
return '${difference.inDays} jours';
} else if (difference.inDays < 365) {
final months = (difference.inDays / 30).floor();
return '$months mois';
} else {
final years = (difference.inDays / 365).floor();
return '$years an${years > 1 ? 's' : ''}';
}
}
}

View File

@@ -0,0 +1,128 @@
import 'package:flutter/material.dart';
import '../../../../shared/theme/app_theme.dart';
/// Barre de recherche pour les membres
class MembresSearchBar extends StatefulWidget {
const MembresSearchBar({
super.key,
required this.controller,
required this.onSearch,
required this.onClear,
this.hintText = 'Rechercher un membre...',
});
final TextEditingController controller;
final ValueChanged<String> onSearch;
final VoidCallback onClear;
final String hintText;
@override
State<MembresSearchBar> createState() => _MembresSearchBarState();
}
class _MembresSearchBarState extends State<MembresSearchBar> {
bool _isSearching = false;
@override
void initState() {
super.initState();
widget.controller.addListener(_onTextChanged);
}
@override
void dispose() {
widget.controller.removeListener(_onTextChanged);
super.dispose();
}
void _onTextChanged() {
final hasText = widget.controller.text.isNotEmpty;
if (_isSearching != hasText) {
setState(() {
_isSearching = hasText;
});
}
}
void _onSubmitted(String value) {
if (value.trim().isNotEmpty) {
widget.onSearch(value.trim());
} else {
widget.onClear();
}
}
void _onClearPressed() {
widget.controller.clear();
widget.onClear();
FocusScope.of(context).unfocus();
}
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
blurRadius: 8,
offset: const Offset(0, 2),
),
],
),
child: TextField(
controller: widget.controller,
onSubmitted: _onSubmitted,
textInputAction: TextInputAction.search,
decoration: InputDecoration(
hintText: widget.hintText,
hintStyle: const TextStyle(
color: AppTheme.textHint,
fontSize: 16,
),
prefixIcon: const Icon(
Icons.search,
color: AppTheme.textSecondary,
),
suffixIcon: _isSearching
? IconButton(
icon: const Icon(
Icons.clear,
color: AppTheme.textSecondary,
),
onPressed: _onClearPressed,
tooltip: 'Effacer la recherche',
)
: null,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide.none,
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide.none,
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: const BorderSide(
color: AppTheme.primaryColor,
width: 2,
),
),
filled: true,
fillColor: Colors.white,
contentPadding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 12,
),
),
style: const TextStyle(
fontSize: 16,
color: AppTheme.textPrimary,
),
),
);
}
}

View File

@@ -0,0 +1,253 @@
import 'package:flutter/material.dart';
import 'package:fl_chart/fl_chart.dart';
import '../../../../shared/theme/app_theme.dart';
/// Card pour afficher les statistiques des membres
class MembresStatsCard extends StatelessWidget {
const MembresStatsCard({
super.key,
required this.stats,
});
final Map<String, dynamic> stats;
@override
Widget build(BuildContext context) {
final nombreMembresActifs = stats['nombreMembresActifs'] as int? ?? 0;
final nombreMembresInactifs = stats['nombreMembresInactifs'] as int? ?? 0;
final nombreMembresSuspendus = stats['nombreMembresSuspendus'] as int? ?? 0;
final total = nombreMembresActifs + nombreMembresInactifs + nombreMembresSuspendus;
return Card(
elevation: 4,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
child: Padding(
padding: const EdgeInsets.all(20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Header
Row(
children: [
Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: AppTheme.primaryColor.withOpacity(0.1),
borderRadius: BorderRadius.circular(8),
),
child: const Icon(
Icons.analytics,
color: AppTheme.primaryColor,
size: 24,
),
),
const SizedBox(width: 12),
const Expanded(
child: Text(
'Statistiques des membres',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
color: AppTheme.textPrimary,
),
),
),
],
),
const SizedBox(height: 20),
// Statistiques principales
Row(
children: [
Expanded(
child: _buildStatItem(
title: 'Total',
value: total.toString(),
color: AppTheme.primaryColor,
icon: Icons.people,
),
),
const SizedBox(width: 16),
Expanded(
child: _buildStatItem(
title: 'Actifs',
value: nombreMembresActifs.toString(),
color: AppTheme.successColor,
icon: Icons.check_circle,
),
),
],
),
const SizedBox(height: 12),
Row(
children: [
Expanded(
child: _buildStatItem(
title: 'Inactifs',
value: nombreMembresInactifs.toString(),
color: AppTheme.warningColor,
icon: Icons.pause_circle,
),
),
const SizedBox(width: 16),
Expanded(
child: _buildStatItem(
title: 'Suspendus',
value: nombreMembresSuspendus.toString(),
color: AppTheme.errorColor,
icon: Icons.block,
),
),
],
),
if (total > 0) ...[
const SizedBox(height: 24),
// Graphique en secteurs
SizedBox(
height: 200,
child: PieChart(
PieChartData(
sections: [
if (nombreMembresActifs > 0)
PieChartSectionData(
value: nombreMembresActifs.toDouble(),
title: '${(nombreMembresActifs / total * 100).round()}%',
color: AppTheme.successColor,
radius: 60,
titleStyle: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
color: Colors.white,
),
),
if (nombreMembresInactifs > 0)
PieChartSectionData(
value: nombreMembresInactifs.toDouble(),
title: '${(nombreMembresInactifs / total * 100).round()}%',
color: AppTheme.warningColor,
radius: 60,
titleStyle: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
color: Colors.white,
),
),
if (nombreMembresSuspendus > 0)
PieChartSectionData(
value: nombreMembresSuspendus.toDouble(),
title: '${(nombreMembresSuspendus / total * 100).round()}%',
color: AppTheme.errorColor,
radius: 60,
titleStyle: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
color: Colors.white,
),
),
],
centerSpaceRadius: 40,
sectionsSpace: 2,
),
),
),
const SizedBox(height: 16),
// Légende
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
if (nombreMembresActifs > 0)
_buildLegendItem('Actifs', AppTheme.successColor),
if (nombreMembresInactifs > 0)
_buildLegendItem('Inactifs', AppTheme.warningColor),
if (nombreMembresSuspendus > 0)
_buildLegendItem('Suspendus', AppTheme.errorColor),
],
),
],
],
),
),
);
}
/// Widget pour une statistique individuelle
Widget _buildStatItem({
required String title,
required String value,
required Color color,
required IconData icon,
}) {
return Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: color.withOpacity(0.1),
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: color.withOpacity(0.3),
width: 1,
),
),
child: Column(
children: [
Icon(
icon,
color: color,
size: 24,
),
const SizedBox(height: 8),
Text(
value,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w700,
color: color,
),
),
const SizedBox(height: 4),
Text(
title,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
color: color,
),
),
],
),
);
}
/// Widget pour un élément de légende
Widget _buildLegendItem(String label, Color color) {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
Container(
width: 12,
height: 12,
decoration: BoxDecoration(
color: color,
shape: BoxShape.circle,
),
),
const SizedBox(width: 6),
Text(
label,
style: const TextStyle(
fontSize: 12,
color: AppTheme.textSecondary,
),
),
],
);
}
}

View File

@@ -4,7 +4,7 @@ import '../../../../shared/theme/app_theme.dart';
import '../../../../shared/widgets/coming_soon_page.dart';
import '../../../../shared/widgets/buttons/buttons.dart';
import '../../../dashboard/presentation/pages/enhanced_dashboard.dart';
import '../../../members/presentation/pages/members_list_page.dart';
import '../../../members/presentation/pages/membres_list_page.dart';
import '../widgets/custom_bottom_nav_bar.dart';
class MainNavigation extends StatefulWidget {
@@ -17,14 +17,12 @@ class MainNavigation extends StatefulWidget {
class _MainNavigationState extends State<MainNavigation>
with TickerProviderStateMixin {
int _currentIndex = 0;
late PageController _pageController;
late AnimationController _fabAnimationController;
late Animation<double> _fabAnimation;
@override
void initState() {
super.initState();
_pageController = PageController();
_fabAnimationController = AnimationController(
duration: const Duration(milliseconds: 300),
@@ -44,7 +42,6 @@ class _MainNavigationState extends State<MainNavigation>
@override
void dispose() {
_pageController.dispose();
_fabAnimationController.dispose();
super.dispose();
}
@@ -85,9 +82,8 @@ class _MainNavigationState extends State<MainNavigation>
@override
Widget build(BuildContext context) {
return Scaffold(
body: PageView(
controller: _pageController,
onPageChanged: _onPageChanged,
body: IndexedStack(
index: _currentIndex,
children: [
EnhancedDashboard(
onNavigateToTab: _onTabTapped,
@@ -151,33 +147,23 @@ class _MainNavigationState extends State<MainNavigation>
}
}
void _onPageChanged(int index) {
setState(() {
_currentIndex = index;
});
// Animation du FAB
if (index == 1 || index == 2 || index == 3) {
_fabAnimationController.forward();
} else {
_fabAnimationController.reverse();
}
// Vibration légère
HapticFeedback.selectionClick();
}
void _onTabTapped(int index) {
if (_currentIndex != index) {
setState(() {
_currentIndex = index;
});
_pageController.animateToPage(
index,
duration: const Duration(milliseconds: 300),
curve: Curves.easeInOut,
);
// Animation du FAB
if (index == 1 || index == 2 || index == 3) {
_fabAnimationController.forward();
} else {
_fabAnimationController.reverse();
}
// Vibration légère
HapticFeedback.selectionClick();
}
}
@@ -219,11 +205,11 @@ class _MainNavigationState extends State<MainNavigation>
}
Widget _buildMembresPage() {
return MembersListPage();
return const MembresListPage();
}
Widget _buildCotisationsPage() {
return ComingSoonPage(
return const ComingSoonPage(
title: 'Module Cotisations',
description: 'Suivi et gestion des cotisations avec paiements automatiques',
icon: Icons.payment_rounded,
@@ -240,7 +226,7 @@ class _MainNavigationState extends State<MainNavigation>
}
Widget _buildEventsPage() {
return ComingSoonPage(
return const ComingSoonPage(
title: 'Module Événements',
description: 'Organisation et gestion d\'événements avec calendrier intégré',
icon: Icons.event_rounded,
@@ -257,51 +243,75 @@ class _MainNavigationState extends State<MainNavigation>
}
Widget _buildMorePage() {
return Scaffold(
backgroundColor: AppTheme.backgroundLight,
appBar: AppBar(
title: const Text('Plus'),
backgroundColor: AppTheme.infoColor,
elevation: 0,
automaticallyImplyLeading: false,
actions: [
IconButton(
icon: const Icon(Icons.settings),
onPressed: () {},
),
],
),
body: ListView(
padding: const EdgeInsets.all(16),
return Container(
color: AppTheme.backgroundLight,
child: Column(
children: [
_buildMoreSection(
'Gestion',
[
_buildMoreItem(Icons.analytics, 'Rapports', 'Génération de rapports'),
_buildMoreItem(Icons.account_balance, 'Finances', 'Tableau de bord financier'),
_buildMoreItem(Icons.message, 'Communications', 'Messages et notifications'),
_buildMoreItem(Icons.folder, 'Documents', 'Gestion documentaire'),
],
// Header personnalisé au lieu d'AppBar
Container(
width: double.infinity,
padding: const EdgeInsets.fromLTRB(16, 50, 16, 16),
decoration: const BoxDecoration(
color: AppTheme.infoColor,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(20),
bottomRight: Radius.circular(20),
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
'Plus',
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
IconButton(
icon: const Icon(Icons.settings, color: Colors.white),
onPressed: () {},
),
],
),
),
const SizedBox(height: 24),
_buildMoreSection(
'Paramètres',
[
_buildMoreItem(Icons.person, 'Mon profil', 'Informations personnelles'),
_buildMoreItem(Icons.notifications, 'Notifications', 'Préférences de notification'),
_buildMoreItem(Icons.security, 'Sécurité', 'Mot de passe et sécurité'),
_buildMoreItem(Icons.language, 'Langue', 'Changer la langue'),
],
),
const SizedBox(height: 24),
_buildMoreSection(
'Support',
[
_buildMoreItem(Icons.help, 'Aide', 'Centre d\'aide et FAQ'),
_buildMoreItem(Icons.contact_support, 'Contact', 'Nous contacter'),
_buildMoreItem(Icons.info, 'À propos', 'Informations sur l\'application'),
_buildMoreItem(Icons.logout, 'Déconnexion', 'Se déconnecter', isDestructive: true),
],
// Contenu scrollable
Expanded(
child: ListView(
padding: const EdgeInsets.all(16),
children: [
_buildMoreSection(
'Gestion',
[
_buildMoreItem(Icons.analytics, 'Rapports', 'Génération de rapports'),
_buildMoreItem(Icons.account_balance, 'Finances', 'Tableau de bord financier'),
_buildMoreItem(Icons.message, 'Communications', 'Messages et notifications'),
_buildMoreItem(Icons.folder, 'Documents', 'Gestion documentaire'),
],
),
const SizedBox(height: 24),
_buildMoreSection(
'Paramètres',
[
_buildMoreItem(Icons.person, 'Mon profil', 'Informations personnelles'),
_buildMoreItem(Icons.notifications, 'Notifications', 'Préférences de notification'),
_buildMoreItem(Icons.security, 'Sécurité', 'Mot de passe et sécurité'),
_buildMoreItem(Icons.language, 'Langue', 'Changer la langue'),
],
),
const SizedBox(height: 24),
_buildMoreSection(
'Support',
[
_buildMoreItem(Icons.help, 'Aide', 'Centre d\'aide et FAQ'),
_buildMoreItem(Icons.contact_support, 'Contact', 'Nous contacter'),
_buildMoreItem(Icons.info, 'À propos', 'Informations sur l\'application'),
_buildMoreItem(Icons.logout, 'Déconnexion', 'Se déconnecter', isDestructive: true),
],
),
],
),
),
],
),