Ver Fonte

[new]增加轨迹详情按钮

zk há 8 meses atrás
pai
commit
bdc2eda084

+ 1 - 0
assets/string/base/string.xml

@@ -287,4 +287,5 @@
     <string name="wechat_pay_qr_code_tips">请使用微信扫码支付</string>
     <string name="member_payment_failed">开通失败,请稍后重试</string>
     <string name="exit_app_tip">再按一次退出应用</string>
+    <string name="trace_detail">轨迹详情</string>
 </resources>

+ 14 - 2
lib/module/track/track_controller.dart

@@ -68,6 +68,10 @@ class TrackController extends BaseController
 
   List<LatLng>? points;
 
+  final RxBool _isShowTraceDetailBtn = false.obs;
+
+  bool get isShowTraceDetailBtn => _isShowTraceDetailBtn.value;
+
   final TrackRepository trackRepository;
   final FriendsRepository friendsRepository;
   final AccountRepository accountRepository;
@@ -238,12 +242,10 @@ class TrackController extends BaseController
       }
       return Pair(pointsList, convertList);
     }).then((pair) {
-      LoadingDialog.hide();
       points = pair.second;
       _showTrack();
       _setStartAndEndAddress(start: pair.first.first, end: pair.first.last);
     }).catchError((error) {
-      LoadingDialog.hide();
       if (error is TrackQueryException) {
         showQueryErrorDialog();
       } else if (error is ServerErrorException) {
@@ -256,6 +258,9 @@ class TrackController extends BaseController
       } else {
         ErrorHandler.toastError(error);
       }
+    }).whenComplete(() {
+      LoadingDialog.hide();
+      _isShowTraceDetailBtn.value = true;
     });
   }
 
@@ -321,6 +326,13 @@ class TrackController extends BaseController
   void showQueryErrorDialog() {
     showTraceNoDataDialog(onConfirm: () {});
   }
+
+  void onTraceDetailClick() {
+    if (points == null || points!.length < 2) {
+      showTraceNoDataDialog(onConfirm: () {});
+      return;
+    }
+  }
 }
 
 class TrackQueryException implements Exception {

+ 72 - 12
lib/module/track/track_page.dart

@@ -107,19 +107,79 @@ class TrackPage extends BasePage<TrackController> {
     return GestureDetector(
       onTap: controller.onTrackQueryClick,
       child: Container(
-        width: 322.w,
-        height: 46.w,
         margin: EdgeInsets.only(bottom: 18.w, top: 9.w),
-        decoration: getPrimaryBtnDecoration(46.w),
-        child: Center(
-          child: Obx(() {
-            return Text(
-              controller.currentIndex == 0
-                  ? StringName.trackQueryPath
-                  : StringName.trackNowLocation,
-              style: TextStyle(fontSize: 14.sp, color: Colors.white),
-            );
-          }),
+        child: Row(
+          mainAxisAlignment: MainAxisAlignment.center,
+          children: [
+            Obx(() {
+              return GestureDetector(
+                onTap: controller.onTraceDetailClick,
+                child: AnimatedOpacity(
+                  opacity: controller.currentIndex == 0 ? 1 : 0,
+                  duration: Duration(milliseconds: 250),
+                  child: AnimatedContainer(
+                    width: controller.currentIndex == 0 &&
+                            controller.isShowTraceDetailBtn
+                        ? 152.w
+                        : 0.w,
+                    height: 46.w,
+                    decoration: BoxDecoration(
+                      color: '#147B7DFF'.color,
+                      border:
+                          Border.all(color: ColorName.colorPrimary, width: 1.w),
+                      borderRadius: BorderRadius.circular(46.w),
+                    ),
+                    duration: Duration(milliseconds: 250),
+                    child: Center(
+                      child: Text(
+                        maxLines: 1,
+                        StringName.traceDetail,
+                        style: TextStyle(
+                            fontSize: 14.sp, color: ColorName.colorPrimary),
+                      ),
+                    ),
+                  ),
+                ),
+              );
+            }),
+            // Obx(() {
+            //   return Visibility(
+            //       visible: controller.currentIndex == 0 &&
+            //           controller.isShowTraceDetailBtn,
+            //       child: SizedBox(width: 18.w));
+            // }),
+            Obx(() {
+              double width = 152.w;
+              if (controller.currentIndex == 1) {
+                width = 322.w;
+              } else if (controller.isShowTraceDetailBtn) {
+                width = 152.w;
+              } else {
+                width = 322.w;
+              }
+              return AnimatedContainer(
+                margin: EdgeInsets.only(
+                    left: controller.currentIndex == 0 &&
+                            controller.isShowTraceDetailBtn
+                        ? 18.w
+                        : 0),
+                duration: Duration(milliseconds: 250),
+                width: width,
+                height: 46.w,
+                decoration: getPrimaryBtnDecoration(46.w),
+                child: Center(
+                  child: Obx(() {
+                    return Text(
+                      controller.currentIndex == 0
+                          ? StringName.trackQueryPath
+                          : StringName.trackNowLocation,
+                      style: TextStyle(fontSize: 14.sp, color: Colors.white),
+                    );
+                  }),
+                ),
+              );
+            })
+          ],
         ),
       ),
     );

+ 2 - 0
lib/resource/string.gen.dart

@@ -242,6 +242,7 @@ class StringName {
   static final String memberPaymentFailed =
       'member_payment_failed'.tr; // 开通失败,请稍后重试
   static final String exitAppTip = 'exit_app_tip'.tr; // 再按一次退出应用
+  static final String traceDetail = 'trace_detail'.tr; // 轨迹详情
 }
 class StringMultiSource {
   StringMultiSource._();
@@ -481,6 +482,7 @@ class StringMultiSource {
       'wechat_pay_qr_code_tips': '请使用微信扫码支付',
       'member_payment_failed': '开通失败,请稍后重试',
       'exit_app_tip': '再按一次退出应用',
+      'trace_detail': '轨迹详情',
     },
   };
 }