Refactoring - Version OK
This commit is contained in:
@@ -301,16 +301,21 @@ class EventDetailPage extends StatelessWidget {
|
||||
evenement.participantsActuels;
|
||||
final isComplet = placesRestantes <= 0 && evenement.maxParticipants != null;
|
||||
|
||||
return FloatingActionButton.extended(
|
||||
onPressed: (isInscrit || !isComplet)
|
||||
? () => _showInscriptionDialog(context, isInscrit)
|
||||
: null,
|
||||
backgroundColor: isInscrit ? Colors.red : const Color(0xFF3B82F6),
|
||||
icon: Icon(isInscrit ? Icons.cancel : Icons.check),
|
||||
label: Text(
|
||||
isInscrit ? 'Se désinscrire' : (isComplet ? 'Complet' : 'S\'inscrire'),
|
||||
),
|
||||
);
|
||||
if (!isComplet) {
|
||||
return FloatingActionButton.extended(
|
||||
onPressed: () => _showInscriptionDialog(context, isInscrit),
|
||||
backgroundColor: const Color(0xFF3B82F6),
|
||||
icon: const Icon(Icons.check),
|
||||
label: const Text('S\'inscrire'),
|
||||
);
|
||||
} else {
|
||||
return const FloatingActionButton.extended(
|
||||
onPressed: null,
|
||||
backgroundColor: Colors.grey,
|
||||
icon: Icon(Icons.block),
|
||||
label: Text('Complet'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void _showInscriptionDialog(BuildContext context, bool isInscrit) {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,10 +7,9 @@ library events_page_connected;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import '../../../../core/auth/bloc/auth_bloc.dart';
|
||||
import '../../../../core/auth/models/user_role.dart';
|
||||
import '../../../../core/utils/logger.dart';
|
||||
import '../../../authentication/data/models/user_role.dart';
|
||||
import '../../../authentication/presentation/bloc/auth_bloc.dart';
|
||||
|
||||
/// Page de gestion des événements avec données injectées
|
||||
class EventsPageWithData extends StatefulWidget {
|
||||
@@ -20,7 +19,7 @@ class EventsPageWithData extends StatefulWidget {
|
||||
/// Nombre total d'événements
|
||||
final int totalCount;
|
||||
|
||||
/// Page actuelle
|
||||
/// Page actuelle.
|
||||
final int currentPage;
|
||||
|
||||
/// Nombre total de pages
|
||||
@@ -46,7 +45,7 @@ class _EventsPageWithDataState extends State<EventsPageWithData>
|
||||
|
||||
// État
|
||||
String _searchQuery = '';
|
||||
String _selectedFilter = 'Tous';
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
||||
@@ -8,8 +8,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
|
||||
import '../../../../core/widgets/error_widget.dart';
|
||||
import '../../../../core/widgets/loading_widget.dart';
|
||||
import '../../../../shared/widgets/error_widget.dart';
|
||||
import '../../../../shared/widgets/loading_widget.dart';
|
||||
import '../../../../core/utils/logger.dart';
|
||||
import '../../bloc/evenements_bloc.dart';
|
||||
import '../../bloc/evenements_event.dart';
|
||||
@@ -177,14 +177,14 @@ class EventsPageConnected extends StatelessWidget {
|
||||
'address': evenement.adresse ?? '',
|
||||
'type': _mapTypeToString(evenement.type),
|
||||
'status': _mapStatutToString(evenement.statut),
|
||||
'maxParticipants': evenement.maxParticipants ?? 0,
|
||||
'currentParticipants': evenement.participantsActuels ?? 0,
|
||||
'maxParticipants': evenement.maxParticipants,
|
||||
'currentParticipants': evenement.participantsActuels,
|
||||
'organizer': 'Organisateur', // TODO: Récupérer depuis organisateurId
|
||||
'priority': _mapPrioriteToString(evenement.priorite),
|
||||
'isPublic': evenement.estPublic ?? true,
|
||||
'requiresRegistration': evenement.inscriptionRequise ?? false,
|
||||
'cost': evenement.cout ?? 0.0,
|
||||
'tags': evenement.tags ?? [],
|
||||
'isPublic': evenement.estPublic,
|
||||
'requiresRegistration': evenement.inscriptionRequise,
|
||||
'cost': evenement.cout,
|
||||
'tags': evenement.tags,
|
||||
'createdBy': 'Créateur', // TODO: Récupérer depuis organisateurId
|
||||
'createdAt': DateTime.now(), // TODO: Ajouter au modèle
|
||||
'lastModified': DateTime.now(), // TODO: Ajouter au modèle
|
||||
|
||||
Reference in New Issue
Block a user