Alignement design systeme OK

This commit is contained in:
DahoudG
2025-09-20 03:56:11 +00:00
parent a1214bc116
commit 96a17eadbd
34 changed files with 11720 additions and 766 deletions

View File

@@ -0,0 +1,433 @@
import 'package:flutter/material.dart';
import '../../../../core/models/membre_search_criteria.dart';
/// Formulaire de recherche de membres
/// Widget réutilisable pour la saisie des critères de recherche
class MembreSearchForm extends StatefulWidget {
final MembreSearchCriteria initialCriteria;
final Function(MembreSearchCriteria) onCriteriaChanged;
final VoidCallback? onSearch;
final VoidCallback? onClear;
final bool isCompact;
const MembreSearchForm({
super.key,
this.initialCriteria = MembreSearchCriteria.empty,
required this.onCriteriaChanged,
this.onSearch,
this.onClear,
this.isCompact = false,
});
@override
State<MembreSearchForm> createState() => _MembreSearchFormState();
}
class _MembreSearchFormState extends State<MembreSearchForm> {
late TextEditingController _queryController;
late TextEditingController _nomController;
late TextEditingController _prenomController;
late TextEditingController _emailController;
late TextEditingController _telephoneController;
String? _selectedStatut;
List<String> _selectedRoles = [];
RangeValues _ageRange = const RangeValues(18, 65);
bool _includeInactifs = false;
bool _membreBureau = false;
bool _responsable = false;
@override
void initState() {
super.initState();
_initializeControllers();
_loadInitialCriteria();
}
@override
void dispose() {
_queryController.dispose();
_nomController.dispose();
_prenomController.dispose();
_emailController.dispose();
_telephoneController.dispose();
super.dispose();
}
void _initializeControllers() {
_queryController = TextEditingController();
_nomController = TextEditingController();
_prenomController = TextEditingController();
_emailController = TextEditingController();
_telephoneController = TextEditingController();
// Écouter les changements pour mettre à jour les critères
_queryController.addListener(_updateCriteria);
_nomController.addListener(_updateCriteria);
_prenomController.addListener(_updateCriteria);
_emailController.addListener(_updateCriteria);
_telephoneController.addListener(_updateCriteria);
}
void _loadInitialCriteria() {
final criteria = widget.initialCriteria;
_queryController.text = criteria.query ?? '';
_nomController.text = criteria.nom ?? '';
_prenomController.text = criteria.prenom ?? '';
_emailController.text = criteria.email ?? '';
_telephoneController.text = criteria.telephone ?? '';
_selectedStatut = criteria.statut;
_selectedRoles = criteria.roles ?? [];
_ageRange = RangeValues(
criteria.ageMin?.toDouble() ?? 18,
criteria.ageMax?.toDouble() ?? 65,
);
_includeInactifs = criteria.includeInactifs;
_membreBureau = criteria.membreBureau ?? false;
_responsable = criteria.responsable ?? false;
}
@override
Widget build(BuildContext context) {
if (widget.isCompact) {
return _buildCompactForm();
}
return _buildFullForm();
}
/// Formulaire compact pour recherche rapide
Widget _buildCompactForm() {
return Card(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
TextField(
controller: _queryController,
decoration: InputDecoration(
labelText: 'Rechercher un membre',
hintText: 'Nom, prénom ou email...',
prefixIcon: const Icon(Icons.search),
suffixIcon: _queryController.text.isNotEmpty
? IconButton(
icon: const Icon(Icons.clear),
onPressed: () {
_queryController.clear();
_updateCriteria();
},
)
: null,
border: const OutlineInputBorder(),
),
onSubmitted: (_) => widget.onSearch?.call(),
),
const SizedBox(height: 12),
Row(
children: [
Expanded(
child: DropdownButtonFormField<String>(
value: _selectedStatut,
decoration: const InputDecoration(
labelText: 'Statut',
border: OutlineInputBorder(),
isDense: true,
),
items: const [
DropdownMenuItem(value: null, child: Text('Tous')),
DropdownMenuItem(value: 'ACTIF', child: Text('Actif')),
DropdownMenuItem(value: 'INACTIF', child: Text('Inactif')),
],
onChanged: (value) {
setState(() => _selectedStatut = value);
_updateCriteria();
},
),
),
const SizedBox(width: 12),
if (widget.onSearch != null)
ElevatedButton.icon(
onPressed: widget.onSearch,
icon: const Icon(Icons.search),
label: const Text('Rechercher'),
),
],
),
],
),
),
);
}
/// Formulaire complet avec tous les critères
Widget _buildFullForm() {
return Column(
children: [
// Recherche générale
_buildGeneralSearchSection(),
const SizedBox(height: 16),
// Critères détaillés
_buildDetailedCriteriaSection(),
const SizedBox(height: 16),
// Filtres avancés
_buildAdvancedFiltersSection(),
const SizedBox(height: 16),
// Boutons d'action
_buildActionButtons(),
],
);
}
/// Section de recherche générale
Widget _buildGeneralSearchSection() {
return Card(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Recherche Générale',
style: Theme.of(context).textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 16),
TextField(
controller: _queryController,
decoration: const InputDecoration(
labelText: 'Terme de recherche',
hintText: 'Nom, prénom, email...',
prefixIcon: Icon(Icons.search),
border: OutlineInputBorder(),
),
),
],
),
),
);
}
/// Section des critères détaillés
Widget _buildDetailedCriteriaSection() {
return Card(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Critères Détaillés',
style: Theme.of(context).textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 16),
Row(
children: [
Expanded(
child: TextField(
controller: _nomController,
decoration: const InputDecoration(
labelText: 'Nom',
border: OutlineInputBorder(),
),
),
),
const SizedBox(width: 12),
Expanded(
child: TextField(
controller: _prenomController,
decoration: const InputDecoration(
labelText: 'Prénom',
border: OutlineInputBorder(),
),
),
),
],
),
const SizedBox(height: 16),
TextField(
controller: _emailController,
decoration: const InputDecoration(
labelText: 'Email',
border: OutlineInputBorder(),
),
),
const SizedBox(height: 16),
Row(
children: [
Expanded(
child: TextField(
controller: _telephoneController,
decoration: const InputDecoration(
labelText: 'Téléphone',
border: OutlineInputBorder(),
),
),
),
const SizedBox(width: 12),
Expanded(
child: DropdownButtonFormField<String>(
value: _selectedStatut,
decoration: const InputDecoration(
labelText: 'Statut',
border: OutlineInputBorder(),
),
items: const [
DropdownMenuItem(value: null, child: Text('Tous')),
DropdownMenuItem(value: 'ACTIF', child: Text('Actif')),
DropdownMenuItem(value: 'INACTIF', child: Text('Inactif')),
DropdownMenuItem(value: 'SUSPENDU', child: Text('Suspendu')),
DropdownMenuItem(value: 'RADIE', child: Text('Radié')),
],
onChanged: (value) {
setState(() => _selectedStatut = value);
_updateCriteria();
},
),
),
],
),
],
),
),
);
}
/// Section des filtres avancés
Widget _buildAdvancedFiltersSection() {
return Card(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Filtres Avancés',
style: Theme.of(context).textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 16),
// Tranche d'âge
Text('Tranche d\'âge: ${_ageRange.start.round()}-${_ageRange.end.round()} ans'),
RangeSlider(
values: _ageRange,
min: 18,
max: 80,
divisions: 62,
labels: RangeLabels(
'${_ageRange.start.round()}',
'${_ageRange.end.round()}',
),
onChanged: (values) {
setState(() => _ageRange = values);
_updateCriteria();
},
),
const SizedBox(height: 16),
// Options booléennes
CheckboxListTile(
title: const Text('Inclure les membres inactifs'),
value: _includeInactifs,
onChanged: (value) {
setState(() => _includeInactifs = value ?? false);
_updateCriteria();
},
),
CheckboxListTile(
title: const Text('Membres du bureau uniquement'),
value: _membreBureau,
onChanged: (value) {
setState(() => _membreBureau = value ?? false);
_updateCriteria();
},
),
CheckboxListTile(
title: const Text('Responsables uniquement'),
value: _responsable,
onChanged: (value) {
setState(() => _responsable = value ?? false);
_updateCriteria();
},
),
],
),
),
);
}
/// Boutons d'action
Widget _buildActionButtons() {
return Row(
children: [
if (widget.onClear != null)
Expanded(
child: OutlinedButton.icon(
onPressed: () {
_clearForm();
widget.onClear?.call();
},
icon: const Icon(Icons.clear),
label: const Text('Effacer'),
),
),
if (widget.onClear != null && widget.onSearch != null)
const SizedBox(width: 16),
if (widget.onSearch != null)
Expanded(
flex: widget.onClear != null ? 2 : 1,
child: ElevatedButton.icon(
onPressed: widget.onSearch,
icon: const Icon(Icons.search),
label: const Text('Rechercher'),
),
),
],
);
}
/// Met à jour les critères de recherche
void _updateCriteria() {
final criteria = MembreSearchCriteria(
query: _queryController.text.trim().isEmpty ? null : _queryController.text.trim(),
nom: _nomController.text.trim().isEmpty ? null : _nomController.text.trim(),
prenom: _prenomController.text.trim().isEmpty ? null : _prenomController.text.trim(),
email: _emailController.text.trim().isEmpty ? null : _emailController.text.trim(),
telephone: _telephoneController.text.trim().isEmpty ? null : _telephoneController.text.trim(),
statut: _selectedStatut,
roles: _selectedRoles.isEmpty ? null : _selectedRoles,
ageMin: _ageRange.start.round(),
ageMax: _ageRange.end.round(),
membreBureau: _membreBureau ? true : null,
responsable: _responsable ? true : null,
includeInactifs: _includeInactifs,
);
widget.onCriteriaChanged(criteria);
}
/// Efface le formulaire
void _clearForm() {
setState(() {
_queryController.clear();
_nomController.clear();
_prenomController.clear();
_emailController.clear();
_telephoneController.clear();
_selectedStatut = null;
_selectedRoles.clear();
_ageRange = const RangeValues(18, 65);
_includeInactifs = false;
_membreBureau = false;
_responsable = false;
});
_updateCriteria();
}
}

View File

@@ -0,0 +1,388 @@
import 'package:flutter/material.dart';
import '../../../../core/models/membre_search_result.dart' as search_model;
import '../../data/models/membre_model.dart' as member_model;
/// Widget d'affichage des résultats de recherche de membres
/// Gère la pagination, le tri et l'affichage des membres trouvés
class MembreSearchResults extends StatefulWidget {
final search_model.MembreSearchResult result;
final Function(member_model.MembreModel)? onMembreSelected;
final bool showPagination;
const MembreSearchResults({
super.key,
required this.result,
this.onMembreSelected,
this.showPagination = true,
});
@override
State<MembreSearchResults> createState() => _MembreSearchResultsState();
}
class _MembreSearchResultsState extends State<MembreSearchResults> {
@override
Widget build(BuildContext context) {
if (widget.result.isEmpty) {
return _buildEmptyState();
}
return Column(
children: [
// En-tête avec informations sur les résultats
_buildResultsHeader(),
// Liste des membres
Expanded(
child: _buildMembersList(),
),
// Pagination si activée
if (widget.showPagination && widget.result.totalPages > 1)
_buildPagination(),
],
);
}
/// État vide quand aucun résultat
Widget _buildEmptyState() {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.search_off,
size: 64,
color: Colors.grey[400],
),
const SizedBox(height: 16),
Text(
'Aucun membre trouvé',
style: Theme.of(context).textTheme.titleLarge?.copyWith(
color: Colors.grey[600],
),
),
const SizedBox(height: 8),
Text(
'Essayez de modifier vos critères de recherche',
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: Colors.grey[500],
),
),
const SizedBox(height: 24),
ElevatedButton.icon(
onPressed: () => Navigator.of(context).pop(),
icon: const Icon(Icons.tune),
label: const Text('Modifier les critères'),
),
],
),
);
}
/// En-tête avec informations sur les résultats
Widget _buildResultsHeader() {
return Container(
padding: const EdgeInsets.all(16.0),
decoration: BoxDecoration(
color: Theme.of(context).primaryColor.withOpacity(0.1),
border: Border(
bottom: BorderSide(
color: Theme.of(context).dividerColor,
width: 1,
),
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Icon(
Icons.search,
color: Theme.of(context).primaryColor,
size: 20,
),
const SizedBox(width: 8),
Expanded(
child: Text(
widget.result.resultDescription,
style: Theme.of(context).textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.bold,
),
),
),
Chip(
label: Text('${widget.result.executionTimeMs}ms'),
backgroundColor: Colors.green.withOpacity(0.1),
labelStyle: const TextStyle(
color: Colors.green,
fontSize: 12,
),
),
],
),
if (widget.result.criteria.description.isNotEmpty) ...[
const SizedBox(height: 8),
Text(
'Critères: ${widget.result.criteria.description}',
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: Colors.grey[600],
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
],
],
),
);
}
/// Liste des membres trouvés
Widget _buildMembersList() {
return ListView.builder(
itemCount: widget.result.membres.length,
itemBuilder: (context, index) {
final membre = widget.result.membres[index];
return _buildMembreCard(membre, index);
},
);
}
/// Carte d'affichage d'un membre
Widget _buildMembreCard(member_model.MembreModel membre, int index) {
return Card(
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
child: ListTile(
leading: CircleAvatar(
backgroundColor: _getStatusColor(membre.statut ?? 'ACTIF'),
child: Text(
_getInitials(membre.nom, membre.prenom),
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
),
title: Text(
'${membre.prenom} ${membre.nom}',
style: const TextStyle(fontWeight: FontWeight.bold),
),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (membre.email.isNotEmpty)
Row(
children: [
const Icon(Icons.email, size: 14, color: Colors.grey),
const SizedBox(width: 4),
Expanded(
child: Text(
membre.email,
style: const TextStyle(fontSize: 12),
overflow: TextOverflow.ellipsis,
),
),
],
),
if (membre.telephone?.isNotEmpty == true)
Row(
children: [
const Icon(Icons.phone, size: 14, color: Colors.grey),
const SizedBox(width: 4),
Text(
membre.telephone!,
style: const TextStyle(fontSize: 12),
),
],
),
if (membre.organisation?.nom?.isNotEmpty == true)
Row(
children: [
const Icon(Icons.business, size: 14, color: Colors.grey),
const SizedBox(width: 4),
Expanded(
child: Text(
membre.organisation!.nom!,
style: const TextStyle(fontSize: 12),
overflow: TextOverflow.ellipsis,
),
),
],
),
],
),
trailing: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
_buildStatusChip(membre.statut ?? 'ACTIF'),
if (membre.role?.isNotEmpty == true) ...[
const SizedBox(height: 4),
Text(
_formatRoles(membre.role!),
style: const TextStyle(
fontSize: 10,
color: Colors.grey,
),
textAlign: TextAlign.center,
),
],
],
),
onTap: widget.onMembreSelected != null
? () => widget.onMembreSelected!(membre)
: null,
),
);
}
/// Pagination
Widget _buildPagination() {
return Container(
padding: const EdgeInsets.all(16.0),
decoration: BoxDecoration(
color: Theme.of(context).cardColor,
border: Border(
top: BorderSide(
color: Theme.of(context).dividerColor,
width: 1,
),
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
// Bouton page précédente
ElevatedButton.icon(
onPressed: widget.result.hasPrevious ? _goToPreviousPage : null,
icon: const Icon(Icons.chevron_left),
label: const Text('Précédent'),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.grey[100],
foregroundColor: Colors.grey[700],
),
),
// Indicateur de page
Container(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
decoration: BoxDecoration(
color: Theme.of(context).primaryColor.withOpacity(0.1),
borderRadius: BorderRadius.circular(20),
),
child: Text(
'Page ${widget.result.currentPage + 1} / ${widget.result.totalPages}',
style: TextStyle(
color: Theme.of(context).primaryColor,
fontWeight: FontWeight.bold,
),
),
),
// Bouton page suivante
ElevatedButton.icon(
onPressed: widget.result.hasNext ? _goToNextPage : null,
icon: const Icon(Icons.chevron_right),
label: const Text('Suivant'),
style: ElevatedButton.styleFrom(
backgroundColor: Theme.of(context).primaryColor,
foregroundColor: Colors.white,
),
),
],
),
);
}
/// Chip de statut
Widget _buildStatusChip(String statut) {
final color = _getStatusColor(statut);
return Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
decoration: BoxDecoration(
color: color.withOpacity(0.1),
borderRadius: BorderRadius.circular(12),
border: Border.all(color: color, width: 1),
),
child: Text(
_getStatusLabel(statut),
style: TextStyle(
color: color,
fontSize: 10,
fontWeight: FontWeight.bold,
),
),
);
}
/// Obtient la couleur du statut
Color _getStatusColor(String statut) {
switch (statut.toUpperCase()) {
case 'ACTIF':
return Colors.green;
case 'INACTIF':
return Colors.orange;
case 'SUSPENDU':
return Colors.red;
case 'RADIE':
return Colors.grey;
default:
return Colors.grey;
}
}
/// Obtient le libellé du statut
String _getStatusLabel(String statut) {
switch (statut.toUpperCase()) {
case 'ACTIF':
return 'Actif';
case 'INACTIF':
return 'Inactif';
case 'SUSPENDU':
return 'Suspendu';
case 'RADIE':
return 'Radié';
default:
return statut;
}
}
/// Obtient les initiales d'un membre
String _getInitials(String nom, String prenom) {
final nomInitial = nom.isNotEmpty ? nom[0].toUpperCase() : '';
final prenomInitial = prenom.isNotEmpty ? prenom[0].toUpperCase() : '';
return '$prenomInitial$nomInitial';
}
/// Formate les rôles pour l'affichage
String _formatRoles(String roles) {
final rolesList = roles.split(',').map((r) => r.trim()).toList();
if (rolesList.length <= 2) {
return rolesList.join(', ');
}
return '${rolesList.take(2).join(', ')}...';
}
/// Navigation vers la page précédente
void _goToPreviousPage() {
// TODO: Implémenter la navigation vers la page précédente
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Navigation vers la page précédente'),
duration: Duration(seconds: 1),
),
);
}
/// Navigation vers la page suivante
void _goToNextPage() {
// TODO: Implémenter la navigation vers la page suivante
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Navigation vers la page suivante'),
duration: Duration(seconds: 1),
),
);
}
}

View File

@@ -0,0 +1,416 @@
import 'package:flutter/material.dart';
import 'package:fl_chart/fl_chart.dart';
import '../../../../core/models/membre_search_result.dart';
/// Widget d'affichage des statistiques de recherche
/// Présente les métriques et graphiques des résultats de recherche
class SearchStatisticsCard extends StatelessWidget {
final SearchStatistics statistics;
const SearchStatisticsCard({
super.key,
required this.statistics,
});
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Titre
Row(
children: [
Icon(
Icons.analytics,
color: Theme.of(context).primaryColor,
size: 24,
),
const SizedBox(width: 8),
Text(
'Statistiques de Recherche',
style: Theme.of(context).textTheme.titleLarge?.copyWith(
fontWeight: FontWeight.bold,
),
),
],
),
const SizedBox(height: 24),
// Métriques principales
_buildMainMetrics(context),
const SizedBox(height: 24),
// Graphique de répartition actifs/inactifs
_buildStatusChart(context),
const SizedBox(height: 24),
// Métriques détaillées
_buildDetailedMetrics(context),
const SizedBox(height: 24),
// Informations complémentaires
_buildAdditionalInfo(context),
],
),
);
}
/// Métriques principales
Widget _buildMainMetrics(BuildContext context) {
return Card(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Vue d\'ensemble',
style: Theme.of(context).textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 16),
Row(
children: [
Expanded(
child: _buildMetricCard(
context,
'Total Membres',
statistics.totalMembres.toString(),
Icons.people,
Colors.blue,
),
),
const SizedBox(width: 12),
Expanded(
child: _buildMetricCard(
context,
'Membres Actifs',
statistics.membresActifs.toString(),
Icons.person,
Colors.green,
),
),
],
),
const SizedBox(height: 12),
Row(
children: [
Expanded(
child: _buildMetricCard(
context,
'Âge Moyen',
'${statistics.ageMoyen.toStringAsFixed(1)} ans',
Icons.cake,
Colors.orange,
),
),
const SizedBox(width: 12),
Expanded(
child: _buildMetricCard(
context,
'Ancienneté',
'${statistics.ancienneteMoyenne.toStringAsFixed(1)} ans',
Icons.schedule,
Colors.purple,
),
),
],
),
],
),
),
);
}
/// Carte de métrique individuelle
Widget _buildMetricCard(
BuildContext context,
String title,
String value,
IconData icon,
Color color,
) {
return Container(
padding: const EdgeInsets.all(12.0),
decoration: BoxDecoration(
color: color.withOpacity(0.1),
borderRadius: BorderRadius.circular(8),
border: Border.all(color: color.withOpacity(0.3)),
),
child: Column(
children: [
Icon(icon, color: color, size: 24),
const SizedBox(height: 8),
Text(
value,
style: Theme.of(context).textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.bold,
color: color,
),
),
Text(
title,
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: Colors.grey[600],
),
textAlign: TextAlign.center,
),
],
),
);
}
/// Graphique de répartition des statuts
Widget _buildStatusChart(BuildContext context) {
if (statistics.totalMembres == 0) {
return const SizedBox.shrink();
}
return Card(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Répartition par Statut',
style: Theme.of(context).textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 16),
SizedBox(
height: 200,
child: Row(
children: [
// Graphique en secteurs
Expanded(
flex: 2,
child: PieChart(
PieChartData(
sections: [
PieChartSectionData(
value: statistics.membresActifs.toDouble(),
title: '${statistics.pourcentageActifs.toStringAsFixed(1)}%',
color: Colors.green,
radius: 60,
titleStyle: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
if (statistics.membresInactifs > 0)
PieChartSectionData(
value: statistics.membresInactifs.toDouble(),
title: '${statistics.pourcentageInactifs.toStringAsFixed(1)}%',
color: Colors.orange,
radius: 60,
titleStyle: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
],
sectionsSpace: 2,
centerSpaceRadius: 40,
),
),
),
// Légende
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_buildLegendItem(
'Actifs',
statistics.membresActifs,
Colors.green,
),
const SizedBox(height: 8),
if (statistics.membresInactifs > 0)
_buildLegendItem(
'Inactifs',
statistics.membresInactifs,
Colors.orange,
),
],
),
),
],
),
),
],
),
),
);
}
/// Item de légende
Widget _buildLegendItem(String label, int count, Color color) {
return Row(
children: [
Container(
width: 12,
height: 12,
decoration: BoxDecoration(
color: color,
shape: BoxShape.circle,
),
),
const SizedBox(width: 8),
Expanded(
child: Text(
'$label ($count)',
style: const TextStyle(fontSize: 12),
),
),
],
);
}
/// Métriques détaillées
Widget _buildDetailedMetrics(BuildContext context) {
return Card(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Détails Démographiques',
style: Theme.of(context).textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 16),
_buildDetailRow(
context,
'Tranche d\'âge',
statistics.trancheAge,
Icons.calendar_today,
),
_buildDetailRow(
context,
'Organisations',
'${statistics.nombreOrganisations} représentées',
Icons.business,
),
_buildDetailRow(
context,
'Régions',
'${statistics.nombreRegions} représentées',
Icons.location_on,
),
_buildDetailRow(
context,
'Taux d\'activité',
'${statistics.pourcentageActifs.toStringAsFixed(1)}%',
Icons.trending_up,
),
],
),
),
);
}
/// Ligne de détail
Widget _buildDetailRow(
BuildContext context,
String label,
String value,
IconData icon,
) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: Row(
children: [
Icon(
icon,
size: 20,
color: Colors.grey[600],
),
const SizedBox(width: 12),
Expanded(
child: Text(
label,
style: Theme.of(context).textTheme.bodyMedium,
),
),
Text(
value,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
fontWeight: FontWeight.bold,
),
),
],
),
);
}
/// Informations complémentaires
Widget _buildAdditionalInfo(BuildContext context) {
return Card(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Icon(
Icons.info_outline,
color: Theme.of(context).primaryColor,
),
const SizedBox(width: 8),
Text(
'Informations Complémentaires',
style: Theme.of(context).textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.bold,
),
),
],
),
const SizedBox(height: 16),
Text(
statistics.description,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: Colors.grey[700],
),
),
const SizedBox(height: 16),
Container(
padding: const EdgeInsets.all(12.0),
decoration: BoxDecoration(
color: Colors.blue.withOpacity(0.1),
borderRadius: BorderRadius.circular(8),
border: Border.all(color: Colors.blue.withOpacity(0.3)),
),
child: Row(
children: [
const Icon(Icons.lightbulb, color: Colors.blue),
const SizedBox(width: 8),
Expanded(
child: Text(
'Ces statistiques sont calculées en temps réel sur les résultats de votre recherche.',
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: Colors.blue[700],
),
),
),
],
),
),
],
),
),
);
}
}