wzx 2 年之前
父節點
當前提交
a19cb4b8dd

+ 2 - 2
lib/view/maplist/map_list_view.dart

@@ -22,10 +22,10 @@ class MapListView extends GetView<MapListController> {
   @override
   Widget build(BuildContext context) {
     // final PageTopController c = Get.find();
-    return PageFrame(child: wBody(context));
+    return PageFrame(child: _wBody(context));
   }
 
-  Widget wBody(BuildContext context) {
+  Widget _wBody(BuildContext context) {
     return Obx(() {
       final data = controller.mapList;
       return Container(

+ 240 - 103
lib/view/mapto/activity_view.dart

@@ -1,14 +1,26 @@
 import 'package:flutter/material.dart';
 import 'package:get/get.dart';
+import 'package:trackoffical_app/utils.dart';
 import 'package:trackoffical_app/view/mapto/map_to_controller.dart';
+import '../../generated/app_api.pb.dart';
 import '../../generated/assets.dart';
 import '../../screen.dart';
 import 'package:trackoffical_app/pb.dart' as pb;
 
-class ActivityView extends GetView {
-  const ActivityView(this.data, {super.key});
+import '../../widget/common.dart';
+
+class ActivityView extends GetView<MapToController> {
+  const ActivityView({super.key});
+  // const ActivityView(this.mapActivitySimpleInfo, this.userInfo, {super.key});
   // final MapToController mapToController = Get.find();
-  final List<pb.MapActivitySimpleInfo> data;
+  // final List<pb.MapActivitySimpleInfo> mapActivitySimpleInfo;
+  // final List<ModelUserInfo> userInfo;
+
+  static Bindings bindings() {
+    return BindingsBuilder(() {
+      Get.lazyPut<MapToController>(() => MapToController());
+    });
+  }
 
   @override
   Widget build(BuildContext context) {
@@ -29,100 +41,97 @@ class ActivityView extends GetView {
       ),
       child: Column(
         mainAxisAlignment: MainAxisAlignment.start,
-        children: [wActivitys()],
+        children: [_wActivitys()],
       ),
     );
   }
 
-  Widget wActivitys() {
-    // var data = mapToController.mapActivitySimpleInfo;
-    return Expanded(
-        child: ListView.builder(
-            padding: EdgeInsets.only(top: 0.wp),
-            itemCount: data.length,
-            itemBuilder: (ctx, i) {
-              return _wElem(ctx, i);
-            }));
+  Widget _wActivitys() {
+    // var mapActivitySimpleInfo = mapToController.mapActivitySimpleInfo;
+    return Obx(() {
+      return Expanded(
+          child: ListView.builder(
+              padding: EdgeInsets.only(top: 0.wp),
+              // itemCount: mapActivitySimpleInfo.length,
+              itemCount: controller.mapActivityList.value.list.length,
+              itemBuilder: (ctx, i) {
+                return _wActivityElem(ctx, i);
+              }));
+    });
   }
 
-  Widget _wElem(BuildContext ctx, int i) {
+  Widget _wActivityElem(BuildContext ctx, int i) {
+    // var info = mapActivitySimpleInfo[i].obs;
+    var info = controller.mapActivityList.value.list[i];
+    var expand = true.obs;
+
     return Obx(() {
-      var info = data[i].obs;
       return GestureDetector(
-        // onTap: info.isOpen? ()=>ActivityDetailView.to(info): null,
+          // onTap: info.isOpen? ()=>ActivityDetailView.to(info): null,
           child: Container(
-            margin: EdgeInsets.only(left: 0.wp, right: 0.wp, top: 0.wp, bottom: 1.wp),
-            // padding: EdgeInsets.only(left: 0.8.wp, right: 0.8.wp, top: 0.8.wp, bottom: 0.8.wp),
-            padding: EdgeInsets.all(0.8.wp),
-            decoration: BoxDecoration(
-              color: const Color(0xffe0e0e0),
-              borderRadius: BorderRadius.circular(0.35.wp),
-            ),
-            child: Column(
-              children: [
-                _activityTitle(info.value.name, info.value.totalControlNum),
-                _activityControl(info.value.totalControlNum),
-              ],
-            ),
-          ));
+        margin:
+            EdgeInsets.only(left: 0.wp, right: 0.wp, top: 0.wp, bottom: 1.wp),
+        // padding: EdgeInsets.only(left: 0.8.wp, right: 0.8.wp, top: 0.8.wp, bottom: 0.8.wp),
+        padding: EdgeInsets.all(0.8.wp),
+        decoration: BoxDecoration(
+          color: const Color(0xffe0e0e0),
+          borderRadius: BorderRadius.circular(0.35.wp),
+        ),
+        child: Column(
+          children: [
+            _activityTitle(info, expand),
+            expand.value ? _activityControl(info) : Container(),
+            expand.value ? _wUserList() : Container(),
+          ],
+        ),
+      ));
     });
   }
 
-  Widget _activityTitle(String title, int num) {
+  Widget _activityTitle(MapActivitySimpleInfo info, var expand) {
     return Container(
-      padding: EdgeInsets.only(bottom: 1.wp),
-      child: Row(
-        mainAxisAlignment: MainAxisAlignment.start,
-        crossAxisAlignment: CrossAxisAlignment.center,
-        children: [
-          // SizedBox(
-          //   width: 20.wp,
-          //   child: Text.rich(
-          //       softWrap: false,
-          //       maxLines: 1,
-          //       overflow: TextOverflow.ellipsis,
-          //       TextSpan(
-          //           text: title,
-          //           style: TextStyle(fontSize: 1.39.wp, fontWeight: FontWeight.w700, color: Color(0xff333333)),
-          //           children: [
-          //             TextSpan(
-          //               text: "($num人)",
-          //               style: TextStyle(fontSize: 1.11.wp, fontWeight: FontWeight.w500, color: Color(0xff333333)),
-          //             ),
-          //           ])),
-          // ),
-
-          SizedBox(
-            width: 16.8.wp,
-            child: Text(title,
-                softWrap: false,
-                maxLines: 1,
-                overflow: TextOverflow.ellipsis,
+      child: GestureDetector(
+        onTap: () {
+          // debugPrint("expand.value = ${expand.value}");
+          expand.value = !(expand.value);
+        },
+        child: Row(
+          mainAxisAlignment: MainAxisAlignment.start,
+          crossAxisAlignment: CrossAxisAlignment.center,
+          children: [
+            SizedBox(
+              width: 16.8.wp,
+              child: Text(info.name,
+                  softWrap: false,
+                  maxLines: 1,
+                  overflow: TextOverflow.ellipsis,
+                  style: TextStyle(
+                      fontSize: 1.29.wp,
+                      fontWeight: FontWeight.w700,
+                      color: const Color(0xff333333))),
+            ),
+            SizedBox(width: 0.3.wp),
+            Text("(${info.totalControlNum}人)",
                 style: TextStyle(
-                    fontSize: 1.39.wp,
-                    fontWeight: FontWeight.w700,
-                    color: Color(0xff333333))),
-          ),
-          SizedBox(width: 0.3.wp),
-          Text("($num人)",
-              style: TextStyle(
-                  fontSize: 1.11.wp,
-                  fontWeight: FontWeight.w500,
-                  color: Color(0xff333333))),
-          SizedBox(width: 0.6.wp),
-          Image.asset(
-            Assets.imagesIcArrowUp,
-            height: 0.86.wp,
-            fit: BoxFit.fitHeight,
-          ),
-        ],
+                    fontSize: 1.11.wp,
+                    fontWeight: FontWeight.w500,
+                    color: const Color(0xff333333))),
+            SizedBox(width: 0.6.wp),
+            Image.asset(
+              expand.value ? Assets.imagesIcArrowUp : Assets.imagesIcArrowDown,
+              height: 0.86.wp,
+              fit: BoxFit.fitHeight,
+            ),
+          ],
+        ),
       ),
     );
   }
 
-  Widget _activityControl(int totalControlNum) {
+  Widget _activityControl(MapActivitySimpleInfo info) {
     return Container(
-        padding: EdgeInsets.symmetric(vertical: 0.8.wp, horizontal: 1.wp),
+        margin: EdgeInsets.only(top: 0.6.wp),
+        padding: EdgeInsets.symmetric(vertical: 0.5.wp, horizontal: 1.wp),
         decoration: BoxDecoration(
           color: Colors.white,
           borderRadius: BorderRadius.circular(0.42.wp),
@@ -132,11 +141,15 @@ class ActivityView extends GetView {
           children: [
             Row(
               children: [
-                Text("广播"),
+                Text("广播",
+                    style: TextStyle(
+                        fontSize: 1.11.wp,
+                        fontWeight: FontWeight.w500,
+                        color: Colors.black)),
                 SizedBox(width: 0.5.wp),
                 Image.asset(
                   Assets.imagesIcBullhorn,
-                  height: 1.33.wp,
+                  height: 1.13.wp,
                   fit: BoxFit.fitHeight,
                 ),
               ],
@@ -149,12 +162,16 @@ class ActivityView extends GetView {
                   fit: BoxFit.fitHeight,
                 ),
                 SizedBox(width: 0.3.wp),
-                Text("$totalControlNum"),
+                Text("${info.totalControlNum}"),
               ],
             ),
             Row(
               children: [
-                Text("全部隐藏"),
+                Text("全部隐藏",
+                    style: TextStyle(
+                        fontSize: 1.11.wp,
+                        fontWeight: FontWeight.w500,
+                        color: Colors.black)),
                 SizedBox(width: 0.5.wp),
                 Image.asset(
                   Assets.imagesIcEye,
@@ -164,34 +181,154 @@ class ActivityView extends GetView {
               ],
             ),
           ],
-        )
-    );
+        ));
   }
 
-  Widget wUserList() {
-    return Expanded(
-        child: ListView.builder(
-            padding: EdgeInsets.only(top: 0.wp),
-            itemCount: data.length,
-            itemBuilder: (ctx, i) {
-              return _wUserElem(ctx, i);
-            }));
+  Widget _wUserList() {
+    final children = <Widget>[];
+
+    return Obx(() {
+      for (var i = 0; i < controller.userInfoList.length; i++) {
+        final userInfo = controller.userInfoList[i];
+
+        children.add(Container(
+            height: 6.25.wp,
+            margin: EdgeInsets.only(top: 0.5.wp),
+            padding: EdgeInsets.symmetric(vertical: 0.5.wp, horizontal: 0.5.wp),
+            decoration: BoxDecoration(
+              color: Colors.white,
+              borderRadius: BorderRadius.circular(0.42.wp),
+            ),
+            child: Column(
+              mainAxisAlignment: MainAxisAlignment.spaceBetween,
+              children: [
+                _wUserInfoRow1(userInfo),
+                _wUserInfoRow2(userInfo),
+                _wUserInfoRow3(userInfo),
+              ],
+            )));
+      }
+      return Column(
+        children: children,
+      );
+    });
   }
 
-  Widget _wUserElem(BuildContext ctx, int i) {
-    return Container(
-        padding: EdgeInsets.symmetric(vertical: 0.8.wp, horizontal: 1.wp),
-        decoration: BoxDecoration(
-          color: Colors.white,
-          borderRadius: BorderRadius.circular(0.42.wp),
+  Widget _wUserInfoRow1(ModelUserInfo userInfo) {
+    return Row(
+      mainAxisAlignment: MainAxisAlignment.start,
+      crossAxisAlignment: CrossAxisAlignment.center,
+      children: [
+        wUserMark(userInfo.iUserid!),
+        SizedBox(width: 0.5.wp),
+        Text(userInfo.sUserName!,
+            style: TextStyle(
+                fontSize: 1.25.wp,
+                fontWeight: FontWeight.w500,
+                color: Colors.black)),
+        SizedBox(width: 0.5.wp),
+        Text("[${userInfo.sRouteCode}]",
+            style: TextStyle(
+                fontSize: 0.97.wp,
+                fontWeight: FontWeight.w400,
+                color: Colors.black)),
+        const Spacer(),
+        Image.asset(
+          true ? Assets.imagesIcEye : Assets.imagesIcEyeOff,
+          height: 1.1.wp,
+          fit: BoxFit.fitHeight,
         ),
-        child: Row(
-          mainAxisAlignment: MainAxisAlignment.spaceBetween,
-          children: [
+        SizedBox(width: 0.5.wp),
+      ],
+    );
+  }
 
-          ],
-        )
+  Widget _wUserInfoRow2(ModelUserInfo userInfo) {
+    return Row(
+      mainAxisAlignment: MainAxisAlignment.spaceAround,
+      crossAxisAlignment: CrossAxisAlignment.center,
+      children: [
+        //待打点位
+        Container(
+          width: 7.81.wp,
+          padding: EdgeInsets.symmetric(vertical: 0.wp, horizontal: 0.6.wp),
+          decoration: BoxDecoration(
+              color: const Color(0xff00a0ff),
+              borderRadius: BorderRadius.circular(0.63.wp)),
+          child: Text("${userInfo.iNextCPId}号点 (${userInfo.sNextCPCode})",
+              textAlign: TextAlign.center,
+              softWrap: false,
+              maxLines: 1,
+              overflow: TextOverflow.ellipsis,
+              style: TextStyle(
+                  fontSize: 0.97.wp,
+                  fontWeight: FontWeight.w400,
+                  color: Colors.white)),
+        ),
+        // 心率
+        Container(
+            width: 4.67.wp,
+            padding: EdgeInsets.symmetric(vertical: 0.wp, horizontal: 0.9.wp),
+            decoration: BoxDecoration(
+                color: userInfo.iHr!.toHRPColor(),
+                borderRadius: BorderRadius.circular(0.63.wp)),
+            child: Row(
+              mainAxisAlignment: MainAxisAlignment.spaceAround,
+              children: [
+                Image.asset(Assets.imagesIcHeart,
+                    height: 0.82.wp, fit: BoxFit.fitHeight),
+                // SizedBox(width: 0.5.wp),
+                Text("${userInfo.iHr}",
+                    style: TextStyle(
+                        fontSize: 0.97.wp,
+                        fontWeight: FontWeight.w400,
+                        color: Colors.white)),
+              ],
+            )),
+        //配速
+        Container(
+          width: 6.39.wp,
+          padding: EdgeInsets.symmetric(vertical: 0.wp, horizontal: 0.6.wp),
+          decoration: BoxDecoration(
+              color: const Color(0xffff880f),
+              borderRadius: BorderRadius.circular(0.63.wp)),
+          child: Text("${userInfo.pacePerKm?.toMinSecondString()}/km",
+              textAlign: TextAlign.center,
+              softWrap: false,
+              maxLines: 1,
+              overflow: TextOverflow.ellipsis,
+              style: TextStyle(
+                  fontSize: 0.97.wp,
+                  fontWeight: FontWeight.w400,
+                  color: Colors.white)),
+        ),
+      ],
     );
   }
 
+  Widget _wUserInfoRow3(ModelUserInfo userInfo) {
+    return Row(
+      mainAxisAlignment: MainAxisAlignment.spaceAround,
+      crossAxisAlignment: CrossAxisAlignment.center,
+      children: [
+        Text("距离 ${userInfo.iDistance!}m",
+            style: TextStyle(
+                fontSize: 0.97.wp,
+                fontWeight: FontWeight.w400,
+                color: Colors.black)),
+        SizedBox(width: 0.5.wp),
+        Text("时间 ${userInfo.iTime}",
+            style: TextStyle(
+                fontSize: 0.97.wp,
+                fontWeight: FontWeight.w400,
+                color: Colors.black)),
+        SizedBox(width: 0.5.wp),
+        Text("里程 ${userInfo.iMileage} km",
+            style: TextStyle(
+                fontSize: 0.97.wp,
+                fontWeight: FontWeight.w400,
+                color: Colors.black)),
+      ],
+    );
+  }
 }

+ 41 - 9
lib/view/mapto/map_to_controller.dart

@@ -7,19 +7,50 @@ import '../../service/app.dart';
 import '../../utils.dart';
 import 'package:trackoffical_app/pb.dart' as pb;
 
+class ModelUserInfo {
+  int? iUserid;
+  String? sUserName;
+  String? sRouteCode;
+  int? iNextCPId;
+  String? sNextCPCode;
+  int? iHr;
+  Duration? pacePerKm;
+  int? iDistance;
+  int? iTime;
+  int? iMileage; // 里程
+  // IconData? iconData;
+  ModelUserInfo(this.iUserid, this.sUserName, this.sRouteCode, this.iNextCPId, this.sNextCPCode,
+      this.iHr, this.pacePerKm, this.iDistance, this.iTime, this.iMileage);
+}
+
+// const String kSubTitle = "abcdefghijklmnopqrstuvwxyz-1234567890";
+List<ModelUserInfo> itemUserInfoDatas = <ModelUserInfo>[
+  ModelUserInfo(1, "贾奕", "LX001", 1, "A51", 51, 11551.seconds, 251, 91, 801),
+  ModelUserInfo(2, "王正祥", "LX002", 12, "A52", 62, 1522.seconds, 252, 92, 801),
+  ModelUserInfo(3, "冯烁", "LX003", 123, "A53", 73, 1523.seconds, 253, 93, 803),
+  ModelUserInfo(4, "贾雨奇", "LX004", 4, "A54", 84, 1524.seconds, 254, 94, 804),
+  ModelUserInfo(5, "刘海生", "LX005", 5, "A55", 95, 1525.seconds, 255, 95, 805),
+  ModelUserInfo(6, "周睿", "LX006", 6, "A56", 106, 11556.seconds, 251, 96, 806),
+];
+
 class MapToController extends GetxController {
   var isMapExpanded = false.obs;
   var mapId = 0.obs;
   final _mapList = <MapInfo>[].obs;
-  final _mapActivityList = pb.MapActivityListReply().obs;
+  final mapActivityList = pb.MapActivityListReply().obs;
+  final userInfoList = <ModelUserInfo>[].obs;
 
-  pb.MapActivityListReply get mapActivityList{
-    return _mapActivityList.value;
-  }
-
-  List<pb.MapActivitySimpleInfo> get mapActivitySimpleInfo{
-    return _mapActivityList.value.list;
-  }
+  // pb.MapActivityListReply get mapActivityList{
+  //   return _mapActivityList.value;
+  // }
+  //
+  // List<pb.MapActivitySimpleInfo> get mapActivitySimpleInfo{
+  //   return _mapActivityList.value.list;
+  // }
+  //
+  // List<ModelUserInfo> get userInfo{
+  //   return _userInfoList;
+  // }
 
   final mapInfoListScrollController = ScrollController();
   final _api = ApiService.to;
@@ -33,12 +64,13 @@ class MapToController extends GetxController {
   MPosition? get myPosition => App.to.position.value;
 
   Future<void> getMapActivityList() async{
-    _mapActivityList.value = await _api.mapActivityList(mapId.value, "");
+    mapActivityList.value = await _api.mapActivityList(mapId.value, "");
   }
 
 
   @override
   void onReady() async{
+    userInfoList.value = itemUserInfoDatas;
     await getMapActivityList();
   }
 

+ 6 - 4
lib/view/mapto/map_to_view.dart

@@ -22,13 +22,14 @@ class MapToView extends GetView<MapToController> {
   @override
   Widget build(BuildContext context) {
     // final PageTopController c = Get.find();
-    return PageFrame(child: wBody(context));
+    return PageFrame(child: _wBody(context));
   }
 
-  Widget wBody(BuildContext context) {
+  Widget _wBody(BuildContext context) {
     return Obx(() {
       var isMapExpanded = controller.isMapExpanded;
-      var mapActivitySimpleInfo = controller.mapActivitySimpleInfo;
+      // var mapActivitySimpleInfo = controller.mapActivityList;
+      // var userInfo = controller.userInfoList;
       // isMapExpanded.value = true;
       // final data = controller.mapList;
       return Container(
@@ -48,7 +49,8 @@ class MapToView extends GetView<MapToController> {
               ]),
             ),
             // 活动
-            !isMapExpanded.value ? ActivityView(mapActivitySimpleInfo) : Container(),
+            // !isMapExpanded.value ? ActivityView(mapActivitySimpleInfo, userInfo) : Container(),
+            !isMapExpanded.value ? ActivityView() : Container(),
           ]));
     });
   }

+ 1 - 1
protos/app_api

@@ -1 +1 @@
-Subproject commit a0f76343070f1b614453de667d963e361a3a154b
+Subproject commit e8299cdff5e3676c5ee054cd9e9732f93bfdcd0e