Add navigation buttons for selecting previous and next days; enhance date selection UI

This commit is contained in:
Sven laptop
2026-05-08 17:13:50 +02:00
parent 1ce9c70b0f
commit 43def88e8c
@@ -62,6 +62,13 @@ class _DailyScheduleScreenState extends State<DailyScheduleScreen> {
} }
} }
void _moveDay(int deltaDays) {
setState(() {
_selectedDate = _selectedDate.add(Duration(days: deltaDays));
_scheduleFuture = _scheduleService.getDailySchedule(_selectedDate);
});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme; final colorScheme = Theme.of(context).colorScheme;
@@ -140,18 +147,51 @@ class _DailyScheduleScreenState extends State<DailyScheduleScreen> {
const SizedBox(height: 14), const SizedBox(height: 14),
Align( Align(
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: SizedBox( child: Wrap(
height: 48, spacing: 8,
child: OutlinedButton.icon( runSpacing: 8,
onPressed: _selectDate, alignment: WrapAlignment.end,
icon: const Icon(Icons.calendar_today, size: 18), children: [
label: const Text('Wijzig'), SizedBox(
style: OutlinedButton.styleFrom( height: 48,
foregroundColor: Colors.white, child: OutlinedButton.icon(
side: BorderSide(color: Colors.white.withOpacity(0.28)), onPressed: () => _moveDay(-1),
padding: const EdgeInsets.symmetric(horizontal: 16), icon: const Icon(Icons.chevron_left, size: 18),
label: const Text('Vorige dag'),
style: OutlinedButton.styleFrom(
foregroundColor: Colors.white,
side: BorderSide(color: Colors.white.withOpacity(0.28)),
padding: const EdgeInsets.symmetric(horizontal: 16),
),
),
), ),
), SizedBox(
height: 48,
child: OutlinedButton.icon(
onPressed: _selectDate,
icon: const Icon(Icons.calendar_today, size: 18),
label: const Text('Kies datum'),
style: OutlinedButton.styleFrom(
foregroundColor: Colors.white,
side: BorderSide(color: Colors.white.withOpacity(0.28)),
padding: const EdgeInsets.symmetric(horizontal: 16),
),
),
),
SizedBox(
height: 48,
child: OutlinedButton.icon(
onPressed: () => _moveDay(1),
icon: const Icon(Icons.chevron_right, size: 18),
label: const Text('Volgende dag'),
style: OutlinedButton.styleFrom(
foregroundColor: Colors.white,
side: BorderSide(color: Colors.white.withOpacity(0.28)),
padding: const EdgeInsets.symmetric(horizontal: 16),
),
),
),
],
), ),
), ),
], ],
@@ -244,7 +284,8 @@ class _DailyScheduleScreenState extends State<DailyScheduleScreen> {
); );
} }
final routes = snapshot.data!.routes; final routes = [...snapshot.data!.routes]
..sort((a, b) => a.startTime.compareTo(b.startTime));
final scheduledRoutes = routes.where((r) => r.status == 'scheduled').toList(); final scheduledRoutes = routes.where((r) => r.status == 'scheduled').toList();
final inProgressRoutes = routes.where((r) => r.status == 'in_progress').toList(); final inProgressRoutes = routes.where((r) => r.status == 'in_progress').toList();
final completedRoutes = routes.where((r) => r.status == 'completed').toList(); final completedRoutes = routes.where((r) => r.status == 'completed').toList();