feat(unionflow): ajout Spec-Kit, constitution, mission mutuelles
- Config Spec-Kit pour Spec-Driven Development - CONSTITUTION.md + .specify/memory/constitution.md - Commandes Cursor /speckit.*, règles projet - Mission: associations + mutuelles d'épargne et de financement - .gitignore: versionner config spec-kit unionflow Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
library analytics_model;
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Modèle pour une métrique analytics — aligné avec AnalyticsDataDTO
|
||||
class AnalyticsModel extends Equatable {
|
||||
final String? id;
|
||||
final String typeMetrique;
|
||||
final String periodeAnalyse;
|
||||
final double valeur;
|
||||
final double? valeurPrecedente;
|
||||
final double? pourcentageEvolution;
|
||||
final DateTime? dateDebut;
|
||||
final DateTime? dateFin;
|
||||
final String? libelle;
|
||||
final String? description;
|
||||
final String? unite;
|
||||
final String? couleur;
|
||||
final String? icone;
|
||||
|
||||
const AnalyticsModel({
|
||||
this.id,
|
||||
required this.typeMetrique,
|
||||
required this.periodeAnalyse,
|
||||
required this.valeur,
|
||||
this.valeurPrecedente,
|
||||
this.pourcentageEvolution,
|
||||
this.dateDebut,
|
||||
this.dateFin,
|
||||
this.libelle,
|
||||
this.description,
|
||||
this.unite,
|
||||
this.couleur,
|
||||
this.icone,
|
||||
});
|
||||
|
||||
bool get hasPositiveTrend =>
|
||||
pourcentageEvolution != null && pourcentageEvolution! > 0;
|
||||
bool get hasNegativeTrend =>
|
||||
pourcentageEvolution != null && pourcentageEvolution! < 0;
|
||||
|
||||
factory AnalyticsModel.fromJson(Map<String, dynamic> json) {
|
||||
return AnalyticsModel(
|
||||
id: json['id']?.toString(),
|
||||
typeMetrique: json['typeMetrique']?.toString() ?? '',
|
||||
periodeAnalyse: json['periodeAnalyse']?.toString() ?? '',
|
||||
valeur: _parseDouble(json['valeur']),
|
||||
valeurPrecedente: json['valeurPrecedente'] != null
|
||||
? _parseDouble(json['valeurPrecedente'])
|
||||
: null,
|
||||
pourcentageEvolution: json['pourcentageEvolution'] != null
|
||||
? _parseDouble(json['pourcentageEvolution'])
|
||||
: null,
|
||||
dateDebut: json['dateDebut'] != null
|
||||
? DateTime.tryParse(json['dateDebut'].toString())
|
||||
: null,
|
||||
dateFin: json['dateFin'] != null
|
||||
? DateTime.tryParse(json['dateFin'].toString())
|
||||
: null,
|
||||
libelle: json['libellePersonnalise']?.toString() ?? json['typeMetrique']?.toString(),
|
||||
description: json['description']?.toString(),
|
||||
unite: json['unite']?.toString(),
|
||||
couleur: json['couleur']?.toString(),
|
||||
icone: json['icone']?.toString(),
|
||||
);
|
||||
}
|
||||
|
||||
static double _parseDouble(dynamic val) {
|
||||
if (val == null) return 0.0;
|
||||
if (val is num) return val.toDouble();
|
||||
return double.tryParse(val.toString()) ?? 0.0;
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [id, typeMetrique, valeur, periodeAnalyse];
|
||||
}
|
||||
|
||||
/// KPI synthétique pour le tableau de bord des rapports
|
||||
class KpiModel extends Equatable {
|
||||
final String libelle;
|
||||
final double valeur;
|
||||
final String? unite;
|
||||
final double? evolution;
|
||||
final String? couleur;
|
||||
|
||||
const KpiModel({
|
||||
required this.libelle,
|
||||
required this.valeur,
|
||||
this.unite,
|
||||
this.evolution,
|
||||
this.couleur,
|
||||
});
|
||||
|
||||
factory KpiModel.fromJson(Map<String, dynamic> json) {
|
||||
return KpiModel(
|
||||
libelle: json['libelle']?.toString() ?? json['nom']?.toString() ?? '',
|
||||
valeur: AnalyticsModel._parseDouble(json['valeur'] ?? json['value']),
|
||||
unite: json['unite']?.toString(),
|
||||
evolution: json['evolution'] != null
|
||||
? AnalyticsModel._parseDouble(json['evolution'])
|
||||
: null,
|
||||
couleur: json['couleur']?.toString(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [libelle, valeur];
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
library reports_repository;
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import '../models/analytics_model.dart';
|
||||
|
||||
/// Interface du repository des rapports
|
||||
abstract class ReportsRepository {
|
||||
Future<List<AnalyticsModel>> getMetriques(String typeMetrique, String periode);
|
||||
Future<Map<String, dynamic>> getPerformanceGlobale();
|
||||
Future<List<AnalyticsModel>> getEvolutions(String typeMetrique);
|
||||
Future<Map<String, dynamic>> getStatistiquesMembres();
|
||||
Future<Map<String, dynamic>> getStatistiquesCotisations(int annee);
|
||||
Future<Map<String, dynamic>> getStatistiquesEvenements();
|
||||
}
|
||||
|
||||
/// Implémentation via /api/v1/analytics
|
||||
class ReportsRepositoryImpl implements ReportsRepository {
|
||||
final Dio _dio;
|
||||
static const String _analyticsBase = '/api/v1/analytics';
|
||||
static const String _membresBase = '/api/membres';
|
||||
static const String _cotisationsBase = '/api/cotisations';
|
||||
static const String _evenementsBase = '/api/evenements';
|
||||
|
||||
ReportsRepositoryImpl(this._dio);
|
||||
|
||||
@override
|
||||
Future<List<AnalyticsModel>> getMetriques(String typeMetrique, String periode) async {
|
||||
try {
|
||||
final response = await _dio.get(
|
||||
'$_analyticsBase/metriques/$typeMetrique',
|
||||
queryParameters: {'periodeAnalyse': periode},
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
final data = response.data;
|
||||
if (data is List) {
|
||||
return data.map((e) => AnalyticsModel.fromJson(e as Map<String, dynamic>)).toList();
|
||||
}
|
||||
if (data is Map) {
|
||||
return [AnalyticsModel.fromJson(data as Map<String, dynamic>)];
|
||||
}
|
||||
}
|
||||
return [];
|
||||
} on DioException catch (e) {
|
||||
if (e.response?.statusCode == 404 || e.response?.statusCode == 400) return [];
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, dynamic>> getPerformanceGlobale() async {
|
||||
try {
|
||||
final response = await _dio.get('$_analyticsBase/performance-globale');
|
||||
if (response.statusCode == 200 && response.data is Map) {
|
||||
return response.data as Map<String, dynamic>;
|
||||
}
|
||||
return {};
|
||||
} on DioException {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<AnalyticsModel>> getEvolutions(String typeMetrique) async {
|
||||
try {
|
||||
final response = await _dio.get(
|
||||
'$_analyticsBase/evolutions',
|
||||
queryParameters: {'typeMetrique': typeMetrique},
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
final data = response.data;
|
||||
if (data is List) {
|
||||
return data.map((e) => AnalyticsModel.fromJson(e as Map<String, dynamic>)).toList();
|
||||
}
|
||||
}
|
||||
return [];
|
||||
} on DioException {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, dynamic>> getStatistiquesMembres() async {
|
||||
try {
|
||||
final response = await _dio.get('$_membresBase/statistiques');
|
||||
if (response.statusCode == 200 && response.data is Map) {
|
||||
return response.data as Map<String, dynamic>;
|
||||
}
|
||||
return {};
|
||||
} on DioException {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, dynamic>> getStatistiquesCotisations(int annee) async {
|
||||
try {
|
||||
final response = await _dio.get(
|
||||
'$_cotisationsBase/statistiques',
|
||||
queryParameters: {'annee': annee},
|
||||
);
|
||||
if (response.statusCode == 200 && response.data is Map) {
|
||||
return response.data as Map<String, dynamic>;
|
||||
}
|
||||
return {};
|
||||
} on DioException {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, dynamic>> getStatistiquesEvenements() async {
|
||||
try {
|
||||
final response = await _dio.get('$_evenementsBase/statistiques');
|
||||
if (response.statusCode == 200 && response.data is Map) {
|
||||
return response.data as Map<String, dynamic>;
|
||||
}
|
||||
return {};
|
||||
} on DioException {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
library reports_di;
|
||||
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import '../data/repositories/reports_repository.dart';
|
||||
import '../presentation/bloc/reports_bloc.dart';
|
||||
|
||||
class ReportsDI {
|
||||
static final GetIt _getIt = GetIt.instance;
|
||||
|
||||
static void register() {
|
||||
_getIt.registerLazySingleton<ReportsRepository>(
|
||||
() => ReportsRepositoryImpl(_getIt<Dio>()),
|
||||
);
|
||||
|
||||
_getIt.registerFactory<ReportsBloc>(
|
||||
() => ReportsBloc(_getIt<ReportsRepository>()),
|
||||
);
|
||||
}
|
||||
|
||||
static void unregister() {
|
||||
if (_getIt.isRegistered<ReportsBloc>()) _getIt.unregister<ReportsBloc>();
|
||||
if (_getIt.isRegistered<ReportsRepository>()) _getIt.unregister<ReportsRepository>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
library reports_bloc;
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../../data/repositories/reports_repository.dart';
|
||||
|
||||
part 'reports_event.dart';
|
||||
part 'reports_state.dart';
|
||||
|
||||
class ReportsBloc extends Bloc<ReportsEvent, ReportsState> {
|
||||
final ReportsRepository _repository;
|
||||
|
||||
ReportsBloc(this._repository) : super(const ReportsInitial()) {
|
||||
on<LoadDashboardReports>(_onLoadDashboard);
|
||||
}
|
||||
|
||||
Future<void> _onLoadDashboard(
|
||||
LoadDashboardReports event,
|
||||
Emitter<ReportsState> emit,
|
||||
) async {
|
||||
try {
|
||||
emit(const ReportsLoading());
|
||||
final anneeActuelle = DateTime.now().year;
|
||||
|
||||
// Appels parallèles pour les performances
|
||||
final results = await Future.wait([
|
||||
_repository.getPerformanceGlobale(),
|
||||
_repository.getStatistiquesMembres(),
|
||||
_repository.getStatistiquesCotisations(anneeActuelle),
|
||||
_repository.getStatistiquesEvenements(),
|
||||
]);
|
||||
|
||||
emit(ReportsDashboardLoaded(
|
||||
performance: results[0],
|
||||
statsMembres: results[1],
|
||||
statsCotisations: results[2],
|
||||
statsEvenements: results[3],
|
||||
));
|
||||
} catch (e) {
|
||||
emit(ReportsError('Erreur lors du chargement des rapports : $e'));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
part of 'reports_bloc.dart';
|
||||
|
||||
abstract class ReportsEvent extends Equatable {
|
||||
const ReportsEvent();
|
||||
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
class LoadDashboardReports extends ReportsEvent {
|
||||
const LoadDashboardReports();
|
||||
}
|
||||
|
||||
class LoadMembresStats extends ReportsEvent {
|
||||
const LoadMembresStats();
|
||||
}
|
||||
|
||||
class LoadCotisationsStats extends ReportsEvent {
|
||||
final int annee;
|
||||
const LoadCotisationsStats({required this.annee});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [annee];
|
||||
}
|
||||
|
||||
class LoadEvenementsStats extends ReportsEvent {
|
||||
const LoadEvenementsStats();
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
part of 'reports_bloc.dart';
|
||||
|
||||
abstract class ReportsState extends Equatable {
|
||||
const ReportsState();
|
||||
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
class ReportsInitial extends ReportsState {
|
||||
const ReportsInitial();
|
||||
}
|
||||
|
||||
class ReportsLoading extends ReportsState {
|
||||
const ReportsLoading();
|
||||
}
|
||||
|
||||
class ReportsDashboardLoaded extends ReportsState {
|
||||
final Map<String, dynamic> performance;
|
||||
final Map<String, dynamic> statsMembres;
|
||||
final Map<String, dynamic> statsCotisations;
|
||||
final Map<String, dynamic> statsEvenements;
|
||||
|
||||
const ReportsDashboardLoaded({
|
||||
required this.performance,
|
||||
required this.statsMembres,
|
||||
required this.statsCotisations,
|
||||
required this.statsEvenements,
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [performance, statsMembres, statsCotisations, statsEvenements];
|
||||
}
|
||||
|
||||
class ReportsError extends ReportsState {
|
||||
final String message;
|
||||
const ReportsError(this.message);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [message];
|
||||
}
|
||||
@@ -0,0 +1,700 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../bloc/reports_bloc.dart';
|
||||
|
||||
/// Page Rapports & Analytics - UnionFlow Mobile
|
||||
///
|
||||
/// Page complète de génération et consultation des rapports avec
|
||||
/// analytics avancés, graphiques et export de données.
|
||||
class ReportsPage extends StatefulWidget {
|
||||
const ReportsPage({super.key});
|
||||
|
||||
@override
|
||||
State<ReportsPage> createState() => _ReportsPageState();
|
||||
}
|
||||
|
||||
class _ReportsPageState extends State<ReportsPage>
|
||||
with TickerProviderStateMixin {
|
||||
late TabController _tabController;
|
||||
|
||||
String _selectedPeriod = 'Dernier mois';
|
||||
String _selectedFormat = 'PDF';
|
||||
|
||||
final List<String> _periods = ['Dernière semaine', 'Dernier mois', 'Dernier trimestre', 'Dernière année'];
|
||||
final List<String> _formats = ['PDF', 'Excel', 'CSV', 'JSON'];
|
||||
|
||||
// Données live du backend
|
||||
Map<String, dynamic> _statsMembres = {};
|
||||
Map<String, dynamic> _statsCotisations = {};
|
||||
Map<String, dynamic> _statsEvenements = {};
|
||||
Map<String, dynamic> _performance = {};
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_tabController = TabController(length: 4, vsync: this);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
context.read<ReportsBloc>().add(const LoadDashboardReports());
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_tabController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocConsumer<ReportsBloc, ReportsState>(
|
||||
listener: (context, state) {
|
||||
if (state is ReportsDashboardLoaded) {
|
||||
setState(() {
|
||||
_performance = state.performance;
|
||||
_statsMembres = state.statsMembres;
|
||||
_statsCotisations = state.statsCotisations;
|
||||
_statsEvenements = state.statsEvenements;
|
||||
});
|
||||
}
|
||||
if (state is ReportsError) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(state.message), backgroundColor: Colors.orange),
|
||||
);
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFFF8F9FA),
|
||||
body: Column(
|
||||
children: [
|
||||
_buildHeader(),
|
||||
_buildTabBar(),
|
||||
if (state is ReportsLoading)
|
||||
const LinearProgressIndicator(minHeight: 3),
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
controller: _tabController,
|
||||
children: [
|
||||
_buildOverviewTab(),
|
||||
_buildMembersTab(),
|
||||
_buildOrganizationsTab(),
|
||||
_buildEventsTab(),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// Header harmonisé
|
||||
Widget _buildHeader() {
|
||||
return Container(
|
||||
margin: const EdgeInsets.all(12),
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
gradient: const LinearGradient(
|
||||
colors: [Color(0xFF6C5CE7), Color(0xFF5A4FCF)],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: const Color(0xFF6C5CE7).withOpacity(0.3),
|
||||
blurRadius: 20,
|
||||
offset: const Offset(0, 8),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: const Icon(Icons.assessment, color: Colors.white, size: 24),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'Rapports & Analytics',
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: Colors.white),
|
||||
),
|
||||
Text(
|
||||
'Statistiques et analyses détaillées',
|
||||
style: TextStyle(fontSize: 14, color: Colors.white.withOpacity(0.8)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: IconButton(
|
||||
onPressed: () => _showExportDialog(),
|
||||
icon: const Icon(Icons.download, color: Colors.white),
|
||||
tooltip: 'Exporter rapport',
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: IconButton(
|
||||
onPressed: () => _scheduleReport(),
|
||||
icon: const Icon(Icons.schedule, color: Colors.white),
|
||||
tooltip: 'Programmer rapport',
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(child: _buildStatCard('Membres', '1,247', Icons.people, Colors.blue)),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(child: _buildStatCard('Organisations', '89', Icons.business, Colors.green)),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(child: _buildStatCard('Événements', '156', Icons.event, Colors.orange)),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStatCard(String label, String value, IconData icon, Color color) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(0.15),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Icon(icon, color: Colors.white, size: 20),
|
||||
const SizedBox(height: 4),
|
||||
Text(value, style: const TextStyle(fontSize: 14, fontWeight: FontWeight.bold, color: Colors.white)),
|
||||
Text(label, style: TextStyle(fontSize: 10, color: Colors.white.withOpacity(0.8))),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Barre d'onglets
|
||||
Widget _buildTabBar() {
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10, offset: const Offset(0, 2))],
|
||||
),
|
||||
child: TabBar(
|
||||
controller: _tabController,
|
||||
labelColor: const Color(0xFF6C5CE7),
|
||||
unselectedLabelColor: Colors.grey[600],
|
||||
indicatorColor: const Color(0xFF6C5CE7),
|
||||
labelStyle: const TextStyle(fontWeight: FontWeight.w600, fontSize: 11),
|
||||
tabs: const [
|
||||
Tab(icon: Icon(Icons.dashboard, size: 16), text: 'Vue d\'ensemble'),
|
||||
Tab(icon: Icon(Icons.people, size: 16), text: 'Membres'),
|
||||
Tab(icon: Icon(Icons.business, size: 16), text: 'Organisations'),
|
||||
Tab(icon: Icon(Icons.event, size: 16), text: 'Événements'),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Onglet vue d'ensemble
|
||||
Widget _buildOverviewTab() {
|
||||
return SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 16),
|
||||
_buildKPICards(),
|
||||
const SizedBox(height: 16),
|
||||
_buildActivityChart(),
|
||||
const SizedBox(height: 16),
|
||||
_buildQuickReports(),
|
||||
const SizedBox(height: 80),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Cartes KPI
|
||||
Widget _buildKPICards() {
|
||||
final totalMembres = _statsMembres['totalMembres']?.toString()
|
||||
?? _statsMembres['total']?.toString() ?? '--';
|
||||
final membresActifs = _statsMembres['membresActifs']?.toString()
|
||||
?? _statsMembres['actifs']?.toString() ?? '--';
|
||||
final totalCotisations = _statsCotisations['totalCotisations']?.toString()
|
||||
?? _statsCotisations['total']?.toString() ?? '--';
|
||||
final totalEvenements = _statsEvenements['totalEvenements']?.toString()
|
||||
?? _statsEvenements['total']?.toString() ?? '--';
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(child: _buildKPICard('Total membres', totalMembres, Icons.people, Colors.indigo)),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(child: _buildKPICard('Membres actifs', membresActifs, Icons.how_to_reg, Colors.green)),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(child: _buildKPICard('Cotisations', totalCotisations, Icons.payment, Colors.blue)),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(child: _buildKPICard('Événements', totalEvenements, Icons.event, Colors.orange)),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildKPICard(String title, String value, IconData icon, Color color) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10, offset: const Offset(0, 2))],
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Icon(icon, color: color, size: 32),
|
||||
const SizedBox(height: 8),
|
||||
Text(value, style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: color)),
|
||||
Text(title, style: TextStyle(fontSize: 12, color: Colors.grey[600]), textAlign: TextAlign.center),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Graphique d'activité
|
||||
Widget _buildActivityChart() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10, offset: const Offset(0, 2))],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.show_chart, color: Color(0xFF6C5CE7), size: 20),
|
||||
const SizedBox(width: 8),
|
||||
Text('Activité des 30 derniers jours', style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Colors.grey[800])),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Container(
|
||||
height: 120,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[50],
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: const Center(
|
||||
child: Text('Graphique d\'activité\n(Intégration Chart.js à venir)', textAlign: TextAlign.center, style: TextStyle(color: Colors.grey)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Rapports rapides
|
||||
Widget _buildQuickReports() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10, offset: const Offset(0, 2))],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.flash_on, color: Color(0xFF6C5CE7), size: 20),
|
||||
const SizedBox(width: 8),
|
||||
Text('Rapports rapides', style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Colors.grey[800])),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildQuickReportItem('Rapport mensuel', 'Synthèse complète du mois', Icons.calendar_month, () => _generateReport('monthly')),
|
||||
_buildQuickReportItem('Top membres actifs', 'Classement des membres les plus actifs', Icons.leaderboard, () => _generateReport('top_members')),
|
||||
_buildQuickReportItem('Analyse des événements', 'Performance et participation aux événements', Icons.analytics, () => _generateReport('events_analysis')),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildQuickReportItem(String title, String subtitle, IconData icon, VoidCallback onTap) {
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[50],
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(icon, color: const Color(0xFF6C5CE7), size: 20),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(title, style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: Color(0xFF1F2937))),
|
||||
Text(subtitle, style: TextStyle(fontSize: 12, color: Colors.grey[600])),
|
||||
],
|
||||
),
|
||||
),
|
||||
Icon(Icons.arrow_forward_ios, color: Colors.grey[400], size: 16),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Onglet membres
|
||||
Widget _buildMembersTab() {
|
||||
return SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 16),
|
||||
_buildMembersStats(),
|
||||
const SizedBox(height: 16),
|
||||
_buildMembersReports(),
|
||||
const SizedBox(height: 80),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMembersStats() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10, offset: const Offset(0, 2))],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.people, color: Color(0xFF6C5CE7), size: 20),
|
||||
const SizedBox(width: 8),
|
||||
Text('Statistiques membres', style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Colors.grey[800])),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(child: _buildStatItem('Total membres', '1,247')),
|
||||
Expanded(child: _buildStatItem('Nouveaux (30j)', '+156')),
|
||||
Expanded(child: _buildStatItem('Actifs (7j)', '892')),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMembersReports() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10, offset: const Offset(0, 2))],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.description, color: Color(0xFF6C5CE7), size: 20),
|
||||
const SizedBox(width: 8),
|
||||
Text('Rapports membres', style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Colors.grey[800])),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildReportItem('Liste complète des membres', 'Export avec toutes les informations', Icons.list_alt),
|
||||
_buildReportItem('Analyse d\'engagement', 'Participation et activité des membres', Icons.trending_up),
|
||||
_buildReportItem('Segmentation démographique', 'Répartition par âge, région, etc.', Icons.pie_chart),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Onglet organisations
|
||||
Widget _buildOrganizationsTab() {
|
||||
return SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 16),
|
||||
_buildOrganizationsStats(),
|
||||
const SizedBox(height: 16),
|
||||
_buildOrganizationsReports(),
|
||||
const SizedBox(height: 80),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildOrganizationsStats() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10, offset: const Offset(0, 2))],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.business, color: Color(0xFF6C5CE7), size: 20),
|
||||
const SizedBox(width: 8),
|
||||
Text('Statistiques organisations', style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Colors.grey[800])),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(child: _buildStatItem('Total orgs', '89')),
|
||||
Expanded(child: _buildStatItem('Actives', '67')),
|
||||
Expanded(child: _buildStatItem('Membres moy.', '14')),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildOrganizationsReports() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10, offset: const Offset(0, 2))],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.description, color: Color(0xFF6C5CE7), size: 20),
|
||||
const SizedBox(width: 8),
|
||||
Text('Rapports organisations', style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Colors.grey[800])),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildReportItem('Annuaire des organisations', 'Liste complète avec contacts', Icons.contact_phone),
|
||||
_buildReportItem('Performance par organisation', 'Activité et engagement', Icons.bar_chart),
|
||||
_buildReportItem('Analyse de croissance', 'Évolution du nombre de membres', Icons.show_chart),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Onglet événements
|
||||
Widget _buildEventsTab() {
|
||||
return SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 16),
|
||||
_buildEventsStats(),
|
||||
const SizedBox(height: 16),
|
||||
_buildEventsReports(),
|
||||
const SizedBox(height: 80),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildEventsStats() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10, offset: const Offset(0, 2))],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.event, color: Color(0xFF6C5CE7), size: 20),
|
||||
const SizedBox(width: 8),
|
||||
Text('Statistiques événements', style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Colors.grey[800])),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(child: _buildStatItem('Total événements', '156')),
|
||||
Expanded(child: _buildStatItem('À venir', '23')),
|
||||
Expanded(child: _buildStatItem('Participation moy.', '45')),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildEventsReports() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10, offset: const Offset(0, 2))],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.description, color: Color(0xFF6C5CE7), size: 20),
|
||||
const SizedBox(width: 8),
|
||||
Text('Rapports événements', style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Colors.grey[800])),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildReportItem('Calendrier des événements', 'Planning complet avec détails', Icons.calendar_today),
|
||||
_buildReportItem('Analyse de participation', 'Taux de participation et feedback', Icons.people_outline),
|
||||
_buildReportItem('ROI des événements', 'Retour sur investissement', Icons.attach_money),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Composants communs
|
||||
Widget _buildStatItem(String label, String value) {
|
||||
return Column(
|
||||
children: [
|
||||
Text(value, style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold, color: Color(0xFF6C5CE7))),
|
||||
Text(label, style: TextStyle(fontSize: 12, color: Colors.grey[600]), textAlign: TextAlign.center),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildReportItem(String title, String subtitle, IconData icon) {
|
||||
return InkWell(
|
||||
onTap: () => _generateReport(title.toLowerCase().replaceAll(' ', '_')),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[50],
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(icon, color: const Color(0xFF6C5CE7), size: 20),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(title, style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: Color(0xFF1F2937))),
|
||||
Text(subtitle, style: TextStyle(fontSize: 12, color: Colors.grey[600])),
|
||||
],
|
||||
),
|
||||
),
|
||||
Icon(Icons.download, color: Colors.grey[400], size: 16),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Méthodes d'action
|
||||
void _showExportDialog() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('Exporter rapport'),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
DropdownButtonFormField<String>(
|
||||
value: _selectedPeriod,
|
||||
decoration: const InputDecoration(labelText: 'Période'),
|
||||
items: _periods.map((period) => DropdownMenuItem(value: period, child: Text(period))).toList(),
|
||||
onChanged: (value) => setState(() => _selectedPeriod = value!),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
DropdownButtonFormField<String>(
|
||||
value: _selectedFormat,
|
||||
decoration: const InputDecoration(labelText: 'Format'),
|
||||
items: _formats.map((format) => DropdownMenuItem(value: format, child: Text(format))).toList(),
|
||||
onChanged: (value) => setState(() => _selectedFormat = value!),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(onPressed: () => Navigator.of(context).pop(), child: const Text('Annuler')),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
_showSuccessSnackBar('Export lancé - Vous recevrez un email');
|
||||
},
|
||||
style: ElevatedButton.styleFrom(backgroundColor: const Color(0xFF6C5CE7), foregroundColor: Colors.white),
|
||||
child: const Text('Exporter'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _scheduleReport() => _showSuccessSnackBar('Programmation de rapport configurée');
|
||||
void _generateReport(String type) => _showSuccessSnackBar('Génération du rapport "$type" lancée');
|
||||
|
||||
void _showSuccessSnackBar(String message) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(message), backgroundColor: const Color(0xFF00B894), behavior: SnackBarBehavior.floating),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
library reports_page_wrapper;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import '../bloc/reports_bloc.dart';
|
||||
import 'reports_page.dart';
|
||||
|
||||
/// Wrapper qui fournit le ReportsBloc à la ReportsPage
|
||||
class ReportsPageWrapper extends StatelessWidget {
|
||||
const ReportsPageWrapper({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider<ReportsBloc>(
|
||||
create: (_) => GetIt.instance<ReportsBloc>(),
|
||||
child: const ReportsPage(),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user