Pārlūkot izejas kodu

update(lab): 修正日期选择器

gavin.chen 4 mēneši atpakaļ
vecāks
revīzija
3067b1272c
1 mainītis faili ar 16 papildinājumiem un 32 dzēšanām
  1. 16 32
      lib/lab/pages/lab_record_info/widgets/dialog_date.dart

+ 16 - 32
lib/lab/pages/lab_record_info/widgets/dialog_date.dart

@@ -1,5 +1,6 @@
 import 'package:flutter/cupertino.dart';
 import 'package:flutter/material.dart';
+import 'package:flyinsono/lab/color/lab_colors.dart';
 import 'package:flyinsono/lab/components/lab_dialog.dart';
 import 'package:get/get.dart';
 
@@ -58,6 +59,7 @@ class VDialogDate extends StatelessWidget {
 
   Widget _buildContent(BuildContext context, _VDialogDateValueCache cache) {
     // 不保留时间部分
+    DateTime now = DateTime.now();
     return Container(
       margin: const EdgeInsets.all(10),
       height: 216,
@@ -65,38 +67,20 @@ class VDialogDate extends StatelessWidget {
       child: Stack(
         children: [
           Positioned.fill(
-            child: VCustomCupertinoDatePicker(
-              initialDateTime: cache.value,
-              minimumYear: 1900,
-              maximumYear: 2100,
-              minimumDate: minimumDate,
-              maximumDate: maxValue,
-              backgroundColor: CupertinoColors.white,
-              onDateTimeChanged: (date) {
-                cache.value = date;
-              },
-            ),
-          ),
-          Positioned(
-            top: 72,
-            left: 0,
-            right: 0,
-            child: Divider(
-              thickness: 1,
-              color: Colors.black.withOpacity(0.2),
-              indent: 12,
-              endIndent: 12,
-            ),
-          ),
-          Positioned(
-            top: 72 + 58,
-            left: 0,
-            right: 0,
-            child: Divider(
-              thickness: 1,
-              color: Colors.black.withOpacity(0.2),
-              indent: 12,
-              endIndent: 12,
+            child: Theme(
+              data: ThemeData(
+                colorScheme: ColorScheme.light(
+                  primary: LabColors.dialogHeaderColor,
+                  onPrimary: LabColors.text100,
+                  onSurface: LabColors.text100,
+                ),
+              ),
+              child: CalendarDatePicker(
+                initialDate: cache.value,
+                firstDate: DateTime(now.year - 200, 1, 1), // 200 年前
+                lastDate: DateTime(now.year, 12, 31), // 今年
+                onDateChanged: (value) => cache.value = value,
+              ),
             ),
           ),
         ],