Browse Source

实时打点

周睿 2 years ago
parent
commit
d47deb5aaa
2 changed files with 72 additions and 46 deletions
  1. 71 45
      lib/view/home/personal_rank/personal_rank.dart
  2. 1 1
      pubspec.yaml

+ 71 - 45
lib/view/home/personal_rank/personal_rank.dart

@@ -1,5 +1,3 @@
-import 'dart:io';
-
 import 'package:application/logger.dart';
 import 'package:application/service/api.dart';
 import 'package:application/service/map_watch.dart';
@@ -7,9 +5,9 @@ import 'package:common_pub/model/distance.dart';
 import 'package:common_pub/model/pace.dart';
 import 'package:common_pub/utils.dart';
 import 'package:fixnum/fixnum.dart';
-import 'package:get/get.dart';
 import 'package:flutter/material.dart';
-import 'package:intl/intl.dart';
+import 'package:get/get.dart';
+
 import '../../../widget/title_point.dart';
 
 class PersonalRankController extends GetxController {
@@ -71,7 +69,6 @@ class PersonalRankController extends GetxController {
 class PersonalRankPage extends StatelessWidget {
   PersonalRankPage({super.key});
 
-
   @override
   Widget build(BuildContext context) {
     return GetBuilder(
@@ -103,11 +100,15 @@ class PersonalRankPage extends StatelessWidget {
 
   Future<void> _pickDate(BuildContext context, PersonalRankController c) async {
     final now = c.filterStartAt.value;
-    final time = await showTimePicker(context: context, initialTime: TimeOfDay.fromDateTime(now));
+    final time = await showTimePicker(
+        context: context, initialTime: TimeOfDay.fromDateTime(now));
 
-    if (time!= null){
-      c.filterStartAt.value = DateTime(now.year, now.month, now.day, time.hour, time.minute);
+    if (time != null) {
+      c.filterStartAt.value =
+          DateTime(now.year, now.month, now.day, time.hour, time.minute);
       info('time: ${c.filterStartAt.value}');
+      c.selectActive.value = null;
+      c.activeList.clear();
     }
     // final date = await showDatePicker(
     //     context: context,
@@ -136,12 +137,12 @@ class PersonalRankPage extends StatelessWidget {
                     ?.copyWith(color: Colors.white)),
             const Spacer(),
             Container(
-              decoration: BoxDecoration(
-                  border: Border.all(color: const Color(0xffe3e3e3))),
-              child: TextButton(
-                  onPressed: () => _pickDate(context, c),
-                  child: Text(TimeOfDay.fromDateTime(c.filterStartAt.value).format(context)))
-            )
+                decoration: BoxDecoration(
+                    border: Border.all(color: const Color(0xffe3e3e3))),
+                child: TextButton(
+                    onPressed: () => _pickDate(context, c),
+                    child: Text(TimeOfDay.fromDateTime(c.filterStartAt.value)
+                        .format(context))))
           ],
         ),
         const SizedBox(height: 20),
@@ -247,24 +248,35 @@ class PersonalRankPage extends StatelessWidget {
                 width: _userNameWidth,
                 child: Text('用户名', textAlign: TextAlign.center)),
             verticalDivider(show: false),
-            const Expanded(child: Text('路线ID', textAlign: TextAlign.center)),
-            verticalDivider(show: false),
             const SizedBox(
-                width: _userResultWidth,
-                child: Text('成绩', textAlign: TextAlign.center)),
+              width: _userPhoneWidth,
+              child: Text(
+                '手机号',
+                textAlign: TextAlign.center,
+              ),
+            ),
+            verticalDivider(show: false),
+            const Expanded(
+                flex: 5, child: Text('路线ID', textAlign: TextAlign.center)),
             verticalDivider(show: false),
             const SizedBox(
                 width: _userTimeWidth,
                 child: Text('总时间', textAlign: TextAlign.center)),
             verticalDivider(show: false),
-            const Expanded(child: Text('总里程', textAlign: TextAlign.center)),
+            const Expanded(
+                flex: 3, child: Text('总里程', textAlign: TextAlign.center)),
             verticalDivider(show: false),
-            const Expanded(child: Text('配速', textAlign: TextAlign.center)),
+            const Expanded(
+                flex: 4, child: Text('配速', textAlign: TextAlign.center)),
             verticalDivider(show: false),
             const SizedBox(
-                width: _userFlagWidth,
-                child: Text('分组', textAlign: TextAlign.center)),
-            verticalDivider(show: false),
+                width: _userResultWidth,
+                child: Text('状态', textAlign: TextAlign.center)),
+            // verticalDivider(show: false),
+            // const SizedBox(
+            //     width: _userFlagWidth,
+            //     child: Text('分组', textAlign: TextAlign.center)),
+            // verticalDivider(show: false),
           ],
         ));
   }
@@ -311,23 +323,21 @@ class PersonalRankPage extends StatelessWidget {
                           width: _userNameWidth,
                           child: Text(
                             data.name,
+                            maxLines: 1,
                             textAlign: TextAlign.center,
                           )),
                       verticalDivider(),
-                      Expanded(
+                      SizedBox(
+                          width: _userPhoneWidth,
                           child: Text(
-                        data.routeName,
-                        textAlign: TextAlign.center,
-                      )),
+                            data.phone,
+                            textAlign: TextAlign.center,
+                          )),
                       verticalDivider(),
-                      SizedBox(
-                          width: _userResultWidth,
+                      Expanded(
+                          flex: 5,
                           child: Text(
-                            switch(data.state){
-                              GameState.processing=>'进行中',
-                              GameState.finish=>'完赛',
-                            GameState.unFinish=>'退赛'
-                            },
+                            data.routeName,
                             textAlign: TextAlign.center,
                           )),
                       verticalDivider(),
@@ -337,14 +347,17 @@ class PersonalRankPage extends StatelessWidget {
                             data.duration.toMinSecondString(),
                             textAlign: TextAlign.center,
                           )),
+
                       verticalDivider(),
                       Expanded(
+                          flex: 3,
                           child: Text(
-                        data.distance.toString(),
-                        textAlign: TextAlign.center,
-                      )),
+                            data.distance.toString(),
+                            textAlign: TextAlign.center,
+                          )),
                       verticalDivider(),
                       Expanded(
+                          flex: 4,
                           child: Container(
                               margin: const EdgeInsets.only(left: 8, right: 8),
                               alignment: Alignment.center,
@@ -356,11 +369,22 @@ class PersonalRankPage extends StatelessWidget {
                                 data.pace.toString(),
                                 textAlign: TextAlign.center,
                               ))),
+                      // verticalDivider(),
                       verticalDivider(),
-                      Container(
-                          alignment: Alignment.center,
-                          width: _userFlagWidth,
-                          child: Icon(Icons.flag, color: data.flag.color)),
+                      SizedBox(
+                          width: _userResultWidth,
+                          child: Text(
+                            switch (data.state) {
+                              GameState.processing => '进行中',
+                              GameState.finish => '完赛',
+                              GameState.unFinish => '退赛'
+                            },
+                            textAlign: TextAlign.center,
+                          )),
+                      // Container(
+                      //     alignment: Alignment.center,
+                      //     width: _userFlagWidth,
+                      //     child: Icon(Icons.flag, color: data.flag.color)),
                     ],
                   ),
                 ))
@@ -378,11 +402,12 @@ class PersonalRankPage extends StatelessWidget {
   }
 
   static const _userIndexWidth = 56.0;
-  static const _userNameWidth = 84.0;
+  static const _userNameWidth = 70.0;
+  static const _userPhoneWidth = 94.0;
   static const _userResultWidth = 62.0;
-  static const _userTimeWidth = 92.0;
+  static const _userTimeWidth = 62.0;
   static const _cardHeight = 45.0;
-  static const _userFlagWidth = 52.0;
+  // static const _userFlagWidth = 52.0;
 }
 
 enum GameState {
@@ -399,7 +424,7 @@ class RankUserInfo {
   var duration = 0.seconds;
   var distance = 0.meter;
   var startAt = DateTime(2000);
-
+  var phone = '';
   Pace get pace => Pace(distance, duration);
   var flag = Flag.red;
 }
@@ -421,6 +446,7 @@ extension UserRankInfoExt on ToOrienteerRankInfo {
         2 => GameState.processing,
         _ => GameState.unFinish
       }
+      ..phone = phone
       ..startAt = startAt.toModel()
       ..duration = duration.toModel()
       ..distance = distance.meter;

+ 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.9+1
+version: 1.0.11+1
 
 environment:
   sdk: '>=3.0.6 <4.0.0'