Initial commit: unionflow-mobile-apps
Application Flutter complète (sans build artifacts). Signed-off-by: lions dev Team
This commit is contained in:
441
lib/features/events/presentation/pages/event_detail_page.dart
Normal file
441
lib/features/events/presentation/pages/event_detail_page.dart
Normal file
@@ -0,0 +1,441 @@
|
||||
/// Page de détails d'un événement
|
||||
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 StatefulWidget {
|
||||
final EvenementModel evenement;
|
||||
|
||||
const EventDetailPage({
|
||||
super.key,
|
||||
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(
|
||||
appBar: AppBar(
|
||||
title: const Text('Détails de l\'événement'),
|
||||
backgroundColor: const Color(0xFF3B82F6),
|
||||
foregroundColor: Colors.white,
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.edit),
|
||||
onPressed: () => _showEditDialog(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: BlocBuilder<EvenementsBloc, EvenementsState>(
|
||||
builder: (context, state) {
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildHeader(),
|
||||
_buildInfoSection(),
|
||||
_buildDescriptionSection(),
|
||||
if (widget.evenement.lieu != null) _buildLocationSection(),
|
||||
_buildParticipantsSection(),
|
||||
const SizedBox(height: 80), // Espace pour le bouton flottant
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
floatingActionButton: _buildInscriptionButton(context),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildHeader() {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(24),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
const Color(0xFF3B82F6),
|
||||
const Color(0xFF3B82F6).withOpacity(0.8),
|
||||
],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: Text(
|
||||
_getTypeLabel(widget.evenement.type),
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
widget.evenement.titre,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: _getStatutColor(widget.evenement.statut),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text(
|
||||
_getStatutLabel(widget.evenement.statut),
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildInfoSection() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
children: [
|
||||
_buildInfoRow(
|
||||
Icons.calendar_today,
|
||||
'Date de début',
|
||||
_formatDate(widget.evenement.dateDebut),
|
||||
),
|
||||
const Divider(),
|
||||
_buildInfoRow(
|
||||
Icons.event,
|
||||
'Date de fin',
|
||||
_formatDate(widget.evenement.dateFin),
|
||||
),
|
||||
if (widget.evenement.maxParticipants != null) ...[
|
||||
const Divider(),
|
||||
_buildInfoRow(
|
||||
Icons.people,
|
||||
'Places',
|
||||
'${widget.evenement.participantsActuels} / ${widget.evenement.maxParticipants}',
|
||||
),
|
||||
],
|
||||
if (widget.evenement.organisateurNom != null) ...[
|
||||
const Divider(),
|
||||
_buildInfoRow(
|
||||
Icons.person,
|
||||
'Organisateur',
|
||||
widget.evenement.organisateurNom!,
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildInfoRow(IconData icon, String label, String value) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(icon, color: const Color(0xFF3B82F6), size: 20),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.grey[600],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
value,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDescriptionSection() {
|
||||
if (widget.evenement.description == null) return const SizedBox.shrink();
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'Description',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
widget.evenement.description!,
|
||||
style: const TextStyle(fontSize: 14, height: 1.5),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLocationSection() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'Lieu',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.location_on, color: Color(0xFF3B82F6)),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
widget.evenement.lieu!,
|
||||
style: const TextStyle(fontSize: 14),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildParticipantsSection() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const Text(
|
||||
'Participants',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'${widget.evenement.participantsActuels} inscrits',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.grey[600],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[100],
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: const Row(
|
||||
children: [
|
||||
Icon(Icons.info_outline, size: 20),
|
||||
SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'La liste des participants est visible uniquement pour les organisateurs',
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildInscriptionButton(BuildContext context) {
|
||||
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),
|
||||
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) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => BlocProvider.value(
|
||||
value: context.read<EvenementsBloc>(),
|
||||
child: InscriptionEventDialog(
|
||||
evenement: widget.evenement,
|
||||
isInscrit: isInscrit,
|
||||
),
|
||||
),
|
||||
).then((_) => _loadInscriptionStatus());
|
||||
}
|
||||
|
||||
void _showEditDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => BlocProvider.value(
|
||||
value: context.read<EvenementsBloc>(),
|
||||
child: EditEventDialog(evenement: widget.evenement),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _formatDate(DateTime date) {
|
||||
final months = [
|
||||
'janvier', 'février', 'mars', 'avril', 'mai', 'juin',
|
||||
'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'
|
||||
];
|
||||
return '${date.day} ${months[date.month - 1]} ${date.year} à ${date.hour}:${date.minute.toString().padLeft(2, '0')}';
|
||||
}
|
||||
|
||||
String _getTypeLabel(TypeEvenement type) {
|
||||
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';
|
||||
}
|
||||
}
|
||||
|
||||
String _getStatutLabel(StatutEvenement statut) {
|
||||
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é';
|
||||
}
|
||||
}
|
||||
|
||||
Color _getStatutColor(StatutEvenement statut) {
|
||||
switch (statut) {
|
||||
case StatutEvenement.planifie:
|
||||
return Colors.blue;
|
||||
case StatutEvenement.confirme:
|
||||
return Colors.green;
|
||||
case StatutEvenement.enCours:
|
||||
return Colors.orange;
|
||||
case StatutEvenement.termine:
|
||||
return Colors.grey;
|
||||
case StatutEvenement.annule:
|
||||
return Colors.red;
|
||||
case StatutEvenement.reporte:
|
||||
return Colors.purple;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,451 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:intl/intl.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 Événements - Design UnionFlow
|
||||
class EventsPageWithData extends StatefulWidget {
|
||||
final List<EvenementModel> events;
|
||||
final int totalCount;
|
||||
final int currentPage;
|
||||
final int totalPages;
|
||||
final void Function(String? query)? onSearch;
|
||||
final VoidCallback? onAddEvent;
|
||||
final void Function(int page, String? recherche)? onPageChanged;
|
||||
|
||||
const EventsPageWithData({
|
||||
super.key,
|
||||
required this.events,
|
||||
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 {
|
||||
final TextEditingController _searchController = TextEditingController();
|
||||
late TabController _tabController;
|
||||
String _searchQuery = '';
|
||||
Timer? _searchDebounce;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_tabController = TabController(length: 4, vsync: this);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_searchDebounce?.cancel();
|
||||
_searchController.dispose();
|
||||
_tabController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<AuthBloc, AuthState>(
|
||||
builder: (context, state) {
|
||||
if (state is! AuthAuthenticated) {
|
||||
return const Scaffold(body: Center(child: CircularProgressIndicator()));
|
||||
}
|
||||
|
||||
final canManageEvents = state.effectiveRole.level >= UserRole.moderator.level;
|
||||
|
||||
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: [
|
||||
_buildHeader(),
|
||||
_buildSearchBar(),
|
||||
_buildTabs(),
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
controller: _tabController,
|
||||
children: [
|
||||
_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'),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (widget.totalPages > 1) _buildPagination(),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
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(20),
|
||||
decoration: BoxDecoration(
|
||||
color: UnionFlowColors.surface,
|
||||
border: Border(bottom: BorderSide(color: UnionFlowColors.border.withOpacity(0.5), width: 1)),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
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 _buildStatCard(IconData icon, String label, String value, Color color) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: color.withOpacity(0.3), width: 1),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
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),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSearchBar() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
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: 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')],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
if (filtered.isEmpty) return _buildEmptyState(type);
|
||||
|
||||
return RefreshIndicator(
|
||||
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]),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildEventCard(EvenementModel event) {
|
||||
final df = DateFormat('dd MMM yyyy, HH:mm');
|
||||
|
||||
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: 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: [
|
||||
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 _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(8),
|
||||
border: Border.all(color: color.withOpacity(0.3), width: 1),
|
||||
),
|
||||
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 _buildPagination() {
|
||||
return Container(
|
||||
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, 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,
|
||||
),
|
||||
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, 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,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
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é';
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,830 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import '../../../../core/utils/logger.dart';
|
||||
import '../../../../shared/widgets/info_badge.dart';
|
||||
import '../../../../shared/widgets/mini_avatar.dart';
|
||||
import '../../../../shared/design_system/unionflow_design_system.dart';
|
||||
import '../../../../shared/design_system/tokens/app_typography.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';
|
||||
|
||||
/// Page de gestion des événements - UI/UX Premium
|
||||
class EventsPageWithData extends StatefulWidget {
|
||||
final List<EvenementModel> events;
|
||||
final int totalCount;
|
||||
final int currentPage;
|
||||
final int totalPages;
|
||||
|
||||
const EventsPageWithData({
|
||||
super.key,
|
||||
required this.events,
|
||||
required this.totalCount,
|
||||
required this.currentPage,
|
||||
required this.totalPages,
|
||||
});
|
||||
|
||||
@override
|
||||
State<EventsPageWithData> createState() => _EventsPageWithDataState();
|
||||
}
|
||||
|
||||
class _EventsPageWithDataState extends State<EventsPageWithData>
|
||||
with TickerProviderStateMixin {
|
||||
final TextEditingController _searchController = TextEditingController();
|
||||
late TabController _tabController;
|
||||
String _searchQuery = '';
|
||||
bool _isSearchExpanded = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_tabController = TabController(length: 5, vsync: this);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_searchController.dispose();
|
||||
_tabController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<AuthBloc, AuthState>(
|
||||
builder: (context, state) {
|
||||
if (state is! AuthAuthenticated) {
|
||||
return const Scaffold(body: Center(child: CircularProgressIndicator()));
|
||||
}
|
||||
|
||||
final canManageEvents = state.effectiveRole.level >= UserRole.moderator.level;
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: ColorTokens.background,
|
||||
appBar: UFAppBar(
|
||||
title: 'ÉVÉNEMENTS',
|
||||
automaticallyImplyLeading: false,
|
||||
actions: [
|
||||
// Search toggle button
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
_isSearchExpanded ? Icons.close : Icons.search,
|
||||
color: ColorTokens.onSurface,
|
||||
size: 20,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_isSearchExpanded = !_isSearchExpanded;
|
||||
if (!_isSearchExpanded) {
|
||||
_searchController.clear();
|
||||
_searchQuery = '';
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
if (canManageEvents)
|
||||
IconButton(
|
||||
icon: const Icon(
|
||||
Icons.add_circle_outline,
|
||||
color: ColorTokens.primary,
|
||||
size: 22,
|
||||
),
|
||||
onPressed: () => AppLogger.info('Add Event clicked'),
|
||||
),
|
||||
const SizedBox(width: SpacingTokens.xs),
|
||||
],
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
// Header avec stats compactes
|
||||
_buildCompactHeader(),
|
||||
|
||||
// Search bar (expandable)
|
||||
if (_isSearchExpanded) _buildSearchBar(),
|
||||
|
||||
// Tabs avec badges
|
||||
_buildEnhancedTabBar(),
|
||||
|
||||
// Liste d'événements
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
controller: _tabController,
|
||||
children: [
|
||||
_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'),
|
||||
_buildCalendarView(),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// Pagination
|
||||
if (widget.totalPages > 1) _buildEnhancedPagination(),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// Header compact avec 3 métriques en ligne
|
||||
Widget _buildCompactHeader() {
|
||||
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.symmetric(
|
||||
horizontal: SpacingTokens.md,
|
||||
vertical: SpacingTokens.sm,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorTokens.surface,
|
||||
border: Border(
|
||||
bottom: BorderSide(
|
||||
color: ColorTokens.outlineVariant.withOpacity(0.5),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
_buildCompactMetric(
|
||||
icon: Icons.event_available,
|
||||
label: 'À venir',
|
||||
value: upcoming.toString(),
|
||||
color: ColorTokens.success,
|
||||
),
|
||||
const SizedBox(width: SpacingTokens.md),
|
||||
_buildCompactMetric(
|
||||
icon: Icons.play_circle_outline,
|
||||
label: 'En cours',
|
||||
value: ongoing.toString(),
|
||||
color: ColorTokens.primary,
|
||||
),
|
||||
const Spacer(),
|
||||
_buildTotalBadge(total),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCompactMetric({
|
||||
required IconData icon,
|
||||
required String label,
|
||||
required String value,
|
||||
required Color color,
|
||||
}) {
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(6),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(RadiusTokens.sm),
|
||||
),
|
||||
child: Icon(icon, size: 14, color: color),
|
||||
),
|
||||
const SizedBox(width: SpacingTokens.xs),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
value,
|
||||
style: AppTypography.headerSmall.copyWith(
|
||||
fontSize: 16,
|
||||
height: 1.2,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
label,
|
||||
style: TypographyTokens.labelSmall.copyWith(
|
||||
fontSize: 10,
|
||||
color: ColorTokens.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTotalBadge(int total) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: SpacingTokens.sm,
|
||||
vertical: SpacingTokens.xs,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorTokens.secondaryContainer,
|
||||
borderRadius: BorderRadius.circular(RadiusTokens.round),
|
||||
border: Border.all(
|
||||
color: ColorTokens.secondary.withOpacity(0.3),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
total.toString(),
|
||||
style: AppTypography.actionText.copyWith(
|
||||
color: ColorTokens.secondary,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
'TOTAL',
|
||||
style: TypographyTokens.labelSmall.copyWith(
|
||||
color: ColorTokens.secondary,
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Search bar avec animation
|
||||
Widget _buildSearchBar() {
|
||||
return AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: SpacingTokens.md,
|
||||
vertical: SpacingTokens.sm,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorTokens.surface,
|
||||
border: Border(
|
||||
bottom: BorderSide(
|
||||
color: ColorTokens.outlineVariant.withOpacity(0.5),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: TextField(
|
||||
controller: _searchController,
|
||||
autofocus: true,
|
||||
onChanged: (v) => setState(() => _searchQuery = v),
|
||||
style: TypographyTokens.bodyMedium,
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Rechercher un événement...',
|
||||
hintStyle: TypographyTokens.bodySmall.copyWith(
|
||||
color: ColorTokens.onSurfaceVariant,
|
||||
),
|
||||
prefixIcon: const Icon(
|
||||
Icons.search,
|
||||
size: 18,
|
||||
color: ColorTokens.onSurfaceVariant,
|
||||
),
|
||||
suffixIcon: _searchQuery.isNotEmpty
|
||||
? IconButton(
|
||||
icon: const Icon(
|
||||
Icons.clear,
|
||||
size: 18,
|
||||
color: ColorTokens.onSurfaceVariant,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_searchController.clear();
|
||||
_searchQuery = '';
|
||||
});
|
||||
},
|
||||
)
|
||||
: null,
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
vertical: SpacingTokens.sm,
|
||||
horizontal: SpacingTokens.xs,
|
||||
),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(RadiusTokens.md),
|
||||
borderSide: BorderSide(
|
||||
color: ColorTokens.outline.withOpacity(0.3),
|
||||
),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(RadiusTokens.md),
|
||||
borderSide: BorderSide(
|
||||
color: ColorTokens.outline.withOpacity(0.3),
|
||||
),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(RadiusTokens.md),
|
||||
borderSide: const BorderSide(
|
||||
color: ColorTokens.primary,
|
||||
width: 1.5,
|
||||
),
|
||||
),
|
||||
filled: true,
|
||||
fillColor: ColorTokens.surfaceVariant.withOpacity(0.3),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// TabBar amélioré avec badges de comptage
|
||||
Widget _buildEnhancedTabBar() {
|
||||
final allCount = widget.events.length;
|
||||
final upcomingCount = widget.events.where((e) => e.estAVenir).length;
|
||||
final ongoingCount = widget.events.where((e) => e.estEnCours).length;
|
||||
final pastCount = widget.events.where((e) => e.estPasse).length;
|
||||
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: ColorTokens.surface,
|
||||
border: Border(
|
||||
bottom: BorderSide(
|
||||
color: ColorTokens.outlineVariant.withOpacity(0.5),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: TabBar(
|
||||
controller: _tabController,
|
||||
labelColor: ColorTokens.primary,
|
||||
unselectedLabelColor: ColorTokens.onSurfaceVariant,
|
||||
indicatorColor: ColorTokens.primary,
|
||||
indicatorWeight: 2.5,
|
||||
labelStyle: TypographyTokens.labelMedium.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
unselectedLabelStyle: TypographyTokens.labelMedium,
|
||||
tabs: [
|
||||
_buildTabWithBadge('Tous', allCount),
|
||||
_buildTabWithBadge('À venir', upcomingCount),
|
||||
_buildTabWithBadge('En cours', ongoingCount),
|
||||
_buildTabWithBadge('Passés', pastCount),
|
||||
const Tab(
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.calendar_month, size: 14),
|
||||
SizedBox(width: 4),
|
||||
Text('Calendrier'),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTabWithBadge(String label, int count) {
|
||||
return Tab(
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(label),
|
||||
if (count > 0) ...[
|
||||
const SizedBox(width: 4),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorTokens.primary.withOpacity(0.15),
|
||||
borderRadius: BorderRadius.circular(RadiusTokens.round),
|
||||
),
|
||||
child: Text(
|
||||
count.toString(),
|
||||
style: TypographyTokens.labelSmall.copyWith(
|
||||
fontSize: 9,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: ColorTokens.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Liste d'événements optimisée
|
||||
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();
|
||||
|
||||
if (filtered.isEmpty) {
|
||||
return _buildEmptyState(type);
|
||||
}
|
||||
|
||||
return RefreshIndicator(
|
||||
onRefresh: () async => context.read<EvenementsBloc>().add(const LoadEvenements()),
|
||||
color: ColorTokens.primary,
|
||||
child: ListView.separated(
|
||||
padding: const EdgeInsets.all(SpacingTokens.md),
|
||||
itemCount: filtered.length,
|
||||
separatorBuilder: (_, __) => const SizedBox(height: SpacingTokens.sm),
|
||||
itemBuilder: (context, index) => _buildEnhancedEventCard(filtered[index]),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Empty state élégant
|
||||
Widget _buildEmptyState(String type) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(SpacingTokens.lg),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorTokens.surfaceVariant.withOpacity(0.3),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.event_busy,
|
||||
size: 48,
|
||||
color: ColorTokens.onSurfaceVariant.withOpacity(0.5),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: SpacingTokens.md),
|
||||
Text(
|
||||
'Aucun événement $type',
|
||||
style: AppTypography.headerSmall.copyWith(
|
||||
color: ColorTokens.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: SpacingTokens.xs),
|
||||
Text(
|
||||
_searchQuery.isEmpty
|
||||
? 'La liste est vide pour le moment'
|
||||
: 'Aucun résultat pour "$_searchQuery"',
|
||||
style: TypographyTokens.bodySmall.copyWith(
|
||||
color: ColorTokens.onSurfaceVariant.withOpacity(0.7),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Card événement améliorée
|
||||
Widget _buildEnhancedEventCard(EvenementModel event) {
|
||||
final df = DateFormat('dd MMM yyyy, HH:mm');
|
||||
final isUrgent = event.estAVenir &&
|
||||
event.dateDebut.difference(DateTime.now()).inDays <= 2;
|
||||
|
||||
return UFCard(
|
||||
margin: EdgeInsets.zero,
|
||||
onTap: () => _showEventDetails(event),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Header avec badges
|
||||
Row(
|
||||
children: [
|
||||
InfoBadge(
|
||||
text: _mapStatut(event.statut),
|
||||
backgroundColor: _getStatutColor(event.statut).withOpacity(0.12),
|
||||
textColor: _getStatutColor(event.statut),
|
||||
),
|
||||
const SizedBox(width: SpacingTokens.xs),
|
||||
InfoBadge.neutral(_mapType(event.type)),
|
||||
if (isUrgent) ...[
|
||||
const SizedBox(width: SpacingTokens.xs),
|
||||
InfoBadge(
|
||||
text: 'URGENT',
|
||||
backgroundColor: ColorTokens.error.withOpacity(0.12),
|
||||
textColor: ColorTokens.error,
|
||||
),
|
||||
],
|
||||
const Spacer(),
|
||||
Icon(
|
||||
Icons.chevron_right,
|
||||
size: 16,
|
||||
color: ColorTokens.onSurfaceVariant.withOpacity(0.5),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: SpacingTokens.sm),
|
||||
|
||||
// Titre
|
||||
Text(
|
||||
event.titre,
|
||||
style: AppTypography.headerSmall.copyWith(fontSize: 15),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
|
||||
// Date et lieu
|
||||
const SizedBox(height: SpacingTokens.sm),
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.access_time,
|
||||
size: 12,
|
||||
color: ColorTokens.onSurfaceVariant,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Expanded(
|
||||
child: Text(
|
||||
df.format(event.dateDebut),
|
||||
style: AppTypography.subtitleSmall,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
if (event.lieu != null) ...[
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.location_on_outlined,
|
||||
size: 12,
|
||||
color: ColorTokens.onSurfaceVariant,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Expanded(
|
||||
child: Text(
|
||||
event.lieu!,
|
||||
style: AppTypography.subtitleSmall,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
|
||||
// Footer avec organisateur et participants
|
||||
const SizedBox(height: SpacingTokens.md),
|
||||
Row(
|
||||
children: [
|
||||
MiniAvatar(
|
||||
fallbackText: event.organisateurNom?[0] ?? 'O',
|
||||
size: 20,
|
||||
),
|
||||
const SizedBox(width: SpacingTokens.xs),
|
||||
Expanded(
|
||||
child: Text(
|
||||
event.organisateurNom ?? 'Organisateur',
|
||||
style: TypographyTokens.labelSmall.copyWith(fontSize: 11),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: SpacingTokens.xs,
|
||||
vertical: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorTokens.surfaceVariant,
|
||||
borderRadius: BorderRadius.circular(RadiusTokens.sm),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.people_outline,
|
||||
size: 11,
|
||||
color: ColorTokens.onSurfaceVariant,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
'${event.participantsActuels}/${event.maxParticipants ?? "∞"}',
|
||||
style: AppTypography.badgeText.copyWith(fontSize: 10),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Vue calendrier placeholder
|
||||
Widget _buildCalendarView() {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(SpacingTokens.xl),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorTokens.surfaceVariant.withOpacity(0.3),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.calendar_month,
|
||||
size: 64,
|
||||
color: ColorTokens.onSurfaceVariant.withOpacity(0.5),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: SpacingTokens.lg),
|
||||
Text(
|
||||
'Vue Calendrier',
|
||||
style: AppTypography.headerSmall.copyWith(fontSize: 16),
|
||||
),
|
||||
const SizedBox(height: SpacingTokens.xs),
|
||||
Text(
|
||||
'Bientôt disponible',
|
||||
style: TypographyTokens.bodySmall.copyWith(
|
||||
color: ColorTokens.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Pagination améliorée
|
||||
Widget _buildEnhancedPagination() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: SpacingTokens.sm),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorTokens.surface,
|
||||
border: Border(
|
||||
top: BorderSide(
|
||||
color: ColorTokens.outlineVariant.withOpacity(0.5),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.chevron_left, size: 20),
|
||||
color: widget.currentPage > 0
|
||||
? ColorTokens.primary
|
||||
: ColorTokens.onSurfaceVariant.withOpacity(0.3),
|
||||
onPressed: widget.currentPage > 0
|
||||
? () => context.read<EvenementsBloc>().add(
|
||||
LoadEvenements(page: widget.currentPage - 1),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: SpacingTokens.md,
|
||||
vertical: SpacingTokens.xs,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorTokens.primaryContainer.withOpacity(0.3),
|
||||
borderRadius: BorderRadius.circular(RadiusTokens.md),
|
||||
),
|
||||
child: Text(
|
||||
'Page ${widget.currentPage + 1} / ${widget.totalPages}',
|
||||
style: TypographyTokens.labelMedium.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: ColorTokens.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.chevron_right, size: 20),
|
||||
color: widget.currentPage < widget.totalPages - 1
|
||||
? ColorTokens.primary
|
||||
: ColorTokens.onSurfaceVariant.withOpacity(0.3),
|
||||
onPressed: widget.currentPage < widget.totalPages - 1
|
||||
? () => context.read<EvenementsBloc>().add(
|
||||
LoadEvenements(page: widget.currentPage + 1),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
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é';
|
||||
}
|
||||
}
|
||||
|
||||
Color _getStatutColor(StatutEvenement s) {
|
||||
switch(s) {
|
||||
case StatutEvenement.planifie: return ColorTokens.info;
|
||||
case StatutEvenement.confirme: return ColorTokens.success;
|
||||
case StatutEvenement.enCours: return ColorTokens.primary;
|
||||
case StatutEvenement.termine: return ColorTokens.secondary;
|
||||
case StatutEvenement.annule: return ColorTokens.error;
|
||||
case StatutEvenement.reporte: return ColorTokens.warning;
|
||||
}
|
||||
}
|
||||
|
||||
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 'Manifestation';
|
||||
case TypeEvenement.celebration: return 'Célébration';
|
||||
case TypeEvenement.autre: return 'Autre';
|
||||
}
|
||||
}
|
||||
|
||||
void _showEventDetails(EvenementModel event) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
backgroundColor: ColorTokens.surface,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(RadiusTokens.lg)),
|
||||
),
|
||||
builder: (context) => Container(
|
||||
padding: const EdgeInsets.all(SpacingTokens.xl),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Header
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
event.titre,
|
||||
style: AppTypography.headerSmall.copyWith(fontSize: 16),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close, size: 20),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: SpacingTokens.md),
|
||||
|
||||
// Badges
|
||||
Wrap(
|
||||
spacing: SpacingTokens.xs,
|
||||
runSpacing: SpacingTokens.xs,
|
||||
children: [
|
||||
InfoBadge(
|
||||
text: _mapStatut(event.statut),
|
||||
backgroundColor: _getStatutColor(event.statut).withOpacity(0.12),
|
||||
textColor: _getStatutColor(event.statut),
|
||||
),
|
||||
InfoBadge.neutral(_mapType(event.type)),
|
||||
],
|
||||
),
|
||||
|
||||
const SizedBox(height: SpacingTokens.lg),
|
||||
|
||||
// Description
|
||||
if (event.description != null && event.description!.isNotEmpty) ...[
|
||||
Text(
|
||||
'Description',
|
||||
style: AppTypography.actionText.copyWith(fontSize: 12),
|
||||
),
|
||||
const SizedBox(height: SpacingTokens.xs),
|
||||
Text(
|
||||
event.description!,
|
||||
style: TypographyTokens.bodySmall,
|
||||
),
|
||||
const SizedBox(height: SpacingTokens.lg),
|
||||
],
|
||||
|
||||
// Actions
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: UFSecondaryButton(
|
||||
label: 'Partager',
|
||||
onPressed: () => AppLogger.info('Share event'),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: SpacingTokens.sm),
|
||||
Expanded(
|
||||
child: UFPrimaryButton(
|
||||
label: 'Détails',
|
||||
onPressed: () => AppLogger.info('View details'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
182
lib/features/events/presentation/pages/events_page_wrapper.dart
Normal file
182
lib/features/events/presentation/pages/events_page_wrapper.dart
Normal file
@@ -0,0 +1,182 @@
|
||||
/// Wrapper BLoC pour la page des événements
|
||||
///
|
||||
/// Ce fichier enveloppe la EventsPage existante avec le EvenementsBloc
|
||||
/// pour connecter l'UI riche existante à l'API backend réelle.
|
||||
library events_page_wrapper;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:get_it/get_it.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';
|
||||
import '../../bloc/evenements_state.dart';
|
||||
import '../widgets/create_event_dialog.dart';
|
||||
import 'events_page_connected.dart';
|
||||
|
||||
final _getIt = GetIt.instance;
|
||||
|
||||
/// Wrapper qui fournit le BLoC à la page des événements
|
||||
class EventsPageWrapper extends StatelessWidget {
|
||||
const EventsPageWrapper({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
AppLogger.info('EventsPageWrapper: Création du BlocProvider');
|
||||
|
||||
return BlocProvider<EvenementsBloc>(
|
||||
create: (context) {
|
||||
AppLogger.info('EventsPageWrapper: Initialisation du EvenementsBloc');
|
||||
final bloc = _getIt<EvenementsBloc>();
|
||||
// Charger les événements au démarrage
|
||||
bloc.add(const LoadEvenements());
|
||||
return bloc;
|
||||
},
|
||||
child: const EventsPageConnected(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Page des événements connectée au BLoC
|
||||
///
|
||||
/// Cette page gère les états du BLoC et affiche l'UI appropriée
|
||||
class EventsPageConnected extends StatelessWidget {
|
||||
const EventsPageConnected({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocListener<EvenementsBloc, EvenementsState>(
|
||||
listener: (context, state) {
|
||||
if (state is EvenementCreated) {
|
||||
context.read<EvenementsBloc>().add(const LoadEvenements(refresh: true));
|
||||
}
|
||||
if (state is EvenementsError) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(state.message),
|
||||
backgroundColor: Colors.red,
|
||||
duration: const Duration(seconds: 4),
|
||||
action: SnackBarAction(
|
||||
label: 'Réessayer',
|
||||
textColor: Colors.white,
|
||||
onPressed: () {
|
||||
context.read<EvenementsBloc>().add(const LoadEvenements());
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: BlocBuilder<EvenementsBloc, EvenementsState>(
|
||||
builder: (context, state) {
|
||||
AppLogger.blocState('EvenementsBloc', state.runtimeType.toString());
|
||||
|
||||
// État initial
|
||||
if (state is EvenementsInitial) {
|
||||
return Container(
|
||||
color: const Color(0xFFF8F9FA),
|
||||
child: const Center(
|
||||
child: AppLoadingWidget(message: 'Initialisation...'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// État de chargement
|
||||
if (state is EvenementsLoading) {
|
||||
return Container(
|
||||
color: const Color(0xFFF8F9FA),
|
||||
child: const Center(
|
||||
child: AppLoadingWidget(message: 'Chargement des événements...'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// État de rafraîchissement
|
||||
if (state is EvenementsRefreshing) {
|
||||
return Container(
|
||||
color: const Color(0xFFF8F9FA),
|
||||
child: const Center(
|
||||
child: AppLoadingWidget(message: 'Actualisation...'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
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');
|
||||
|
||||
return EventsPageWithData(
|
||||
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));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// État d'erreur réseau
|
||||
if (state is EvenementsNetworkError) {
|
||||
AppLogger.error('EventsPageConnected: Erreur réseau', error: state.message);
|
||||
return Container(
|
||||
color: const Color(0xFFF8F9FA),
|
||||
child: NetworkErrorWidget(
|
||||
onRetry: () {
|
||||
AppLogger.userAction('Retry load evenements after network error');
|
||||
context.read<EvenementsBloc>().add(const LoadEvenements());
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// État d'erreur générale
|
||||
if (state is EvenementsError) {
|
||||
AppLogger.error('EventsPageConnected: Erreur', error: state.message);
|
||||
return Container(
|
||||
color: const Color(0xFFF8F9FA),
|
||||
child: AppErrorWidget(
|
||||
message: state.message,
|
||||
onRetry: () {
|
||||
AppLogger.userAction('Retry load evenements after error');
|
||||
context.read<EvenementsBloc>().add(const LoadEvenements());
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// État par défaut
|
||||
AppLogger.warning('EventsPageConnected: État non géré: ${state.runtimeType}');
|
||||
return Container(
|
||||
color: const Color(0xFFF8F9FA),
|
||||
child: const Center(
|
||||
child: AppLoadingWidget(message: 'Chargement...'),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,442 @@
|
||||
/// Dialogue de création d'événement
|
||||
/// Formulaire complet pour créer un nouvel événement
|
||||
library create_event_dialog;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
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
|
||||
class CreateEventDialog extends StatefulWidget {
|
||||
const CreateEventDialog({super.key});
|
||||
|
||||
@override
|
||||
State<CreateEventDialog> createState() => _CreateEventDialogState();
|
||||
}
|
||||
|
||||
class _CreateEventDialogState extends State<CreateEventDialog> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
bool _createSent = false;
|
||||
|
||||
// Contrôleurs de texte
|
||||
final _titreController = TextEditingController();
|
||||
final _descriptionController = TextEditingController();
|
||||
final _lieuController = TextEditingController();
|
||||
final _adresseController = TextEditingController();
|
||||
final _capaciteController = TextEditingController();
|
||||
|
||||
// Valeurs sélectionnées
|
||||
DateTime _dateDebut = DateTime.now().add(const Duration(days: 7));
|
||||
DateTime? _dateFin;
|
||||
TypeEvenement _selectedType = TypeEvenement.autre;
|
||||
bool _inscriptionRequise = true;
|
||||
bool _visiblePublic = true;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_titreController.dispose();
|
||||
_descriptionController.dispose();
|
||||
_lieuController.dispose();
|
||||
_adresseController.dispose();
|
||||
_capaciteController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
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),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// En-tête
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: const BoxDecoration(
|
||||
color: Color(0xFF3B82F6),
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(4),
|
||||
topRight: Radius.circular(4),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.event, color: Colors.white),
|
||||
const SizedBox(width: 12),
|
||||
const Text(
|
||||
'Créer un événement',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close, color: Colors.white),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// Formulaire
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Informations de base
|
||||
_buildSectionTitle('Informations de base'),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
TextFormField(
|
||||
controller: _titreController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Titre *',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.title),
|
||||
),
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Le titre est obligatoire';
|
||||
}
|
||||
if (value.length < 3) {
|
||||
return 'Le titre doit contenir au moins 3 caractères';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
TextFormField(
|
||||
controller: _descriptionController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Description',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.description),
|
||||
),
|
||||
maxLines: 3,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// Type d'événement
|
||||
DropdownButtonFormField<TypeEvenement>(
|
||||
value: _selectedType,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Type d\'événement *',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.category),
|
||||
),
|
||||
items: TypeEvenement.values.map((type) {
|
||||
return DropdownMenuItem(
|
||||
value: type,
|
||||
child: Text(_getTypeLabel(type)),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_selectedType = value!;
|
||||
});
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Dates
|
||||
_buildSectionTitle('Dates et horaires'),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
InkWell(
|
||||
onTap: () => _selectDateDebut(context),
|
||||
child: InputDecorator(
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Date de début *',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.calendar_today),
|
||||
),
|
||||
child: Text(
|
||||
DateFormat('dd/MM/yyyy HH:mm').format(_dateDebut),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
InkWell(
|
||||
onTap: () => _selectDateFin(context),
|
||||
child: InputDecorator(
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Date de fin (optionnel)',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.event_available),
|
||||
),
|
||||
child: Text(
|
||||
_dateFin != null
|
||||
? DateFormat('dd/MM/yyyy HH:mm').format(_dateFin!)
|
||||
: 'Sélectionner une date',
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Lieu
|
||||
_buildSectionTitle('Lieu'),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
TextFormField(
|
||||
controller: _lieuController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Lieu *',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.place),
|
||||
),
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Le lieu est obligatoire';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
TextFormField(
|
||||
controller: _adresseController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Adresse complète',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.location_on),
|
||||
),
|
||||
maxLines: 2,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Paramètres
|
||||
_buildSectionTitle('Paramètres'),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
TextFormField(
|
||||
controller: _capaciteController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Capacité maximale',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.people),
|
||||
hintText: 'Nombre de places disponibles',
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
validator: (value) {
|
||||
if (value != null && value.isNotEmpty) {
|
||||
final capacite = int.tryParse(value);
|
||||
if (capacite == null || capacite <= 0) {
|
||||
return 'Capacité invalide';
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
SwitchListTile(
|
||||
title: const Text('Inscription requise'),
|
||||
subtitle: const Text('Les participants doivent s\'inscrire'),
|
||||
value: _inscriptionRequise,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_inscriptionRequise = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
|
||||
SwitchListTile(
|
||||
title: const Text('Visible publiquement'),
|
||||
subtitle: const Text('L\'événement est visible par tous'),
|
||||
value: _visiblePublic,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_visiblePublic = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Boutons d'action
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[100],
|
||||
border: Border(top: BorderSide(color: Colors.grey[300]!)),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('Annuler'),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
ElevatedButton(
|
||||
onPressed: _submitForm,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF3B82F6),
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
child: const Text('Créer l\'événement'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSectionTitle(String title) {
|
||||
return Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF3B82F6),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _getTypeLabel(TypeEvenement type) {
|
||||
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';
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _selectDateDebut(BuildContext context) async {
|
||||
final DateTime? pickedDate = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: _dateDebut,
|
||||
firstDate: DateTime.now(),
|
||||
lastDate: DateTime.now().add(const Duration(days: 365 * 2)),
|
||||
);
|
||||
|
||||
if (pickedDate != null) {
|
||||
final TimeOfDay? pickedTime = await showTimePicker(
|
||||
context: context,
|
||||
initialTime: TimeOfDay.fromDateTime(_dateDebut),
|
||||
);
|
||||
|
||||
if (pickedTime != null) {
|
||||
setState(() {
|
||||
_dateDebut = DateTime(
|
||||
pickedDate.year,
|
||||
pickedDate.month,
|
||||
pickedDate.day,
|
||||
pickedTime.hour,
|
||||
pickedTime.minute,
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _selectDateFin(BuildContext context) async {
|
||||
final DateTime? pickedDate = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: _dateFin ?? _dateDebut.add(const Duration(hours: 2)),
|
||||
firstDate: _dateDebut,
|
||||
lastDate: DateTime.now().add(const Duration(days: 365 * 2)),
|
||||
);
|
||||
|
||||
if (pickedDate != null) {
|
||||
final TimeOfDay? pickedTime = await showTimePicker(
|
||||
context: context,
|
||||
initialTime: TimeOfDay.fromDateTime(_dateFin ?? _dateDebut.add(const Duration(hours: 2))),
|
||||
);
|
||||
|
||||
if (pickedTime != null) {
|
||||
setState(() {
|
||||
_dateFin = DateTime(
|
||||
pickedDate.year,
|
||||
pickedDate.month,
|
||||
pickedDate.day,
|
||||
pickedTime.hour,
|
||||
pickedTime.minute,
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _submitForm() {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
// Créer le modèle d'événement
|
||||
final evenement = EvenementModel(
|
||||
titre: _titreController.text,
|
||||
description: _descriptionController.text.isNotEmpty ? _descriptionController.text : null,
|
||||
dateDebut: _dateDebut,
|
||||
dateFin: _dateFin ?? _dateDebut.add(const Duration(hours: 2)),
|
||||
lieu: _lieuController.text,
|
||||
adresse: _adresseController.text.isNotEmpty ? _adresseController.text : null,
|
||||
type: _selectedType,
|
||||
maxParticipants: _capaciteController.text.isNotEmpty ? int.parse(_capaciteController.text) : null,
|
||||
inscriptionRequise: _inscriptionRequise,
|
||||
estPublic: _visiblePublic,
|
||||
statut: StatutEvenement.planifie,
|
||||
);
|
||||
|
||||
setState(() => _createSent = true);
|
||||
context.read<EvenementsBloc>().add(CreateEvenement(evenement));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
525
lib/features/events/presentation/widgets/edit_event_dialog.dart
Normal file
525
lib/features/events/presentation/widgets/edit_event_dialog.dart
Normal file
@@ -0,0 +1,525 @@
|
||||
/// Dialogue de modification d'événement
|
||||
/// Formulaire pré-rempli pour modifier un événement existant
|
||||
library edit_event_dialog;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
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
|
||||
class EditEventDialog extends StatefulWidget {
|
||||
final EvenementModel evenement;
|
||||
|
||||
const EditEventDialog({
|
||||
super.key,
|
||||
required this.evenement,
|
||||
});
|
||||
|
||||
@override
|
||||
State<EditEventDialog> createState() => _EditEventDialogState();
|
||||
}
|
||||
|
||||
class _EditEventDialogState extends State<EditEventDialog> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
bool _updateSent = false;
|
||||
|
||||
// Contrôleurs de texte
|
||||
late final TextEditingController _titreController;
|
||||
late final TextEditingController _descriptionController;
|
||||
late final TextEditingController _lieuController;
|
||||
late final TextEditingController _adresseController;
|
||||
late final TextEditingController _capaciteController;
|
||||
|
||||
// Valeurs sélectionnées
|
||||
late DateTime _dateDebut;
|
||||
late DateTime _dateFin;
|
||||
late TypeEvenement _selectedType;
|
||||
late StatutEvenement _selectedStatut;
|
||||
late bool _inscriptionRequise;
|
||||
late bool _estPublic;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
// Initialiser les contrôleurs avec les valeurs existantes
|
||||
_titreController = TextEditingController(text: widget.evenement.titre);
|
||||
_descriptionController = TextEditingController(text: widget.evenement.description ?? '');
|
||||
_lieuController = TextEditingController(text: widget.evenement.lieu ?? '');
|
||||
_adresseController = TextEditingController(text: widget.evenement.adresse ?? '');
|
||||
_capaciteController = TextEditingController(
|
||||
text: widget.evenement.maxParticipants?.toString() ?? '',
|
||||
);
|
||||
|
||||
// Initialiser les valeurs
|
||||
_dateDebut = widget.evenement.dateDebut;
|
||||
_dateFin = widget.evenement.dateFin;
|
||||
_selectedType = widget.evenement.type;
|
||||
_selectedStatut = widget.evenement.statut;
|
||||
_inscriptionRequise = widget.evenement.inscriptionRequise;
|
||||
_estPublic = widget.evenement.estPublic;
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_titreController.dispose();
|
||||
_descriptionController.dispose();
|
||||
_lieuController.dispose();
|
||||
_adresseController.dispose();
|
||||
_capaciteController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
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),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// En-tête
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: const BoxDecoration(
|
||||
color: Color(0xFF3B82F6),
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(4),
|
||||
topRight: Radius.circular(4),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.edit, color: Colors.white),
|
||||
const SizedBox(width: 12),
|
||||
const Text(
|
||||
'Modifier l\'événement',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close, color: Colors.white),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// Formulaire
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Informations de base
|
||||
_buildSectionTitle('Informations de base'),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
TextFormField(
|
||||
controller: _titreController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Titre *',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.title),
|
||||
),
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Le titre est obligatoire';
|
||||
}
|
||||
if (value.length < 3) {
|
||||
return 'Le titre doit contenir au moins 3 caractères';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
TextFormField(
|
||||
controller: _descriptionController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Description',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.description),
|
||||
),
|
||||
maxLines: 3,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// Type et statut
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: DropdownButtonFormField<TypeEvenement>(
|
||||
value: _selectedType,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Type *',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.category),
|
||||
),
|
||||
items: TypeEvenement.values.map((type) {
|
||||
return DropdownMenuItem(
|
||||
value: type,
|
||||
child: Text(_getTypeLabel(type)),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_selectedType = value!;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: DropdownButtonFormField<StatutEvenement>(
|
||||
value: _selectedStatut,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Statut *',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.flag),
|
||||
),
|
||||
items: StatutEvenement.values.map((statut) {
|
||||
return DropdownMenuItem(
|
||||
value: statut,
|
||||
child: Text(_getStatutLabel(statut)),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_selectedStatut = value!;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Dates
|
||||
_buildSectionTitle('Dates et horaires'),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
InkWell(
|
||||
onTap: () => _selectDateDebut(context),
|
||||
child: InputDecorator(
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Date de début *',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.calendar_today),
|
||||
),
|
||||
child: Text(
|
||||
DateFormat('dd/MM/yyyy HH:mm').format(_dateDebut),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
InkWell(
|
||||
onTap: () => _selectDateFin(context),
|
||||
child: InputDecorator(
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Date de fin *',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.event_available),
|
||||
),
|
||||
child: Text(
|
||||
DateFormat('dd/MM/yyyy HH:mm').format(_dateFin),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Lieu
|
||||
_buildSectionTitle('Lieu'),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
TextFormField(
|
||||
controller: _lieuController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Lieu *',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.place),
|
||||
),
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Le lieu est obligatoire';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
TextFormField(
|
||||
controller: _adresseController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Adresse complète',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.location_on),
|
||||
),
|
||||
maxLines: 2,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Capacité
|
||||
_buildSectionTitle('Paramètres'),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
TextFormField(
|
||||
controller: _capaciteController,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Capacité maximale',
|
||||
border: const OutlineInputBorder(),
|
||||
prefixIcon: const Icon(Icons.people),
|
||||
suffixText: widget.evenement.participantsActuels > 0
|
||||
? '${widget.evenement.participantsActuels} inscrits'
|
||||
: null,
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
validator: (value) {
|
||||
if (value != null && value.isNotEmpty) {
|
||||
final capacite = int.tryParse(value);
|
||||
if (capacite == null || capacite <= 0) {
|
||||
return 'La capacité doit être un nombre positif';
|
||||
}
|
||||
if (capacite < widget.evenement.participantsActuels) {
|
||||
return 'La capacité ne peut pas être inférieure au nombre d\'inscrits (${widget.evenement.participantsActuels})';
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
SwitchListTile(
|
||||
title: const Text('Inscription requise'),
|
||||
subtitle: const Text('Les participants doivent s\'inscrire'),
|
||||
value: _inscriptionRequise,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_inscriptionRequise = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
|
||||
SwitchListTile(
|
||||
title: const Text('Événement public'),
|
||||
subtitle: const Text('Visible par tous les membres'),
|
||||
value: _estPublic,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_estPublic = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Boutons d'action
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[100],
|
||||
border: Border(top: BorderSide(color: Colors.grey[300]!)),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('Annuler'),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
ElevatedButton(
|
||||
onPressed: _submitForm,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF3B82F6),
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
child: const Text('Enregistrer'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSectionTitle(String title) {
|
||||
return Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF3B82F6),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String _getTypeLabel(TypeEvenement type) {
|
||||
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';
|
||||
}
|
||||
}
|
||||
|
||||
String _getStatutLabel(StatutEvenement statut) {
|
||||
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é';
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _selectDateDebut(BuildContext context) async {
|
||||
final DateTime? pickedDate = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: _dateDebut,
|
||||
firstDate: DateTime.now().subtract(const Duration(days: 365)),
|
||||
lastDate: DateTime.now().add(const Duration(days: 365 * 2)),
|
||||
);
|
||||
|
||||
if (pickedDate != null) {
|
||||
final TimeOfDay? pickedTime = await showTimePicker(
|
||||
context: context,
|
||||
initialTime: TimeOfDay.fromDateTime(_dateDebut),
|
||||
);
|
||||
|
||||
if (pickedTime != null) {
|
||||
setState(() {
|
||||
_dateDebut = DateTime(
|
||||
pickedDate.year,
|
||||
pickedDate.month,
|
||||
pickedDate.day,
|
||||
pickedTime.hour,
|
||||
pickedTime.minute,
|
||||
);
|
||||
|
||||
// Ajuster la date de fin si elle est avant la date de début
|
||||
if (_dateFin.isBefore(_dateDebut)) {
|
||||
_dateFin = _dateDebut.add(const Duration(hours: 2));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _selectDateFin(BuildContext context) async {
|
||||
final DateTime? pickedDate = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: _dateFin,
|
||||
firstDate: _dateDebut,
|
||||
lastDate: DateTime.now().add(const Duration(days: 365 * 2)),
|
||||
);
|
||||
|
||||
if (pickedDate != null) {
|
||||
final TimeOfDay? pickedTime = await showTimePicker(
|
||||
context: context,
|
||||
initialTime: TimeOfDay.fromDateTime(_dateFin),
|
||||
);
|
||||
|
||||
if (pickedTime != null) {
|
||||
setState(() {
|
||||
_dateFin = DateTime(
|
||||
pickedDate.year,
|
||||
pickedDate.month,
|
||||
pickedDate.day,
|
||||
pickedTime.hour,
|
||||
pickedTime.minute,
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _submitForm() {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
// Créer le modèle d'événement mis à jour
|
||||
final evenementUpdated = widget.evenement.copyWith(
|
||||
titre: _titreController.text,
|
||||
description: _descriptionController.text.isNotEmpty ? _descriptionController.text : null,
|
||||
dateDebut: _dateDebut,
|
||||
dateFin: _dateFin,
|
||||
lieu: _lieuController.text,
|
||||
adresse: _adresseController.text.isNotEmpty ? _adresseController.text : null,
|
||||
type: _selectedType,
|
||||
statut: _selectedStatut,
|
||||
maxParticipants: _capaciteController.text.isNotEmpty ? int.parse(_capaciteController.text) : null,
|
||||
inscriptionRequise: _inscriptionRequise,
|
||||
estPublic: _estPublic,
|
||||
);
|
||||
|
||||
setState(() => _updateSent = true);
|
||||
context.read<EvenementsBloc>().add(UpdateEvenement(widget.evenement.id!.toString(), evenementUpdated));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,337 @@
|
||||
/// Dialogue d'inscription à un événement
|
||||
library inscription_event_dialog;
|
||||
|
||||
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 {
|
||||
final EvenementModel evenement;
|
||||
final bool isInscrit;
|
||||
|
||||
const InscriptionEventDialog({
|
||||
super.key,
|
||||
required this.evenement,
|
||||
this.isInscrit = false,
|
||||
});
|
||||
|
||||
@override
|
||||
State<InscriptionEventDialog> createState() => _InscriptionEventDialogState();
|
||||
}
|
||||
|
||||
class _InscriptionEventDialogState extends State<InscriptionEventDialog> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final _commentaireController = TextEditingController();
|
||||
bool _actionSent = false;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_commentaireController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
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),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
_buildHeader(),
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildEventInfo(),
|
||||
const SizedBox(height: 16),
|
||||
if (!widget.isInscrit) ...[
|
||||
_buildPlacesInfo(),
|
||||
const SizedBox(height: 16),
|
||||
_buildCommentaireField(),
|
||||
] else ...[
|
||||
_buildDesinscriptionWarning(),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
_buildActionButtons(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildHeader() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: widget.isInscrit ? Colors.red : const Color(0xFF3B82F6),
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(4),
|
||||
topRight: Radius.circular(4),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
widget.isInscrit ? Icons.cancel : Icons.event_available,
|
||||
color: Colors.white,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
widget.isInscrit ? 'Se désinscrire' : 'S\'inscrire à l\'événement',
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close, color: Colors.white),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildEventInfo() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.blue[50],
|
||||
border: Border.all(color: Colors.blue[200]!),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.event, color: Color(0xFF3B82F6)),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
widget.evenement.titre,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.calendar_today, size: 16, color: Colors.grey),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
_formatDate(widget.evenement.dateDebut),
|
||||
style: const TextStyle(fontSize: 14),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (widget.evenement.lieu != null) ...[
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.location_on, size: 16, color: Colors.grey),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
widget.evenement.lieu!,
|
||||
style: const TextStyle(fontSize: 14),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPlacesInfo() {
|
||||
final placesRestantes = (widget.evenement.maxParticipants ?? 0) -
|
||||
widget.evenement.participantsActuels;
|
||||
final isComplet = placesRestantes <= 0 && widget.evenement.maxParticipants != null;
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: isComplet ? Colors.red[50] : Colors.green[50],
|
||||
border: Border.all(
|
||||
color: isComplet ? Colors.red[200]! : Colors.green[200]!,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
isComplet ? Icons.warning : Icons.check_circle,
|
||||
color: isComplet ? Colors.red : Colors.green,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
isComplet ? 'Événement complet' : 'Places disponibles',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: isComplet ? Colors.red[900] : Colors.green[900],
|
||||
),
|
||||
),
|
||||
if (widget.evenement.maxParticipants != null)
|
||||
Text(
|
||||
'$placesRestantes places restantes sur ${widget.evenement.maxParticipants}',
|
||||
style: const TextStyle(fontSize: 12),
|
||||
)
|
||||
else
|
||||
const Text(
|
||||
'Nombre de places illimité',
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCommentaireField() {
|
||||
return TextFormField(
|
||||
controller: _commentaireController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Commentaire (optionnel)',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.comment),
|
||||
hintText: 'Ajoutez un commentaire...',
|
||||
),
|
||||
maxLines: 3,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDesinscriptionWarning() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.orange[50],
|
||||
border: Border.all(color: Colors.orange[200]!),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: const Row(
|
||||
children: [
|
||||
Icon(Icons.warning, color: Colors.orange),
|
||||
SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Êtes-vous sûr de vouloir vous désinscrire de cet événement ?',
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildActionButtons() {
|
||||
final placesRestantes = (widget.evenement.maxParticipants ?? 0) -
|
||||
widget.evenement.participantsActuels;
|
||||
final isComplet = placesRestantes <= 0 && widget.evenement.maxParticipants != null;
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[100],
|
||||
border: Border(top: BorderSide(color: Colors.grey[300]!)),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('Annuler'),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
ElevatedButton(
|
||||
onPressed: (widget.isInscrit || !isComplet) ? _submitForm : null,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: widget.isInscrit ? Colors.red : const Color(0xFF3B82F6),
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
child: Text(widget.isInscrit ? 'Se désinscrire' : 'S\'inscrire'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _formatDate(DateTime date) {
|
||||
final months = [
|
||||
'janvier', 'février', 'mars', 'avril', 'mai', 'juin',
|
||||
'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'
|
||||
];
|
||||
return '${date.day} ${months[date.month - 1]} ${date.year} à ${date.hour}:${date.minute.toString().padLeft(2, '0')}';
|
||||
}
|
||||
|
||||
void _submitForm() {
|
||||
setState(() => _actionSent = true);
|
||||
if (widget.isInscrit) {
|
||||
context.read<EvenementsBloc>().add(DesinscrireEvenement(widget.evenement.id!.toString()));
|
||||
} else {
|
||||
context.read<EvenementsBloc>().add(
|
||||
InscrireEvenement(widget.evenement.id!.toString()),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user