Browse Source

实时打点

周睿 2 năm trước cách đây
mục cha
commit
fc24571c23
2 tập tin đã thay đổi với 17 bổ sung13 xóa
  1. 16 12
      lib/view/home/personal_rank/personal_rank.dart
  2. 1 1
      pubspec.yaml

+ 16 - 12
lib/view/home/personal_rank/personal_rank.dart

@@ -71,7 +71,6 @@ class PersonalRankController extends GetxController {
 class PersonalRankPage extends StatelessWidget {
   PersonalRankPage({super.key});
 
-  final dateFmt = DateFormat('yyyy-MM-dd');
 
   @override
   Widget build(BuildContext context) {
@@ -103,18 +102,23 @@ class PersonalRankPage extends StatelessWidget {
   }
 
   Future<void> _pickDate(BuildContext context, PersonalRankController c) async {
-    final now = DateTime.now();
-
-    final date = await showDatePicker(
-        context: context,
-        initialDate: c.filterStartAt.value,
-        firstDate: DateTime(now.year - 1),
-        lastDate: DateTime(now.year, now.month, now.day + 1),
-    );
+    final now = c.filterStartAt.value;
+    final time = await showTimePicker(context: context, initialTime: TimeOfDay.fromDateTime(now));
 
-    if (date != null) {
-      c.filterStartAt.value = DateTime(date.year, date.month, date.day);
+    if (time!= null){
+      c.filterStartAt.value = DateTime(now.year, now.month, now.day, time.hour, time.minute);
+      info('time: ${c.filterStartAt.value}');
     }
+    // final date = await showDatePicker(
+    //     context: context,
+    //     initialDate: c.filterStartAt.value,
+    //     firstDate: DateTime(now.year - 1),
+    //     lastDate: DateTime(now.year, now.month, now.day + 1),
+    // );
+    //
+    // if (date != null) {
+    //   c.filterStartAt.value = DateTime(date.year, date.month, date.day);
+    // }
   }
 
   Widget titlePoint() {
@@ -136,7 +140,7 @@ class PersonalRankPage extends StatelessWidget {
                   border: Border.all(color: const Color(0xffe3e3e3))),
               child: TextButton(
                   onPressed: () => _pickDate(context, c),
-                  child: Text(dateFmt.format(c.filterStartAt.value))),
+                  child: Text(TimeOfDay.fromDateTime(c.filterStartAt.value).format(context)))
             )
           ],
         ),

+ 1 - 1
pubspec.yaml

@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
 # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
 # In Windows, build-name is used as the major, minor, and patch parts
 # of the product and file versions while build-number is used as the build suffix.
-version: 1.0.8+1
+version: 1.0.9+1
 
 environment:
   sdk: '>=3.0.6 <4.0.0'