Просмотр исходного кода

fix(mobile): allow editing asset dates in the future (#5522)

Co-authored-by: shalong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
shenlong 1 год назад
Родитель
Сommit
e1739ac4fc
1 измененных файлов с 5 добавлено и 2 удалено
  1. 5 2
      mobile/lib/shared/ui/date_time_picker.dart

+ 5 - 2
mobile/lib/shared/ui/date_time_picker.dart

@@ -86,11 +86,14 @@ class _DateTimePicker extends HookWidget {
     final timeZones = useMemoized(() => getAllTimeZones(), const []);
 
     void pickDate() async {
+      final now = DateTime.now();
+      // Handles cases where the date from the asset is far off in the future
+      final initialDate = date.value.isAfter(now) ? now : date.value;
       final newDate = await showDatePicker(
         context: context,
-        initialDate: date.value,
+        initialDate: initialDate,
         firstDate: DateTime(1800),
-        lastDate: DateTime.now(),
+        lastDate: now,
       );
       if (newDate == null) {
         return;