Ajout de la date de l'événement et des boutons suivant et précédents
This commit is contained in:
@ -71,6 +71,7 @@ class _CalendarPageState extends State<CalendarPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildDesktopLayout() {
|
Widget _buildDesktopLayout() {
|
||||||
|
final eventProvider = Provider.of<EventProvider>(context);
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
// Calendrier (65% de la largeur)
|
// Calendrier (65% de la largeur)
|
||||||
@ -82,7 +83,17 @@ class _CalendarPageState extends State<CalendarPage> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
flex: 35,
|
flex: 35,
|
||||||
child: _selectedEvent != null
|
child: _selectedEvent != null
|
||||||
? EventDetails(event: _selectedEvent!)
|
? EventDetails(
|
||||||
|
event: _selectedEvent!,
|
||||||
|
selectedDate: _selectedDay,
|
||||||
|
events: eventProvider.events,
|
||||||
|
onSelectEvent: (event, date) {
|
||||||
|
setState(() {
|
||||||
|
_selectedEvent = event;
|
||||||
|
_selectedDay = date;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
)
|
||||||
: const Center(
|
: const Center(
|
||||||
child:
|
child:
|
||||||
Text('Sélectionnez un événement pour voir les détails'),
|
Text('Sélectionnez un événement pour voir les détails'),
|
||||||
@ -93,6 +104,7 @@ class _CalendarPageState extends State<CalendarPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildMobileLayout() {
|
Widget _buildMobileLayout() {
|
||||||
|
final eventProvider = Provider.of<EventProvider>(context);
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
// Calendrier
|
// Calendrier
|
||||||
@ -102,7 +114,17 @@ class _CalendarPageState extends State<CalendarPage> {
|
|||||||
// Détails de l'événement
|
// Détails de l'événement
|
||||||
if (_selectedEvent != null)
|
if (_selectedEvent != null)
|
||||||
Expanded(
|
Expanded(
|
||||||
child: EventDetails(event: _selectedEvent!),
|
child: EventDetails(
|
||||||
|
event: _selectedEvent!,
|
||||||
|
selectedDate: _selectedDay,
|
||||||
|
events: eventProvider.events,
|
||||||
|
onSelectEvent: (event, date) {
|
||||||
|
setState(() {
|
||||||
|
_selectedEvent = event;
|
||||||
|
_selectedDay = date;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
@ -124,24 +124,43 @@ class MonthView extends StatelessWidget {
|
|||||||
selectedBuilder: (context, day, focusedDay) {
|
selectedBuilder: (context, day, focusedDay) {
|
||||||
return _buildDayCell(day, true);
|
return _buildDayCell(day, true);
|
||||||
},
|
},
|
||||||
|
todayBuilder: (context, day, focusedDay) {
|
||||||
|
return _buildDayCell(day, false, isToday: true);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildDayCell(DateTime day, bool isSelected) {
|
Widget _buildDayCell(DateTime day, bool isSelected, {bool isToday = false}) {
|
||||||
final dayEvents = CalendarUtils.getEventsForDay(day, events);
|
final dayEvents = CalendarUtils.getEventsForDay(day, events);
|
||||||
final textColor = isSelected ? Colors.white : null;
|
final textColor =
|
||||||
|
isSelected ? Colors.white : (isToday ? AppColors.rouge : null);
|
||||||
final badgeColor = isSelected ? Colors.white : AppColors.rouge;
|
final badgeColor = isSelected ? Colors.white : AppColors.rouge;
|
||||||
final badgeTextColor = isSelected ? AppColors.rouge : Colors.white;
|
final badgeTextColor = isSelected ? AppColors.rouge : Colors.white;
|
||||||
|
|
||||||
|
BoxDecoration decoration;
|
||||||
|
if (isSelected) {
|
||||||
|
decoration = BoxDecoration(
|
||||||
|
color: AppColors.rouge,
|
||||||
|
border: Border.all(color: AppColors.rouge),
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
);
|
||||||
|
} else if (isToday) {
|
||||||
|
decoration = BoxDecoration(
|
||||||
|
color: AppColors.rouge.withAlpha(26),
|
||||||
|
border: Border.all(color: AppColors.rouge),
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
decoration = BoxDecoration(
|
||||||
|
color: null,
|
||||||
|
border: Border.all(color: Colors.grey.shade300),
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
margin: const EdgeInsets.all(4),
|
margin: const EdgeInsets.all(4),
|
||||||
decoration: BoxDecoration(
|
decoration: decoration,
|
||||||
color: isSelected ? AppColors.rouge : null,
|
|
||||||
border: Border.all(
|
|
||||||
color: isSelected ? AppColors.rouge : Colors.grey.shade300,
|
|
||||||
),
|
|
||||||
borderRadius: BorderRadius.circular(4),
|
|
||||||
),
|
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
Positioned(
|
Positioned(
|
||||||
|
@ -5,16 +5,27 @@ import 'package:intl/intl.dart';
|
|||||||
|
|
||||||
class EventDetails extends StatelessWidget {
|
class EventDetails extends StatelessWidget {
|
||||||
final EventModel event;
|
final EventModel event;
|
||||||
|
final DateTime? selectedDate;
|
||||||
|
final List<EventModel> events;
|
||||||
|
final void Function(EventModel, DateTime) onSelectEvent;
|
||||||
|
|
||||||
const EventDetails({
|
const EventDetails({
|
||||||
super.key,
|
super.key,
|
||||||
required this.event,
|
required this.event,
|
||||||
|
required this.selectedDate,
|
||||||
|
required this.events,
|
||||||
|
required this.onSelectEvent,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final dateFormat = DateFormat('dd/MM/yyyy HH:mm');
|
final dateFormat = DateFormat('dd/MM/yyyy HH:mm');
|
||||||
final currencyFormat = NumberFormat.currency(locale: 'fr_FR', symbol: '€');
|
final currencyFormat = NumberFormat.currency(locale: 'fr_FR', symbol: '€');
|
||||||
|
final fullDateFormat = DateFormat('EEEE d MMMM y', 'fr_FR');
|
||||||
|
// Trie les événements par date de début
|
||||||
|
final sortedEvents = List<EventModel>.from(events)
|
||||||
|
..sort((a, b) => a.startDateTime.compareTo(b.startDateTime));
|
||||||
|
final currentIndex = sortedEvents.indexWhere((e) => e.id == event.id);
|
||||||
|
|
||||||
return Card(
|
return Card(
|
||||||
margin: const EdgeInsets.all(16),
|
margin: const EdgeInsets.all(16),
|
||||||
@ -23,6 +34,44 @@ class EventDetails extends StatelessWidget {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
IconButton(
|
||||||
|
onPressed: currentIndex > 0
|
||||||
|
? () {
|
||||||
|
final prevEvent = sortedEvents[currentIndex - 1];
|
||||||
|
onSelectEvent(prevEvent, prevEvent.startDateTime);
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
icon: const Icon(Icons.arrow_back),
|
||||||
|
color: AppColors.rouge,
|
||||||
|
),
|
||||||
|
if (selectedDate != null)
|
||||||
|
Expanded(
|
||||||
|
child: Center(
|
||||||
|
child: Text(
|
||||||
|
fullDateFormat.format(selectedDate!),
|
||||||
|
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||||
|
color: AppColors.rouge,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
onPressed: currentIndex < sortedEvents.length - 1
|
||||||
|
? () {
|
||||||
|
final nextEvent = sortedEvents[currentIndex + 1];
|
||||||
|
onSelectEvent(nextEvent, nextEvent.startDateTime);
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
icon: const Icon(Icons.arrow_forward),
|
||||||
|
color: AppColors.rouge,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
Text(
|
Text(
|
||||||
event.name,
|
event.name,
|
||||||
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
|
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
|
||||||
|
Reference in New Issue
Block a user