소스 검색

update(mobile): 完成注释工具

gavin.chen 2 년 전
부모
커밋
5f6096325b

+ 6 - 1
lib/view/mobile_view/mobile_bottom_menu.dart

@@ -1,6 +1,8 @@
+import 'package:fis_measure/interfaces/enums/annotation.dart';
 import 'package:fis_measure/interfaces/process/player/play_controller.dart';
 import 'package:fis_measure/interfaces/process/workspace/application.dart';
 import 'package:fis_measure/interfaces/process/workspace/mobile_measure_view_state_controller.dart';
+import 'package:fis_measure/process/workspace/measure_handler.dart';
 import 'package:fis_measure/view/mobile_view/controller/mobile_measure_view_state_controller.dart';
 import 'package:fis_measure/view/mobile_view/mobile_control_board/mobile_control_board.dart';
 import 'package:fis_measure/view/mobile_view/mobile_control_board/next_btn.dart';
@@ -22,6 +24,7 @@ class MobileBottomMenu extends StatefulWidget {
 
 class _MobileBottomMenuState extends State<MobileBottomMenu> {
   final application = Get.find<IApplication>();
+  late final measureHandler = Get.find<MeasureHandler>();
   final mobileMeasureStateController =
       Get.find<MobileMeasureViewStateController>();
   late final playerController = Get.find<IPlayerController>();
@@ -128,7 +131,9 @@ class _MobileBottomMenuState extends State<MobileBottomMenu> {
                   ? SingleIconButton(
                       icon: Icons.more,
                       onPressed: () {
-                        print("进入注释模式");
+                        measureHandler.changedAnnotationType =
+                            AnnotationType.label;
+                        application.switchAnnotation(AnnotationType.label);
                         mobileMeasureStateController.currentMode =
                             MobileMeasureMode.annotationMode;
                       },

+ 0 - 1
lib/view/mobile_view/mobile_measure_main_view.dart

@@ -228,7 +228,6 @@ class _MobileMeasureMainViewState extends State<MobileMeasureMainView> {
 
     measureCommentItemResult?.commentItems?.forEach((element) {
       commentsList.add(element.text ?? '');
-      print("element.text: ${element.text}");
     });
     measureData.getCommentsList = commentsList;
   }

+ 18 - 12
lib/view/mobile_view/mobile_right_panel.dart

@@ -51,9 +51,11 @@ class _MobileRightPanelState extends State<MobileRightPanel> {
     return Column(
       mainAxisAlignment: MainAxisAlignment.start,
       children: [
-        Row(
-          mainAxisAlignment: MainAxisAlignment.end,
-          children: [_rightPanel()],
+        Expanded(
+          child: Row(
+            mainAxisAlignment: MainAxisAlignment.end,
+            children: [_rightPanel()],
+          ),
         ),
       ],
     );
@@ -62,17 +64,21 @@ class _MobileRightPanelState extends State<MobileRightPanel> {
   Widget _rightPanel() {
     switch (curMode) {
       case MobileMeasureMode.playerMode:
-        return SizedBox(
-          width: 150,
-          height: 220,
-          child: FittedBox(
-            child: SizedBox(
-              width: 200,
-              child: AIPaintInfoReslut(
-                playerController as VidPlayerController,
+        return Column(
+          children: [
+            SizedBox(
+              width: 150,
+              height: 220,
+              child: FittedBox(
+                child: SizedBox(
+                  width: 200,
+                  child: AIPaintInfoReslut(
+                    playerController as VidPlayerController,
+                  ),
+                ),
               ),
             ),
-          ),
+          ],
         );
       case MobileMeasureMode.measureMode:
         return const MobileMeasureSelector();

+ 104 - 15
lib/view/mobile_view/mobile_right_panel/mobile_annotation_tool.dart

@@ -3,6 +3,7 @@ import 'package:fis_measure/interfaces/process/workspace/application.dart';
 import 'package:fis_measure/process/workspace/measure_data_controller.dart';
 import 'package:fis_measure/process/workspace/measure_handler.dart';
 import 'package:fis_measure/utils/prompt_box.dart';
+import 'package:fis_measure/view/measure/tool_chest_title.dart';
 import 'package:fis_ui/index.dart';
 import 'package:flutter/material.dart';
 import 'package:get/get.dart';
@@ -27,15 +28,31 @@ class _MobileAnnotationSelectorState extends State<MobileAnnotationSelector> {
   /// 数据
   late final measureData = Get.find<MeasureDataController>();
 
+  bool isArrowMode = false;
+
+  void onChangedAnnotationType(
+    Object sender,
+    AnnotationType? e,
+  ) {
+    print("onChangedAnnotationType");
+    setState(() {
+      isArrowMode =
+          measureHandler.changedAnnotationType == AnnotationType.arrow;
+    });
+  }
+
   @override
   void initState() {
-    // application.switchAnnotation(
-    //     AnnotationType.label, measureData.getCommentsList[0]);
+    measureHandler.onChangedAnnotationType.addListener(onChangedAnnotationType);
+
     super.initState();
   }
 
   @override
   void dispose() {
+    measureHandler.onChangedAnnotationType
+        .removeListener(onChangedAnnotationType);
+
     super.dispose();
   }
 
@@ -46,19 +63,24 @@ class _MobileAnnotationSelectorState extends State<MobileAnnotationSelector> {
         const SizedBox(
           height: 50,
         ),
-        SizedBox(
-          width: 150,
-          height: 300,
-          child: Scrollbar(
-            controller: scrollController,
-            isAlwaysShown: true,
-            child: GridView.count(
+        _buildModeChangeBtn(),
+        const SizedBox(
+          height: 10,
+        ),
+        Expanded(
+          child: SizedBox(
+            width: 150,
+            child: Scrollbar(
               controller: scrollController,
-              crossAxisCount: 1,
-              childAspectRatio: 3,
-              children: measureData.getCommentsList.map((e) {
-                return _buildNoteTools(e);
-              }).toList(),
+              isAlwaysShown: true,
+              child: GridView.count(
+                controller: scrollController,
+                crossAxisCount: 1,
+                childAspectRatio: 3,
+                children: measureData.getCommentsList.map((e) {
+                  return _buildNoteTools(e);
+                }).toList(),
+              ),
             ),
           ),
         ),
@@ -94,7 +116,7 @@ class _MobileAnnotationSelectorState extends State<MobileAnnotationSelector> {
           child: OutlinedButton(
             child: Text(tools, style: style),
             onPressed: () {
-              PromptBox.toast('拖动添加');
+              PromptBox.toast('拖动添加注释');
             },
             style: OutlinedButton.styleFrom(
               shape: RoundedRectangleBorder(
@@ -113,4 +135,71 @@ class _MobileAnnotationSelectorState extends State<MobileAnnotationSelector> {
       ],
     );
   }
+
+  Widget _buildModeChangeBtn() {
+    return SizedBox(
+      width: 150,
+      child: Row(
+        mainAxisSize: MainAxisSize.max,
+        mainAxisAlignment: MainAxisAlignment.center,
+        children: [
+          InkWell(
+            child: _buildModeBtn(!isArrowMode, "文本", Icons.abc, true),
+            onTap: () {
+              measureHandler.changedAnnotationType = AnnotationType.label;
+              application.switchAnnotation(AnnotationType.label);
+            },
+          ),
+          InkWell(
+            child: _buildModeBtn(
+                isArrowMode, "箭头", Icons.compare_arrows_rounded, false),
+            onTap: () {
+              measureHandler.changedAnnotationType = AnnotationType.arrow;
+              application.switchAnnotation(AnnotationType.arrow);
+            },
+          ),
+        ],
+      ),
+    );
+  }
+
+  Widget _buildModeBtn(
+      bool ifActive, String text, IconData iconData, bool ifLeft) {
+    const style = TextStyle(color: Colors.grey, fontSize: 12);
+    const activeStyle = TextStyle(color: Colors.white, fontSize: 12);
+    const borderColor = Colors.grey;
+    const activeBorderColor = Colors.white;
+    const borderSide = BorderSide(color: borderColor);
+    const activeBorderSide = BorderSide(color: activeBorderColor);
+    const leftBorderStyle = BorderRadius.only(
+      topLeft: Radius.circular(4),
+      bottomLeft: Radius.circular(4),
+    );
+    const rightBorderStyle = BorderRadius.only(
+      topRight: Radius.circular(4),
+      bottomRight: Radius.circular(4),
+    );
+    return Container(
+      decoration: BoxDecoration(
+        borderRadius: ifLeft ? leftBorderStyle : rightBorderStyle,
+        border: Border.fromBorderSide(ifActive ? activeBorderSide : borderSide),
+      ),
+      padding: const EdgeInsets.symmetric(
+        horizontal: 4,
+        vertical: 4,
+      ),
+      child: Row(
+        children: [
+          Icon(
+            iconData,
+            color: ifActive ? Colors.white : Colors.grey,
+          ),
+          const FSizedBox(
+            width: 6,
+          ),
+          Text(text, style: ifActive ? activeStyle : style),
+        ],
+      ),
+    );
+  }
 }

+ 1 - 28
lib/view/mobile_view/mobile_top_menu.dart

@@ -95,8 +95,6 @@ class _MobileTopMenuState extends State<MobileTopMenu> {
           _exitBtn(),
           const Text('注释模式'),
           _fillEmptySpace(),
-          _annotationBtn(),
-          _arrowBtn(),
           _saveBtn(),
           _deleteBtn(),
           _undoBtn(),
@@ -137,7 +135,7 @@ class _MobileTopMenuState extends State<MobileTopMenu> {
     return SingleIconButton(
       icon: Icons.arrow_back_ios_new,
       onPressed: () {
-        print("call 返回");
+        Get.back();
       },
     );
   }
@@ -146,36 +144,11 @@ class _MobileTopMenuState extends State<MobileTopMenu> {
     return SingleIconButton(
       icon: Icons.exit_to_app,
       onPressed: () {
-        print("call 退出当前模式");
         mobileMeasureStateController.currentMode = MobileMeasureMode.playerMode;
       },
     );
   }
 
-  Widget _annotationBtn() {
-    return SingleIconButton(
-      icon: Icons.abc,
-      onPressed: () {
-        print("call 注释模式");
-      },
-    );
-  }
-
-  Widget _arrowBtn() {
-    // bool get isArrowMeasureAnnotationType =>
-    //   measureHandler.changedAnnotationType == AnnotationType.arrow;
-    // TODO 原本是用于判断当前是否为箭头模式
-    return SingleIconButton(
-      icon: Icons.compare_arrows_rounded,
-      onPressed: () {
-        print("call 箭头模式");
-        measureHandler.changedAnnotationType =
-            AnnotationType.arrow; // TODO 原本是用于判断当前是否为箭头模式
-        application.switchAnnotation(AnnotationType.arrow);
-      },
-    );
-  }
-
   Widget _deleteBtn() {
     return SingleIconButton(
       icon: Icons.delete_outline,