feat: WebSocket temps réel + Finance Workflow + corrections

- Task #6: WebSocket /ws/dashboard + Kafka events (5 topics)
  * Backend: KafkaEventProducer, KafkaEventConsumer
  * Mobile: WebSocketService (reconnection, heartbeat, typed events)
  * DashboardBloc: Auto-refresh depuis WebSocket events

- Finance Workflow: approbations + budgets (backend + mobile)
  * Backend: entities, services, resources, migrations Flyway V6
  * Mobile: features finance_workflow complète avec BLoC

- Corrections DI: interfaces IRepository partout
  * IProfileRepository, IOrganizationRepository, IMembreRepository
  * GetIt configuré avec @injectable

- Spec-Kit: constitution + templates mis à jour
  * .specify/memory/constitution.md enrichie
  * Templates agent, plan, spec, tasks, checklist

- Nettoyage: fichiers temporaires supprimés

Signed-off-by: lions dev Team
This commit is contained in:
dahoud
2026-03-15 02:12:17 +00:00
parent bbc409de9d
commit e8ad874015
635 changed files with 58160 additions and 20674 deletions

View File

@@ -3,13 +3,15 @@ library event_detail_page;
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../../../core/di/injection.dart';
import '../../bloc/evenements_bloc.dart';
import '../../bloc/evenements_state.dart';
import '../../data/models/evenement_model.dart';
import '../../domain/repositories/evenement_repository.dart';
import '../widgets/inscription_event_dialog.dart';
import '../widgets/edit_event_dialog.dart';
class EventDetailPage extends StatelessWidget {
class EventDetailPage extends StatefulWidget {
final EvenementModel evenement;
const EventDetailPage({
@@ -17,6 +19,34 @@ class EventDetailPage extends StatelessWidget {
required this.evenement,
});
@override
State<EventDetailPage> createState() => _EventDetailPageState();
}
class _EventDetailPageState extends State<EventDetailPage> {
bool? _isInscrit;
@override
void initState() {
super.initState();
_loadInscriptionStatus();
}
Future<void> _loadInscriptionStatus() async {
final id = widget.evenement.id?.toString();
if (id == null || id.isEmpty) {
if (mounted) setState(() => _isInscrit = false);
return;
}
try {
final repo = getIt<IEvenementRepository>();
final value = await repo.getInscriptionStatus(id);
if (mounted) setState(() => _isInscrit = value);
} catch (_) {
if (mounted) setState(() => _isInscrit = false);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -40,7 +70,7 @@ class EventDetailPage extends StatelessWidget {
_buildHeader(),
_buildInfoSection(),
_buildDescriptionSection(),
if (evenement.lieu != null) _buildLocationSection(),
if (widget.evenement.lieu != null) _buildLocationSection(),
_buildParticipantsSection(),
const SizedBox(height: 80), // Espace pour le bouton flottant
],
@@ -76,7 +106,7 @@ class EventDetailPage extends StatelessWidget {
borderRadius: BorderRadius.circular(20),
),
child: Text(
_getTypeLabel(evenement.type),
_getTypeLabel(widget.evenement.type),
style: const TextStyle(
color: Colors.white,
fontSize: 12,
@@ -86,7 +116,7 @@ class EventDetailPage extends StatelessWidget {
),
const SizedBox(height: 12),
Text(
evenement.titre,
widget.evenement.titre,
style: const TextStyle(
color: Colors.white,
fontSize: 24,
@@ -99,11 +129,11 @@ class EventDetailPage extends StatelessWidget {
Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: _getStatutColor(evenement.statut),
color: _getStatutColor(widget.evenement.statut),
borderRadius: BorderRadius.circular(4),
),
child: Text(
_getStatutLabel(evenement.statut),
_getStatutLabel(widget.evenement.statut),
style: const TextStyle(
color: Colors.white,
fontSize: 12,
@@ -126,28 +156,28 @@ class EventDetailPage extends StatelessWidget {
_buildInfoRow(
Icons.calendar_today,
'Date de début',
_formatDate(evenement.dateDebut),
_formatDate(widget.evenement.dateDebut),
),
const Divider(),
_buildInfoRow(
Icons.event,
'Date de fin',
_formatDate(evenement.dateFin),
_formatDate(widget.evenement.dateFin),
),
if (evenement.maxParticipants != null) ...[
if (widget.evenement.maxParticipants != null) ...[
const Divider(),
_buildInfoRow(
Icons.people,
'Places',
'${evenement.participantsActuels} / ${evenement.maxParticipants}',
'${widget.evenement.participantsActuels} / ${widget.evenement.maxParticipants}',
),
],
if (evenement.organisateurNom != null) ...[
if (widget.evenement.organisateurNom != null) ...[
const Divider(),
_buildInfoRow(
Icons.person,
'Organisateur',
evenement.organisateurNom!,
widget.evenement.organisateurNom!,
),
],
],
@@ -190,7 +220,7 @@ class EventDetailPage extends StatelessWidget {
}
Widget _buildDescriptionSection() {
if (evenement.description == null) return const SizedBox.shrink();
if (widget.evenement.description == null) return const SizedBox.shrink();
return Container(
padding: const EdgeInsets.all(16),
@@ -206,7 +236,7 @@ class EventDetailPage extends StatelessWidget {
),
const SizedBox(height: 8),
Text(
evenement.description!,
widget.evenement.description!,
style: const TextStyle(fontSize: 14, height: 1.5),
),
],
@@ -234,7 +264,7 @@ class EventDetailPage extends StatelessWidget {
const SizedBox(width: 8),
Expanded(
child: Text(
evenement.lieu!,
widget.evenement.lieu!,
style: const TextStyle(fontSize: 14),
),
),
@@ -262,7 +292,7 @@ class EventDetailPage extends StatelessWidget {
),
),
Text(
'${evenement.participantsActuels} inscrits',
'${widget.evenement.participantsActuels} inscrits',
style: TextStyle(
fontSize: 14,
color: Colors.grey[600],
@@ -296,11 +326,11 @@ class EventDetailPage extends StatelessWidget {
}
Widget _buildInscriptionButton(BuildContext context) {
const isInscrit = false; // Nécessite endpoint d'inscription par utilisateur
final placesRestantes = (evenement.maxParticipants ?? 0) -
evenement.participantsActuels;
final isComplet = placesRestantes <= 0 && evenement.maxParticipants != null;
final isInscrit = _isInscrit ?? false;
final placesRestantes = (widget.evenement.maxParticipants ?? 0) -
widget.evenement.participantsActuels;
final isComplet = placesRestantes <= 0 && widget.evenement.maxParticipants != null;
if (!isComplet) {
return FloatingActionButton.extended(
onPressed: () => _showInscriptionDialog(context, isInscrit),
@@ -324,11 +354,11 @@ class EventDetailPage extends StatelessWidget {
builder: (context) => BlocProvider.value(
value: context.read<EvenementsBloc>(),
child: InscriptionEventDialog(
evenement: evenement,
evenement: widget.evenement,
isInscrit: isInscrit,
),
),
);
).then((_) => _loadInscriptionStatus());
}
void _showEditDialog(BuildContext context) {
@@ -336,7 +366,7 @@ class EventDetailPage extends StatelessWidget {
context: context,
builder: (context) => BlocProvider.value(
value: context.read<EvenementsBloc>(),
child: EditEventDialog(evenement: evenement),
child: EditEventDialog(evenement: widget.evenement),
),
);
}

View File

@@ -1,31 +1,26 @@
/// Page des événements avec données injectées depuis le BLoC
///
/// Cette version de EventsPage accepte les données en paramètre
/// au lieu d'utiliser des données mock hardcodées.
library events_page_connected;
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:intl/intl.dart';
import '../../../../core/utils/logger.dart';
import '../../../../core/constants/app_constants.dart';
import '../../../../shared/design_system/unionflow_design_v2.dart';
import '../../../../shared/design_system/components/uf_app_bar.dart';
import '../../../authentication/data/models/user_role.dart';
import '../../../authentication/presentation/bloc/auth_bloc.dart';
import '../../bloc/evenements_bloc.dart';
import '../../bloc/evenements_event.dart';
import '../../data/models/evenement_model.dart';
import 'event_detail_page.dart';
/// Page de gestion des événements avec données injectées
/// Page Événements - Design UnionFlow
class EventsPageWithData extends StatefulWidget {
/// Liste des événements à afficher
final List<Map<String, dynamic>> events;
/// Nombre total d'événements
final List<EvenementModel> events;
final int totalCount;
/// Page actuelle.
final int currentPage;
/// Nombre total de pages
final int totalPages;
final void Function(String? query)? onSearch;
final VoidCallback? onAddEvent;
final void Function(int page, String? recherche)? onPageChanged;
const EventsPageWithData({
super.key,
@@ -33,31 +28,30 @@ class EventsPageWithData extends StatefulWidget {
required this.totalCount,
required this.currentPage,
required this.totalPages,
this.onSearch,
this.onAddEvent,
this.onPageChanged,
});
@override
State<EventsPageWithData> createState() => _EventsPageWithDataState();
}
class _EventsPageWithDataState extends State<EventsPageWithData>
with TickerProviderStateMixin {
// Controllers
class _EventsPageWithDataState extends State<EventsPageWithData> with TickerProviderStateMixin {
final TextEditingController _searchController = TextEditingController();
late TabController _tabController;
// État
String _searchQuery = '';
Timer? _searchDebounce;
@override
void initState() {
super.initState();
_tabController = TabController(length: 5, vsync: this);
AppLogger.info('EventsPageWithData initialisée avec ${widget.events.length} événements');
_tabController = TabController(length: 4, vsync: this);
}
@override
void dispose() {
_searchDebounce?.cancel();
_searchController.dispose();
_tabController.dispose();
super.dispose();
@@ -68,42 +62,44 @@ class _EventsPageWithDataState extends State<EventsPageWithData>
return BlocBuilder<AuthBloc, AuthState>(
builder: (context, state) {
if (state is! AuthAuthenticated) {
return Container(
color: const Color(0xFFF8F9FA),
child: const Center(child: CircularProgressIndicator()),
);
return const Scaffold(body: Center(child: CircularProgressIndicator()));
}
final canManageEvents = _canManageEvents(state.effectiveRole);
final canManageEvents = state.effectiveRole.level >= UserRole.moderator.level;
return Container(
color: const Color(0xFFF8F9FA),
child: Column(
return Scaffold(
backgroundColor: UnionFlowColors.background,
appBar: UFAppBar(
title: 'Événements',
backgroundColor: UnionFlowColors.surface,
foregroundColor: UnionFlowColors.textPrimary,
actions: [
if (canManageEvents && widget.onAddEvent != null)
IconButton(
icon: const Icon(Icons.add_circle_outline),
color: UnionFlowColors.unionGreen,
onPressed: widget.onAddEvent,
tooltip: 'Créer un événement',
),
const SizedBox(width: 8),
],
),
body: Column(
children: [
// Métriques
_buildEventMetrics(),
// Recherche et filtres
_buildSearchAndFilters(canManageEvents),
// Onglets
_buildTabBar(),
// Contenu
_buildHeader(),
_buildSearchBar(),
_buildTabs(),
Expanded(
child: TabBarView(
controller: _tabController,
children: [
_buildAllEventsView(),
_buildUpcomingEventsView(),
_buildOngoingEventsView(),
_buildPastEventsView(),
_buildCalendarView(),
_buildEventsList(widget.events, 'tous'),
_buildEventsList(widget.events.where((e) => e.estAVenir).toList(), 'à venir'),
_buildEventsList(widget.events.where((e) => e.estEnCours).toList(), 'en cours'),
_buildEventsList(widget.events.where((e) => e.estPasse).toList(), 'passés'),
],
),
),
// Pagination
if (widget.totalPages > 1) _buildPagination(),
],
),
@@ -112,428 +108,269 @@ class _EventsPageWithDataState extends State<EventsPageWithData>
);
}
/// Métriques des événements
Widget _buildEventMetrics() {
final upcoming = widget.events.where((e) => e['estAVenir'] == true).length;
final ongoing = widget.events.where((e) => e['estEnCours'] == true).length;
final past = widget.events.where((e) => e['estPasse'] == true).length;
Widget _buildHeader() {
final upcoming = widget.events.where((e) => e.estAVenir).length;
final ongoing = widget.events.where((e) => e.estEnCours).length;
final total = widget.totalCount;
return Container(
padding: const EdgeInsets.all(12),
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: UnionFlowColors.surface,
border: Border(bottom: BorderSide(color: UnionFlowColors.border.withOpacity(0.5), width: 1)),
),
child: Row(
children: [
Expanded(
child: _buildMetricCard(
'À venir',
upcoming.toString(),
Icons.event_available,
const Color(0xFF00B894),
),
),
const SizedBox(width: 8),
Expanded(
child: _buildMetricCard(
'En cours',
ongoing.toString(),
Icons.event,
const Color(0xFF74B9FF),
),
),
const SizedBox(width: 8),
Expanded(
child: _buildMetricCard(
'Passés',
past.toString(),
Icons.event_busy,
const Color(0xFF636E72),
),
),
Expanded(child: _buildStatCard(Icons.event_available, 'À venir', upcoming.toString(), UnionFlowColors.success)),
const SizedBox(width: 12),
Expanded(child: _buildStatCard(Icons.play_circle_outline, 'En cours', ongoing.toString(), UnionFlowColors.amber)),
const SizedBox(width: 12),
Expanded(child: _buildStatCard(Icons.calendar_today, 'Total', total.toString(), UnionFlowColors.unionGreen)),
],
),
);
}
Widget _buildMetricCard(String label, String value, IconData icon, Color color) {
Widget _buildStatCard(IconData icon, String label, String value, Color color) {
return Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.05),
blurRadius: 4,
offset: const Offset(0, 2),
),
],
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: 4),
Text(
value,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: color,
),
),
Text(
label,
style: const TextStyle(fontSize: 10, color: Color(0xFF636E72)),
),
Icon(icon, size: 20, color: color),
const SizedBox(height: 6),
Text(value, style: TextStyle(fontSize: 18, fontWeight: FontWeight.w700, color: color)),
const SizedBox(height: 2),
Text(label, style: TextStyle(fontSize: 10, fontWeight: FontWeight.w600, color: color), textAlign: TextAlign.center),
],
),
);
}
/// Recherche et filtres
Widget _buildSearchAndFilters(bool canManageEvents) {
Widget _buildSearchBar() {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
child: Row(
children: [
Expanded(
child: TextField(
controller: _searchController,
decoration: InputDecoration(
hintText: 'Rechercher un événement...',
prefixIcon: const Icon(Icons.search, size: 20),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
borderSide: BorderSide.none,
),
filled: true,
fillColor: Colors.white,
contentPadding: const EdgeInsets.symmetric(vertical: 8),
),
onChanged: (value) {
setState(() {
_searchQuery = value;
});
AppLogger.userAction('Search events', data: {'query': value});
},
),
),
if (canManageEvents) ...[
const SizedBox(width: 8),
IconButton(
icon: const Icon(Icons.add_circle, color: Color(0xFF6C5CE7)),
onPressed: () {
AppLogger.userAction('Add new event button clicked');
_showAddEventDialog();
},
tooltip: 'Ajouter un événement',
),
],
],
),
);
}
/// Barre d'onglets
Widget _buildTabBar() {
return Container(
margin: const EdgeInsets.symmetric(horizontal: 12),
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
color: UnionFlowColors.surface,
border: Border(bottom: BorderSide(color: UnionFlowColors.border.withOpacity(0.5), width: 1)),
),
child: TextField(
controller: _searchController,
onChanged: (v) {
setState(() => _searchQuery = v);
_searchDebounce?.cancel();
_searchDebounce = Timer(AppConstants.searchDebounce, () {
widget.onSearch?.call(v.isEmpty ? null : v);
});
},
style: const TextStyle(fontSize: 14, color: UnionFlowColors.textPrimary),
decoration: InputDecoration(
hintText: 'Rechercher un événement...',
hintStyle: const TextStyle(fontSize: 13, color: UnionFlowColors.textTertiary),
prefixIcon: const Icon(Icons.search, size: 20, color: UnionFlowColors.textSecondary),
suffixIcon: _searchQuery.isNotEmpty
? IconButton(
icon: const Icon(Icons.clear, size: 18, color: UnionFlowColors.textSecondary),
onPressed: () {
_searchDebounce?.cancel();
_searchController.clear();
setState(() => _searchQuery = '');
widget.onSearch?.call(null);
},
)
: null,
contentPadding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12), borderSide: BorderSide(color: UnionFlowColors.border.withOpacity(0.3))),
enabledBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(12), borderSide: BorderSide(color: UnionFlowColors.border.withOpacity(0.3))),
focusedBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(12), borderSide: const BorderSide(color: UnionFlowColors.unionGreen, width: 1.5)),
filled: true,
fillColor: UnionFlowColors.surfaceVariant.withOpacity(0.3),
),
),
);
}
Widget _buildTabs() {
return Container(
decoration: BoxDecoration(
color: UnionFlowColors.surface,
border: Border(bottom: BorderSide(color: UnionFlowColors.border.withOpacity(0.5), width: 1)),
),
child: TabBar(
controller: _tabController,
labelColor: const Color(0xFF6C5CE7),
unselectedLabelColor: const Color(0xFF636E72),
indicatorColor: const Color(0xFF6C5CE7),
labelStyle: const TextStyle(fontSize: 12, fontWeight: FontWeight.w600),
tabs: const [
Tab(text: 'Tous'),
Tab(text: 'À venir'),
Tab(text: 'En cours'),
Tab(text: 'Passés'),
Tab(text: 'Calendrier'),
],
labelColor: UnionFlowColors.unionGreen,
unselectedLabelColor: UnionFlowColors.textSecondary,
indicatorColor: UnionFlowColors.unionGreen,
indicatorWeight: 3,
labelStyle: const TextStyle(fontSize: 13, fontWeight: FontWeight.w700),
unselectedLabelStyle: const TextStyle(fontSize: 13, fontWeight: FontWeight.w600),
tabs: const [Tab(text: 'Tous'), Tab(text: 'À venir'), Tab(text: 'En cours'), Tab(text: 'Passés')],
),
);
}
/// Vue tous les événements
Widget _buildAllEventsView() {
final filtered = _getFilteredEvents();
return _buildEventsList(filtered);
}
Widget _buildEventsList(List<EvenementModel> events, String type) {
final filtered = _searchQuery.isEmpty
? events
: events.where((e) => e.titre.toLowerCase().contains(_searchQuery.toLowerCase()) || (e.lieu?.toLowerCase().contains(_searchQuery.toLowerCase()) ?? false)).toList();
/// Vue événements à venir
Widget _buildUpcomingEventsView() {
final filtered = _getFilteredEvents()
.where((e) => e['estAVenir'] == true)
.toList();
return _buildEventsList(filtered);
}
/// Vue événements en cours
Widget _buildOngoingEventsView() {
final filtered = _getFilteredEvents()
.where((e) => e['estEnCours'] == true)
.toList();
return _buildEventsList(filtered);
}
/// Vue événements passés
Widget _buildPastEventsView() {
final filtered = _getFilteredEvents()
.where((e) => e['estPasse'] == true)
.toList();
return _buildEventsList(filtered);
}
/// Vue calendrier (placeholder)
Widget _buildCalendarView() {
return const Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.calendar_month, size: 64, color: Color(0xFF636E72)),
SizedBox(height: 16),
Text(
'Vue calendrier',
style: TextStyle(fontSize: 18, color: Color(0xFF636E72)),
),
SizedBox(height: 8),
Text(
'À implémenter',
style: TextStyle(fontSize: 14, color: Color(0xFF636E72)),
),
],
),
);
}
/// Liste des événements
Widget _buildEventsList(List<Map<String, dynamic>> events) {
if (events.isEmpty) {
return const Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.event_busy, size: 64, color: Color(0xFF636E72)),
SizedBox(height: 16),
Text(
'Aucun événement trouvé',
style: TextStyle(fontSize: 18, color: Color(0xFF636E72)),
),
],
),
);
}
if (filtered.isEmpty) return _buildEmptyState(type);
return RefreshIndicator(
onRefresh: () async {
// Recharger les événements
// Note: Cette page utilise des données passées en paramètre
// Le rafraîchissement devrait être géré par le parent
await Future.delayed(const Duration(milliseconds: 500));
},
child: ListView.builder(
padding: const EdgeInsets.all(12),
itemCount: events.length,
itemBuilder: (context, index) {
final event = events[index];
return _buildEventCard(event);
},
onRefresh: () async => context.read<EvenementsBloc>().add(const LoadEvenements()),
color: UnionFlowColors.unionGreen,
child: ListView.separated(
padding: const EdgeInsets.all(16),
itemCount: filtered.length,
separatorBuilder: (_, __) => const SizedBox(height: 12),
itemBuilder: (context, index) => _buildEventCard(filtered[index]),
),
);
}
/// Carte d'événement
Widget _buildEventCard(Map<String, dynamic> event) {
final startDate = event['startDate'] as DateTime;
final dateFormatter = DateFormat('dd/MM/yyyy HH:mm');
Widget _buildEventCard(EvenementModel event) {
final df = DateFormat('dd MMM yyyy, HH:mm');
return Card(
margin: const EdgeInsets.only(bottom: 12),
elevation: 2,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
child: InkWell(
onTap: () {
AppLogger.userAction('View event details', data: {'eventId': event['id']});
_showEventDetails(event);
},
borderRadius: BorderRadius.circular(12),
child: Padding(
padding: const EdgeInsets.all(12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: Text(
event['title'],
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
),
_buildStatusChip(event['status']),
],
),
const SizedBox(height: 8),
Row(
children: [
const Icon(Icons.calendar_today, size: 14, color: Color(0xFF636E72)),
const SizedBox(width: 4),
Text(
dateFormatter.format(startDate),
style: const TextStyle(fontSize: 12, color: Color(0xFF636E72)),
),
const SizedBox(width: 12),
const Icon(Icons.location_on, size: 14, color: Color(0xFF636E72)),
const SizedBox(width: 4),
Expanded(
child: Text(
event['location'],
style: const TextStyle(fontSize: 12, color: Color(0xFF636E72)),
overflow: TextOverflow.ellipsis,
),
),
],
),
if (event['description'] != null && event['description'].toString().isNotEmpty) ...[
const SizedBox(height: 8),
Text(
event['description'],
style: const TextStyle(fontSize: 12, color: Color(0xFF636E72)),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
return GestureDetector(
onTap: () => _showEventDetails(event),
child: Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: UnionFlowColors.surface,
borderRadius: BorderRadius.circular(16),
boxShadow: UnionFlowColors.softShadow,
border: Border(left: BorderSide(color: _getStatutColor(event.statut), width: 4)),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
_buildBadge(_mapStatut(event.statut), _getStatutColor(event.statut)),
const SizedBox(width: 8),
_buildBadge(_mapType(event.type), UnionFlowColors.textSecondary),
const Spacer(),
const Icon(Icons.chevron_right, size: 18, color: UnionFlowColors.textTertiary),
],
const SizedBox(height: 8),
),
const SizedBox(height: 12),
Text(event.titre, style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w700, color: UnionFlowColors.textPrimary), maxLines: 2, overflow: TextOverflow.ellipsis),
const SizedBox(height: 12),
Row(
children: [
const Icon(Icons.access_time, size: 14, color: UnionFlowColors.textSecondary),
const SizedBox(width: 6),
Text(df.format(event.dateDebut), style: const TextStyle(fontSize: 12, color: UnionFlowColors.textSecondary)),
],
),
if (event.lieu != null) ...[
const SizedBox(height: 6),
Row(
children: [
_buildTypeChip(event['type']),
const SizedBox(width: 8),
if (event['cost'] != null && event['cost'] > 0)
_buildCostChip(event['cost']),
const Spacer(),
Text(
'${event['currentParticipants']}/${event['maxParticipants']}',
style: const TextStyle(fontSize: 12, color: Color(0xFF636E72)),
),
const SizedBox(width: 4),
const Icon(Icons.people, size: 14, color: Color(0xFF636E72)),
const Icon(Icons.location_on_outlined, size: 14, color: UnionFlowColors.textSecondary),
const SizedBox(width: 6),
Expanded(child: Text(event.lieu!, style: const TextStyle(fontSize: 12, color: UnionFlowColors.textSecondary), maxLines: 1, overflow: TextOverflow.ellipsis)),
],
),
],
),
const SizedBox(height: 12),
Row(
children: [
Container(
width: 24,
height: 24,
decoration: const BoxDecoration(gradient: UnionFlowColors.primaryGradient, shape: BoxShape.circle),
alignment: Alignment.center,
child: Text(event.organisateurNom?[0] ?? 'O', style: const TextStyle(color: Colors.white, fontWeight: FontWeight.w700, fontSize: 12)),
),
const SizedBox(width: 8),
Expanded(child: Text(event.organisateurNom ?? 'Organisateur', style: const TextStyle(fontSize: 11, color: UnionFlowColors.textSecondary), maxLines: 1, overflow: TextOverflow.ellipsis)),
Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: UnionFlowColors.goldPale,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: UnionFlowColors.gold.withOpacity(0.3), width: 1),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(Icons.people_outline, size: 12, color: UnionFlowColors.gold),
const SizedBox(width: 4),
Text('${event.participantsActuels}/${event.maxParticipants ?? ""}', style: const TextStyle(fontSize: 11, fontWeight: FontWeight.w600, color: UnionFlowColors.gold)),
],
),
),
],
),
],
),
),
);
}
Widget _buildStatusChip(String status) {
Color color;
switch (status) {
case 'Confirmé':
color = const Color(0xFF00B894);
break;
case 'Annulé':
color = const Color(0xFFFF7675);
break;
case 'Reporté':
color = const Color(0xFFFFBE76);
break;
case 'Brouillon':
color = const Color(0xFF636E72);
break;
default:
color = const Color(0xFF74B9FF);
}
Widget _buildBadge(String text, Color color) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: color.withOpacity(0.1),
borderRadius: BorderRadius.circular(12),
borderRadius: BorderRadius.circular(8),
border: Border.all(color: color.withOpacity(0.3), width: 1),
),
child: Text(
status,
style: TextStyle(
color: color,
fontSize: 10,
fontWeight: FontWeight.w600,
),
child: Text(text, style: TextStyle(fontSize: 10, fontWeight: FontWeight.w600, color: color)),
);
}
Widget _buildEmptyState(String type) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding: const EdgeInsets.all(24),
decoration: const BoxDecoration(color: UnionFlowColors.goldPale, shape: BoxShape.circle),
child: const Icon(Icons.event_busy, size: 64, color: UnionFlowColors.gold),
),
const SizedBox(height: 24),
Text('Aucun événement $type', style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w700, color: UnionFlowColors.textPrimary)),
const SizedBox(height: 8),
Text(_searchQuery.isEmpty ? 'La liste est vide pour le moment' : 'Essayez une autre recherche', style: const TextStyle(fontSize: 13, color: UnionFlowColors.textSecondary)),
],
),
);
}
Widget _buildTypeChip(String type) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: const Color(0xFF6C5CE7).withOpacity(0.1),
borderRadius: BorderRadius.circular(12),
),
child: Text(
type,
style: const TextStyle(
color: Color(0xFF6C5CE7),
fontSize: 10,
fontWeight: FontWeight.w600,
),
),
);
}
Widget _buildCostChip(double cost) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: const Color(0xFFFFBE76).withOpacity(0.1),
borderRadius: BorderRadius.circular(12),
),
child: Text(
'${cost.toStringAsFixed(2)}',
style: const TextStyle(
color: Color(0xFFFFBE76),
fontSize: 10,
fontWeight: FontWeight.w600,
),
),
);
}
/// Pagination
Widget _buildPagination() {
return Container(
padding: const EdgeInsets.all(12),
decoration: const BoxDecoration(
color: Colors.white,
border: Border(top: BorderSide(color: Color(0xFFE0E0E0))),
padding: const EdgeInsets.symmetric(vertical: 12),
decoration: BoxDecoration(
color: UnionFlowColors.surface,
border: Border(top: BorderSide(color: UnionFlowColors.border.withOpacity(0.5), width: 1)),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
IconButton(
icon: const Icon(Icons.chevron_left),
onPressed: widget.currentPage > 0
? () {
AppLogger.userAction('Previous page', data: {'page': widget.currentPage - 1});
context.read<EvenementsBloc>().add(LoadEvenements(page: widget.currentPage - 1));
}
icon: const Icon(Icons.chevron_left, size: 24),
color: widget.currentPage > 0 ? UnionFlowColors.unionGreen : UnionFlowColors.textTertiary,
onPressed: widget.currentPage > 0 && widget.onPageChanged != null
? () => widget.onPageChanged!(widget.currentPage - 1, _searchQuery.isEmpty ? null : _searchQuery)
: null,
),
Text('Page ${widget.currentPage + 1} / ${widget.totalPages}'),
Container(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
decoration: BoxDecoration(gradient: UnionFlowColors.primaryGradient, borderRadius: BorderRadius.circular(20)),
child: Text('Page ${widget.currentPage + 1} / ${widget.totalPages}', style: const TextStyle(fontSize: 13, fontWeight: FontWeight.w600, color: Colors.white)),
),
IconButton(
icon: const Icon(Icons.chevron_right),
onPressed: widget.currentPage < widget.totalPages - 1
? () {
AppLogger.userAction('Next page', data: {'page': widget.currentPage + 1});
context.read<EvenementsBloc>().add(LoadEvenements(page: widget.currentPage + 1));
}
icon: const Icon(Icons.chevron_right, size: 24),
color: widget.currentPage < widget.totalPages - 1 ? UnionFlowColors.unionGreen : UnionFlowColors.textTertiary,
onPressed: widget.currentPage < widget.totalPages - 1 && widget.onPageChanged != null
? () => widget.onPageChanged!(widget.currentPage + 1, _searchQuery.isEmpty ? null : _searchQuery)
: null,
),
],
@@ -541,62 +378,74 @@ class _EventsPageWithDataState extends State<EventsPageWithData>
);
}
/// Filtrer les événements
List<Map<String, dynamic>> _getFilteredEvents() {
var filtered = widget.events;
if (_searchQuery.isNotEmpty) {
filtered = filtered.where((e) {
final title = e['title'].toString().toLowerCase();
final description = e['description'].toString().toLowerCase();
final query = _searchQuery.toLowerCase();
return title.contains(query) || description.contains(query);
}).toList();
String _mapStatut(StatutEvenement s) {
switch (s) {
case StatutEvenement.planifie:
return 'Planifié';
case StatutEvenement.confirme:
return 'Confirmé';
case StatutEvenement.enCours:
return 'En cours';
case StatutEvenement.termine:
return 'Terminé';
case StatutEvenement.annule:
return 'Annulé';
case StatutEvenement.reporte:
return 'Reporté';
}
return filtered;
}
/// Vérifier permissions
bool _canManageEvents(UserRole role) {
return role.level >= UserRole.moderator.level;
Color _getStatutColor(StatutEvenement s) {
switch (s) {
case StatutEvenement.planifie:
return UnionFlowColors.info;
case StatutEvenement.confirme:
return UnionFlowColors.success;
case StatutEvenement.enCours:
return UnionFlowColors.amber;
case StatutEvenement.termine:
return UnionFlowColors.textSecondary;
case StatutEvenement.annule:
return UnionFlowColors.error;
case StatutEvenement.reporte:
return UnionFlowColors.warning;
}
}
/// Afficher détails événement
void _showEventDetails(Map<String, dynamic> event) {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text(event['title']),
content: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Description: ${event['description']}'),
const SizedBox(height: 8),
Text('Lieu: ${event['location']}'),
Text('Type: ${event['type']}'),
Text('Statut: ${event['status']}'),
Text('Participants: ${event['currentParticipants']}/${event['maxParticipants']}'),
],
),
String _mapType(TypeEvenement t) {
switch (t) {
case TypeEvenement.assembleeGenerale:
return 'AG';
case TypeEvenement.reunion:
return 'Réunion';
case TypeEvenement.formation:
return 'Formation';
case TypeEvenement.conference:
return 'Conférence';
case TypeEvenement.atelier:
return 'Atelier';
case TypeEvenement.seminaire:
return 'Séminaire';
case TypeEvenement.evenementSocial:
return 'Social';
case TypeEvenement.manifestation:
return 'Manif.';
case TypeEvenement.celebration:
return 'Célébr.';
case TypeEvenement.autre:
return 'Autre';
}
}
void _showEventDetails(EvenementModel event) {
final bloc = context.read<EvenementsBloc>();
Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (_) => BlocProvider.value(
value: bloc,
child: EventDetailPage(evenement: event),
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('Fermer'),
),
],
),
);
}
/// Dialogue ajout événement
void _showAddEventDialog() {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Fonctionnalité à implémenter')),
);
}
}

View File

@@ -14,7 +14,7 @@ import '../../../../core/utils/logger.dart';
import '../../bloc/evenements_bloc.dart';
import '../../bloc/evenements_event.dart';
import '../../bloc/evenements_state.dart';
import '../../data/models/evenement_model.dart';
import '../widgets/create_event_dialog.dart';
import 'events_page_connected.dart';
final _getIt = GetIt.instance;
@@ -50,7 +50,9 @@ class EventsPageConnected extends StatelessWidget {
Widget build(BuildContext context) {
return BlocListener<EvenementsBloc, EvenementsState>(
listener: (context, state) {
// Gestion des erreurs avec SnackBar
if (state is EvenementCreated) {
context.read<EvenementsBloc>().add(const LoadEvenements(refresh: true));
}
if (state is EvenementsError) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
@@ -102,19 +104,36 @@ class EventsPageConnected extends StatelessWidget {
);
}
// État chargé avec succès
if (state is EvenementCreated) {
return Container(
color: const Color(0xFFF8F9FA),
child: const Center(
child: AppLoadingWidget(message: 'Actualisation...'),
),
);
}
if (state is EvenementsLoaded) {
final evenements = state.evenements;
AppLogger.info('EventsPageConnected: ${evenements.length} événements chargés');
// Convertir les événements en format Map pour l'UI existante
final eventsData = _convertEvenementsToMapList(evenements);
return EventsPageWithData(
events: eventsData,
events: evenements,
totalCount: state.total,
currentPage: state.page,
totalPages: state.totalPages,
onSearch: (query) {
context.read<EvenementsBloc>().add(LoadEvenements(page: 0, recherche: query));
},
onAddEvent: () async {
await showDialog<void>(
context: context,
builder: (_) => const CreateEventDialog(),
);
},
onPageChanged: (page, recherche) {
context.read<EvenementsBloc>().add(LoadEvenements(page: page, recherche: recherche));
},
);
}
@@ -159,117 +178,5 @@ class EventsPageConnected extends StatelessWidget {
),
);
}
/// Convertit une liste de EvenementModel en List<Map<String, dynamic>>
List<Map<String, dynamic>> _convertEvenementsToMapList(List<EvenementModel> evenements) {
return evenements.map((evenement) => _convertEvenementToMap(evenement)).toList();
}
/// Convertit un EvenementModel en Map<String, dynamic>
Map<String, dynamic> _convertEvenementToMap(EvenementModel evenement) {
return {
'id': evenement.id ?? '',
'title': evenement.titre,
'description': evenement.description ?? '',
'startDate': evenement.dateDebut,
'endDate': evenement.dateFin,
'location': evenement.lieu ?? '',
'address': evenement.adresse ?? '',
'type': _mapTypeToString(evenement.type),
'status': _mapStatutToString(evenement.statut),
'maxParticipants': evenement.maxParticipants,
'currentParticipants': evenement.participantsActuels,
'organizer': evenement.organisateurNom ?? 'Organisateur inconnu',
'priority': _mapPrioriteToString(evenement.priorite),
'isPublic': evenement.estPublic,
'requiresRegistration': evenement.inscriptionRequise,
'cost': evenement.cout,
'tags': evenement.tags,
'createdBy': evenement.organisateurNom ?? 'Créateur inconnu',
'createdAt': evenement.dateCreation ?? DateTime.now(),
'lastModified': evenement.dateModification ?? DateTime.now(),
// Champs supplémentaires du modèle
'ville': evenement.ville,
'codePostal': evenement.codePostal,
'organisateurId': evenement.organisateurId,
'organisationId': evenement.organisationId,
'devise': evenement.devise,
'imageUrl': evenement.imageUrl,
'documentUrl': evenement.documentUrl,
// Propriétés calculées
'dureeHeures': evenement.dureeHeures,
'joursAvantEvenement': evenement.joursAvantEvenement,
'estAVenir': evenement.estAVenir,
'estEnCours': evenement.estEnCours,
'estPasse': evenement.estPasse,
'placesDisponibles': evenement.placesDisponibles,
'estComplet': evenement.estComplet,
'peutSinscrire': evenement.peutSinscrire,
};
}
/// Mappe le type du modèle vers une chaîne lisible
String _mapTypeToString(TypeEvenement? type) {
if (type == null) return 'Autre';
switch (type) {
case TypeEvenement.assembleeGenerale:
return 'Assemblée Générale';
case TypeEvenement.reunion:
return 'Réunion';
case TypeEvenement.formation:
return 'Formation';
case TypeEvenement.conference:
return 'Conférence';
case TypeEvenement.atelier:
return 'Atelier';
case TypeEvenement.seminaire:
return 'Séminaire';
case TypeEvenement.evenementSocial:
return 'Événement Social';
case TypeEvenement.manifestation:
return 'Manifestation';
case TypeEvenement.celebration:
return 'Célébration';
case TypeEvenement.autre:
return 'Autre';
}
}
/// Mappe le statut du modèle vers une chaîne lisible
String _mapStatutToString(StatutEvenement? statut) {
if (statut == null) return 'Planifié';
switch (statut) {
case StatutEvenement.planifie:
return 'Planifié';
case StatutEvenement.confirme:
return 'Confirmé';
case StatutEvenement.enCours:
return 'En cours';
case StatutEvenement.termine:
return 'Terminé';
case StatutEvenement.annule:
return 'Annulé';
case StatutEvenement.reporte:
return 'Reporté';
}
}
/// Mappe la priorité du modèle vers une chaîne lisible
String _mapPrioriteToString(PrioriteEvenement? priorite) {
if (priorite == null) return 'Moyenne';
switch (priorite) {
case PrioriteEvenement.basse:
return 'Basse';
case PrioriteEvenement.moyenne:
return 'Moyenne';
case PrioriteEvenement.haute:
return 'Haute';
}
}
}

View File

@@ -7,6 +7,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:intl/intl.dart';
import '../../bloc/evenements_bloc.dart';
import '../../bloc/evenements_event.dart';
import '../../bloc/evenements_state.dart';
import '../../data/models/evenement_model.dart';
/// Dialogue de création d'événement
@@ -19,7 +20,8 @@ class CreateEventDialog extends StatefulWidget {
class _CreateEventDialogState extends State<CreateEventDialog> {
final _formKey = GlobalKey<FormState>();
bool _createSent = false;
// Contrôleurs de texte
final _titreController = TextEditingController();
final _descriptionController = TextEditingController();
@@ -46,7 +48,29 @@ class _CreateEventDialogState extends State<CreateEventDialog> {
@override
Widget build(BuildContext context) {
return Dialog(
return BlocListener<EvenementsBloc, EvenementsState>(
listenWhen: (_, state) => _createSent && (state is EvenementCreated || state is EvenementsError),
listener: (context, state) {
if (!_createSent || !mounted) return;
if (state is EvenementsError) {
setState(() => _createSent = false);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(state.message), backgroundColor: Colors.red),
);
return;
}
if (state is EvenementCreated) {
setState(() => _createSent = false);
Navigator.pop(context);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Événement créé avec succès'),
backgroundColor: Colors.green,
),
);
}
},
child: Dialog(
child: Container(
width: MediaQuery.of(context).size.width * 0.9,
constraints: const BoxConstraints(maxHeight: 600),
@@ -297,6 +321,7 @@ class _CreateEventDialogState extends State<CreateEventDialog> {
],
),
),
),
);
}
@@ -409,19 +434,8 @@ class _CreateEventDialogState extends State<CreateEventDialog> {
statut: StatutEvenement.planifie,
);
// Envoyer l'événement au BLoC
setState(() => _createSent = true);
context.read<EvenementsBloc>().add(CreateEvenement(evenement));
// Fermer le dialogue
Navigator.pop(context);
// Afficher un message de succès
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Événement créé avec succès'),
backgroundColor: Colors.green,
),
);
}
}
}

View File

@@ -7,6 +7,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:intl/intl.dart';
import '../../bloc/evenements_bloc.dart';
import '../../bloc/evenements_event.dart';
import '../../bloc/evenements_state.dart';
import '../../data/models/evenement_model.dart';
/// Dialogue de modification d'événement
@@ -24,6 +25,7 @@ class EditEventDialog extends StatefulWidget {
class _EditEventDialogState extends State<EditEventDialog> {
final _formKey = GlobalKey<FormState>();
bool _updateSent = false;
// Contrôleurs de texte
late final TextEditingController _titreController;
@@ -74,7 +76,29 @@ class _EditEventDialogState extends State<EditEventDialog> {
@override
Widget build(BuildContext context) {
return Dialog(
return BlocListener<EvenementsBloc, EvenementsState>(
listenWhen: (_, state) => _updateSent && (state is EvenementUpdated || state is EvenementsError),
listener: (context, state) {
if (!_updateSent || !mounted) return;
if (state is EvenementsError) {
setState(() => _updateSent = false);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(state.message), backgroundColor: Colors.red),
);
return;
}
if (state is EvenementUpdated) {
setState(() => _updateSent = false);
Navigator.pop(context);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Événement modifié avec succès'),
backgroundColor: Colors.green,
),
);
}
},
child: Dialog(
child: Container(
width: MediaQuery.of(context).size.width * 0.9,
constraints: const BoxConstraints(maxHeight: 600),
@@ -356,6 +380,7 @@ class _EditEventDialogState extends State<EditEventDialog> {
],
),
),
),
);
}
@@ -492,19 +517,8 @@ class _EditEventDialogState extends State<EditEventDialog> {
estPublic: _estPublic,
);
// Envoyer l'événement au BLoC
setState(() => _updateSent = true);
context.read<EvenementsBloc>().add(UpdateEvenement(widget.evenement.id!.toString(), evenementUpdated));
// Fermer le dialogue
Navigator.pop(context);
// Afficher un message de succès
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Événement modifié avec succès'),
backgroundColor: Colors.green,
),
);
}
}
}

View File

@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../bloc/evenements_bloc.dart';
import '../../bloc/evenements_event.dart';
import '../../bloc/evenements_state.dart';
import '../../data/models/evenement_model.dart';
class InscriptionEventDialog extends StatefulWidget {
@@ -24,6 +25,7 @@ class InscriptionEventDialog extends StatefulWidget {
class _InscriptionEventDialogState extends State<InscriptionEventDialog> {
final _formKey = GlobalKey<FormState>();
final _commentaireController = TextEditingController();
bool _actionSent = false;
@override
void dispose() {
@@ -33,7 +35,38 @@ class _InscriptionEventDialogState extends State<InscriptionEventDialog> {
@override
Widget build(BuildContext context) {
return Dialog(
return BlocListener<EvenementsBloc, EvenementsState>(
listenWhen: (_, state) =>
_actionSent &&
(state is EvenementInscrit ||
state is EvenementDesinscrit ||
state is EvenementsError),
listener: (context, state) {
if (!_actionSent || !mounted) return;
if (state is EvenementsError) {
setState(() => _actionSent = false);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(state.message), backgroundColor: Colors.red),
);
return;
}
if (state is EvenementInscrit || state is EvenementDesinscrit) {
setState(() => _actionSent = false);
Navigator.pop(context);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
state is EvenementInscrit
? 'Inscription réussie'
: 'Désinscription réussie',
),
backgroundColor:
state is EvenementInscrit ? Colors.green : Colors.orange,
),
);
}
},
child: Dialog(
child: Container(
width: MediaQuery.of(context).size.width * 0.9,
constraints: const BoxConstraints(maxHeight: 500),
@@ -67,6 +100,7 @@ class _InscriptionEventDialogState extends State<InscriptionEventDialog> {
],
),
),
),
);
}
@@ -290,30 +324,13 @@ class _InscriptionEventDialogState extends State<InscriptionEventDialog> {
}
void _submitForm() {
setState(() => _actionSent = true);
if (widget.isInscrit) {
// Désinscription
context.read<EvenementsBloc>().add(DesinscrireEvenement(widget.evenement.id!.toString()));
Navigator.pop(context);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Désinscription réussie'),
backgroundColor: Colors.orange,
),
);
} else {
// Inscription
context.read<EvenementsBloc>().add(
InscrireEvenement(widget.evenement.id!.toString()),
);
Navigator.pop(context);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Inscription réussie'),
backgroundColor: Colors.green,
),
);
}
}
}