Refactoring - Version OK
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../../core/auth/bloc/auth_bloc.dart';
|
||||
import '../../../../core/auth/models/user_role.dart';
|
||||
import '../../../authentication/presentation/bloc/auth_bloc.dart';
|
||||
|
||||
import '../../../../shared/design_system/tokens/color_tokens.dart';
|
||||
|
||||
/// Page de gestion des événements - Interface sophistiquée et exhaustive
|
||||
///
|
||||
@@ -222,7 +223,7 @@ class _EventsPageState extends State<EventsPage> with TickerProviderStateMixin {
|
||||
);
|
||||
}
|
||||
|
||||
final canManageEvents = _canManageEvents(state.effectiveRole);
|
||||
|
||||
|
||||
return Container(
|
||||
color: const Color(0xFFF8F9FA),
|
||||
@@ -257,12 +258,7 @@ class _EventsPageState extends State<EventsPage> with TickerProviderStateMixin {
|
||||
);
|
||||
}
|
||||
|
||||
/// Vérifie si l'utilisateur peut gérer les événements
|
||||
bool _canManageEvents(UserRole role) {
|
||||
return role == UserRole.superAdmin ||
|
||||
role == UserRole.orgAdmin ||
|
||||
role == UserRole.moderator;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -282,73 +278,42 @@ class _EventsPageState extends State<EventsPage> with TickerProviderStateMixin {
|
||||
sum + (event['currentParticipants'] as int)
|
||||
);
|
||||
|
||||
final averageParticipation = _allEvents.isNotEmpty
|
||||
? (_allEvents.fold<double>(0, (sum, event) {
|
||||
final current = event['currentParticipants'] as int;
|
||||
final max = event['maxParticipants'] as int;
|
||||
return sum + (max > 0 ? (current / max) * 100 : 0);
|
||||
}) / _allEvents.length).round()
|
||||
: 0;
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorTokens.secondary.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'Métriques Événements',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF6C5CE7),
|
||||
fontSize: 20,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _buildSimpleKPICard(
|
||||
'À Venir',
|
||||
upcomingEvents.toString(),
|
||||
'+2 ce mois',
|
||||
Icons.event_available,
|
||||
const Color(0xFF10B981),
|
||||
),
|
||||
),
|
||||
const Icon(Icons.event, color: ColorTokens.secondary),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: _buildSimpleKPICard(
|
||||
'En Cours',
|
||||
ongoingEvents.toString(),
|
||||
'Actifs maintenant',
|
||||
Icons.play_circle_filled,
|
||||
const Color(0xFF3B82F6),
|
||||
),
|
||||
const Text(
|
||||
'Événements',
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const Spacer(),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.add),
|
||||
onPressed: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Créer événement - Fonctionnalité à venir')),
|
||||
);
|
||||
},
|
||||
tooltip: 'Créer un événement',
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Expanded(
|
||||
child: _buildSimpleKPICard(
|
||||
'Participants',
|
||||
totalParticipants.toString(),
|
||||
'Total inscrits',
|
||||
Icons.people,
|
||||
const Color(0xFF8B5CF6),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: _buildSimpleKPICard(
|
||||
'Taux Moyen',
|
||||
'$averageParticipation%',
|
||||
'Participation',
|
||||
Icons.trending_up,
|
||||
const Color(0xFFF59E0B),
|
||||
),
|
||||
),
|
||||
_buildStatCard('À Venir', upcomingEvents.toString(), ColorTokens.success),
|
||||
_buildStatCard('En Cours', ongoingEvents.toString(), ColorTokens.info),
|
||||
_buildStatCard('Participants', totalParticipants.toString(), ColorTokens.secondary),
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -356,62 +321,30 @@ class _EventsPageState extends State<EventsPage> with TickerProviderStateMixin {
|
||||
);
|
||||
}
|
||||
|
||||
/// Carte KPI simple alignée sur le design system
|
||||
Widget _buildSimpleKPICard(String title, String value, String subtitle, IconData icon, Color color) {
|
||||
Widget _buildStatCard(String label, String value, Color color) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
color: color.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.05),
|
||||
blurRadius: 4,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
border: Border.all(color: color.withOpacity(0.3)),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(6),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Icon(icon, color: color, size: 16),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Color(0xFF6B7280),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
value,
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF374151),
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
subtitle,
|
||||
style: const TextStyle(
|
||||
fontSize: 10,
|
||||
color: Color(0xFF9CA3AF),
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: color.withOpacity(0.8),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -1295,14 +1228,13 @@ class _EventsPageState extends State<EventsPage> with TickerProviderStateMixin {
|
||||
}
|
||||
}
|
||||
|
||||
/// Créer un nouvel événement
|
||||
void _showCreateEventDialog(BuildContext context) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Création d\'événement - Fonctionnalité à implémenter'),
|
||||
backgroundColor: Color(0xFF6C5CE7),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_searchController.dispose();
|
||||
_tabController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
/// Modifier un événement
|
||||
@@ -1324,31 +1256,4 @@ class _EventsPageState extends State<EventsPage> with TickerProviderStateMixin {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Importer des événements
|
||||
void _showEventImportDialog() {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Import d\'événements - Fonctionnalité à implémenter'),
|
||||
backgroundColor: Color(0xFFF59E0B),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Exporter des événements
|
||||
void _showEventExportDialog() {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Export d\'événements - Fonctionnalité à implémenter'),
|
||||
backgroundColor: Color(0xFF10B981),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_searchController.dispose();
|
||||
_tabController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user