Améliorations UI

This commit is contained in:
2025-05-22 12:27:25 +02:00
parent 64e5eddfd5
commit 2c61b9ce8d

View File

@ -94,9 +94,11 @@ class _CalendarPageState extends State<CalendarPage> {
});
},
)
: const Center(
child:
Text('Sélectionnez un événement pour voir les détails'),
: Center(
child: _selectedDay != null
? Text('Aucun événement ne démarre à cette date')
: const Text(
'Sélectionnez un événement pour voir les détails'),
),
),
],
@ -126,6 +128,12 @@ class _CalendarPageState extends State<CalendarPage> {
},
),
),
if (_selectedEvent == null && _selectedDay != null)
Expanded(
child: Center(
child: Text('Aucun événement ne démarre à cette date'),
),
),
],
);
}
@ -156,9 +164,21 @@ class _CalendarPageState extends State<CalendarPage> {
calendarFormat: _calendarFormat,
events: eventProvider.events,
onDaySelected: (selectedDay, focusedDay) {
final eventsForDay = eventProvider.events
.where((event) =>
event.startDateTime.year == selectedDay.year &&
event.startDateTime.month == selectedDay.month &&
event.startDateTime.day == selectedDay.day)
.toList()
..sort((a, b) => a.startDateTime.compareTo(b.startDateTime));
setState(() {
_selectedDay = selectedDay;
_focusedDay = focusedDay;
if (eventsForDay.isNotEmpty) {
_selectedEvent = eventsForDay.first;
} else {
_selectedEvent = null;
}
});
},
onFormatChanged: (format) {