chore: restrict selection

This commit is contained in:
Yaros
2026-05-13 18:36:46 +02:00
parent 6bd001d9ff
commit 86ff373752
@@ -28,12 +28,13 @@ class MapTimeRange extends StatelessWidget {
: null, : null,
onTap: () async { onTap: () async {
final initial = timeRange.from.unwrapOrNull ?? DateTime.now(); final initial = timeRange.from.unwrapOrNull ?? DateTime.now();
final currentTo = timeRange.to.unwrapOrNull;
final picked = await showDatePicker( final picked = await showDatePicker(
context: context, context: context,
initialDate: initial, initialDate: currentTo != null && initial.isAfter(currentTo) ? currentTo : initial,
firstDate: DateTime(1970), firstDate: DateTime(1970),
lastDate: DateTime.now(), lastDate: currentTo ?? DateTime.now(),
); );
if (picked != null) { if (picked != null) {
@@ -41,7 +42,6 @@ class MapTimeRange extends StatelessWidget {
} }
}, },
), ),
ListTile( ListTile(
title: Text(context.t.date_before), title: Text(context.t.date_before),
subtitle: Text( subtitle: Text(
@@ -55,11 +55,12 @@ class MapTimeRange extends StatelessWidget {
: null, : null,
onTap: () async { onTap: () async {
final initial = timeRange.to.unwrapOrNull ?? DateTime.now(); final initial = timeRange.to.unwrapOrNull ?? DateTime.now();
final currentFrom = timeRange.from.unwrapOrNull;
final picked = await showDatePicker( final picked = await showDatePicker(
context: context, context: context,
initialDate: initial, initialDate: currentFrom != null && initial.isBefore(currentFrom) ? currentFrom : initial,
firstDate: DateTime(1970), firstDate: currentFrom ?? DateTime(1970),
lastDate: DateTime.now(), lastDate: DateTime.now(),
); );