Browse Source

update(mobile): 完成注释工具基础结构

gavin.chen 2 years ago
parent
commit
51ef52edcb

+ 0 - 113
lib/view/gesture/mobile_annotation/input_position_panel.dart

@@ -1,113 +0,0 @@
-// ignore_for_file: constant_identifier_names
-
-import 'package:fis_measure/interfaces/process/workspace/application.dart';
-import 'package:fis_measure/interfaces/process/workspace/point_info.dart';
-import 'package:fis_measure/values/colors.dart';
-import 'package:flutter/material.dart';
-import 'package:get/get.dart';
-
-import '../positioned_cursor.dart';
-
-/// 自定义注释文本框定位面板
-class AnnotationInputPositionPanel extends StatefulWidget {
-  const AnnotationInputPositionPanel({Key? key}) : super(key: key);
-
-  @override
-  State<AnnotationInputPositionPanel> createState() => _PanelState();
-}
-
-class _PanelState extends State<AnnotationInputPositionPanel> {
-  late final application = Get.find<IApplication>();
-  final mouseState = Get.find<IMouseState>();
-
-  Offset? position;
-
-  @override
-  Widget build(BuildContext context) {
-    return GestureDetector(
-      onPanDown: (details) {
-        setState(() {
-          position = details.localPosition;
-          application.createPointInfo(position!, PointInfoType.mouseDown);
-        });
-      },
-      child: MouseRegion(
-        cursor: SystemMouseCursors.none,
-        onHover: (event) {
-          mouseState.mousePosition = event.localPosition +
-              const Offset(
-                _InputWidget.C_MIN_WIDTH / 2,
-                _InputWidget.C_MAX_HEIGHT / 2,
-              );
-        },
-        child: Stack(
-          children: [
-            if (position != null)
-              Positioned(
-                child: _InputWidget(
-                  key: UniqueKey(),
-                  onChanged: (value) {
-                    application.activeAnnotationItem?.text = value;
-                  },
-                ),
-                left: position!.dx,
-                top: position!.dy,
-              ),
-            const PositionedCursor(),
-          ],
-        ),
-      ),
-    );
-  }
-}
-
-typedef _InputValueChanged = void Function(String value);
-
-class _InputWidget extends StatelessWidget {
-  static const C_BG_COLOR = Color.fromARGB(255, 121, 135, 151);
-  static const C_MIN_WIDTH = 40.0;
-  static const C_MAX_HEIGHT = 28.0;
-
-  final FocusNode? focusNode;
-  final _InputValueChanged onChanged;
-
-  const _InputWidget({
-    required this.onChanged,
-    Key? key,
-    this.focusNode,
-  }) : super(key: key);
-
-  @override
-  Widget build(BuildContext context) {
-    const border = OutlineInputBorder(
-      borderSide: BorderSide(color: C_BG_COLOR),
-      borderRadius: BorderRadius.all(Radius.circular(4.0)),
-    );
-    final input = TextField(
-      expands: false,
-      autofocus: true,
-      focusNode: focusNode,
-      style: const TextStyle(color: MeasureColors.Primary),
-      cursorColor: MeasureColors.Primary,
-      cursorWidth: 1.0,
-      onChanged: onChanged,
-      decoration: const InputDecoration(
-        border: border,
-        enabledBorder: border,
-        focusedBorder: border,
-        counterText: '',
-        filled: true,
-        fillColor: C_BG_COLOR,
-        isCollapsed: false,
-        contentPadding: EdgeInsets.symmetric(horizontal: 2, vertical: 8),
-        constraints:
-            BoxConstraints(minWidth: C_MIN_WIDTH, maxHeight: C_MAX_HEIGHT),
-      ),
-    );
-    return Container(
-      padding: const EdgeInsets.symmetric(horizontal: 1),
-      alignment: Alignment.topLeft,
-      child: IntrinsicWidth(child: input),
-    );
-  }
-}

+ 1 - 16
lib/view/gesture/mobile_annotation/label_drag_target_pannel.dart

@@ -4,8 +4,6 @@ import 'package:fis_measure/interfaces/process/workspace/point_info.dart';
 import 'package:flutter/material.dart';
 import 'package:get/get.dart';
 
-import '../positioned_cursor.dart';
-
 /// 文本注释拖拽目标面板
 class AnnotationLabelDragTargetPanel extends StatefulWidget {
   const AnnotationLabelDragTargetPanel({Key? key}) : super(key: key);
@@ -16,7 +14,6 @@ class AnnotationLabelDragTargetPanel extends StatefulWidget {
 
 class _PanelState extends State<AnnotationLabelDragTargetPanel> {
   late final application = Get.find<IApplication>();
-  final mouseState = Get.find<IMouseState>();
 
   @override
   void initState() {
@@ -36,19 +33,8 @@ class _PanelState extends State<AnnotationLabelDragTargetPanel> {
                 details.localPosition,
                 PointInfoType.mouseDown,
               );
-              application.switchAnnotation(AnnotationType.input);
+              // application.switchAnnotation(AnnotationType.input);
             },
-            child: MouseRegion(
-              cursor: SystemMouseCursors.none,
-              onHover: (event) {
-                mouseState.mousePosition = event.localPosition;
-              },
-              child: Stack(
-                children: const [
-                  PositionedCursor(),
-                ],
-              ),
-            ),
           );
         },
         onMove: (details) {
@@ -67,7 +53,6 @@ class _PanelState extends State<AnnotationLabelDragTargetPanel> {
     PointInfoType type,
   ) {
     final localOffset = _findLocalPosition(context, offset);
-    mouseState.mousePosition = localOffset;
     application.createPointInfo(localOffset, type);
   }
 

+ 1 - 28
lib/view/gesture/mobile_annotation/mobile_annotation_gesture.dart

@@ -6,7 +6,6 @@ import 'package:get/get.dart';
 
 import '../positioned_cursor.dart';
 import 'arrow_gesture_panel.dart';
-import 'input_position_panel.dart';
 import 'label_drag_target_pannel.dart';
 
 /// 移动端注释手势层
@@ -52,34 +51,8 @@ class _AnnotationTouchLayerState extends State<AnnotationTouchLayer> {
   @override
   Widget build(BuildContext context) {
     return _buildItemPanel();
-    // // TODO: melon - optimize with handlers
-    // return Stack(
-    //   children: [
-    //     _buildItemPanel(),
-    //     _buildTopGesture(),
-    //   ],
-    // );
   }
 
-  // Widget _buildTopGesture() {
-  //   return GestureDetector(
-  //     onPanUpdate: (details) {
-  //       mouseState.mousePosition = details.localPosition;
-  //     },
-  //     child: MouseRegion(
-  //       cursor: SystemMouseCursors.none,
-  //       onHover: (details) {
-  //         mouseState.mousePosition = details.localPosition;
-  //       },
-  //       child: Stack(
-  //         children: const [
-  //           PositionedCursor(),
-  //         ],
-  //       ),
-  //     ),
-  //   );
-  // }
-
   Widget _buildItemPanel() {
     if (currentItem == null) {
       return const SizedBox();
@@ -89,7 +62,7 @@ class _AnnotationTouchLayerState extends State<AnnotationTouchLayer> {
       case AnnotationType.label:
         return const AnnotationLabelDragTargetPanel();
       case AnnotationType.input:
-        return const AnnotationInputPositionPanel();
+        return Container();
       case AnnotationType.arrow:
         return const AnnotationArrowGesturePanel();
     }

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

@@ -90,6 +90,7 @@ class _MobileMeasureMainViewState extends State<MobileMeasureMainView> {
   void initState() {
     super.initState();
     installStandardLine();
+    getNoteCommentsList();
     final mobileMeasureStateController =
         Get.put(MobileMeasureViewStateController());
     mobileMeasureStateController.onModeChanged.addListener(_onViewModeChanged);
@@ -214,6 +215,24 @@ class _MobileMeasureMainViewState extends State<MobileMeasureMainView> {
     }
   }
 
+  /// 注释获取
+  void getNoteCommentsList() async {
+    List<String> commentsList = [];
+    var measureCommentItemResult =
+        await measureData.getCommentsByApplicationAsync(
+      application.applicationName,
+      application.categoryName,
+    );
+    measureData.measureCommentItemResult =
+        measureCommentItemResult?.commentItems ?? [];
+
+    measureCommentItemResult?.commentItems?.forEach((element) {
+      commentsList.add(element.text ?? '');
+      print("element.text: ${element.text}");
+    });
+    measureData.getCommentsList = commentsList;
+  }
+
   void onCanMeasureChanged(Object sender, bool e) {
     if (e != canMeasure) {
       setState(() {

+ 2 - 7
lib/view/mobile_view/mobile_right_panel.dart

@@ -2,6 +2,7 @@ import 'package:fis_measure/interfaces/process/player/play_controller.dart';
 import 'package:fis_measure/interfaces/process/workspace/mobile_measure_view_state_controller.dart';
 import 'package:fis_measure/view/measure/measure_left_annotation.dart';
 import 'package:fis_measure/view/mobile_view/controller/mobile_measure_view_state_controller.dart';
+import 'package:fis_measure/view/mobile_view/mobile_right_panel/mobile_annotation_tool.dart';
 import 'package:fis_measure/view/mobile_view/mobile_right_panel/mobile_measure_tool.dart';
 import 'package:fis_measure/view/paint/ai_patint_result.dart';
 import 'package:fis_measure/view/player/controller.dart';
@@ -76,13 +77,7 @@ class _MobileRightPanelState extends State<MobileRightPanel> {
       case MobileMeasureMode.measureMode:
         return const MobileMeasureSelector();
       case MobileMeasureMode.annotationMode:
-        return Container(
-          height: 100,
-          width: 100,
-          color: Color.fromARGB(10, 190, 190, 190),
-          key: UniqueKey(),
-          // child: const MeasureLeftAnnotation(),
-        );
+        return const MobileAnnotationSelector();
       default:
         return Container();
     }

+ 95 - 128
lib/view/mobile_view/mobile_right_panel/mobile_annotation_tool.dart

@@ -1,149 +1,116 @@
-import 'package:fis_measure/interfaces/process/items/item_metas.dart';
-import 'package:fis_measure/interfaces/process/items/types.dart';
-import 'package:fis_measure/process/workspace/measure_3d_view_controller.dart';
-import 'package:fis_measure/view/measure/measure_tool.dart';
+import 'package:fis_measure/interfaces/enums/annotation.dart';
+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_ui/index.dart';
 import 'package:flutter/material.dart';
 import 'package:get/get.dart';
-import 'package:vid/us/vid_us_unit.dart';
 
-/// 移动端测量项选择器(继承自 测量项页面)
-class MobileAnnotationSelector extends LeftSiderSelectMeasure {
+/// 注释项
+///
+// ignore: must_be_immutable
+class MobileAnnotationSelector extends StatefulWidget implements FWidget {
   const MobileAnnotationSelector({Key? key}) : super(key: key);
-
   @override
-  FState<LeftSiderSelectMeasure> createState() => _MobileAnnotationSelector();
+  State<StatefulWidget> createState() => _MobileAnnotationSelectorState();
 }
 
-class _MobileAnnotationSelector extends LeftSiderSelectMeasureState {
-  late final measure3DViewController = Get.find<Measure3DViewController>();
+class _MobileAnnotationSelectorState extends State<MobileAnnotationSelector> {
+  // ignore: non_constant_identifier_names
+  // static final C_SUPPORTED_TEXTS = measureData.getCommentsList;
+
+  final scrollController = ScrollController();
+  final application = Get.find<IApplication>();
+  late final measureHandler = Get.find<MeasureHandler>();
 
-  /// 写死的移动端测量项
-  List<MobileMeasureBtn> mobileMeasureBtnList = [
-    MobileMeasureBtn(
-      icon: Icons.linear_scale,
-      displayName: '距离',
-      itemMeta: ItemMeta(
-        MeasureTypes.Distance,
-        measureType: MeasureTypes.Distance,
-        description: MeasureTypes.Distance,
-        briefAnnotation: "D",
-        outputs: [
-          ItemOutputMeta(MeasureTypes.Distance, "Distance", VidUsUnit.cm),
-        ],
-      ),
-    ),
-    MobileMeasureBtn(
-      icon: Icons.border_style,
-      displayName: '周长',
-      itemMeta: ItemMeta(
-        MeasureTypes.Perimeter,
-        measureType: MeasureTypes.Perimeter,
-        description: MeasureTypes.Perimeter,
-        briefAnnotation: "P",
-        outputs: [
-          ItemOutputMeta(MeasureTypes.Perimeter, "Perimeter", VidUsUnit.cm),
-        ],
-      ),
-    ),
-    MobileMeasureBtn(
-      icon: Icons.format_shapes,
-      displayName: '面积',
-      itemMeta: ItemMeta(
-        MeasureTypes.Area,
-        measureType: MeasureTypes.Area,
-        description: MeasureTypes.Area,
-        briefAnnotation: "A",
-        outputs: [
-          ItemOutputMeta(MeasureTypes.Area, "Area", VidUsUnit.cm2),
-        ],
-      ),
-    ),
-  ];
+  /// 数据
+  late final measureData = Get.find<MeasureDataController>();
 
   @override
-  FWidget build(BuildContext context) {
-    return FSizedBox(
-      width: 100,
-      height: 320,
-      child: FColumn(
-          mainAxisAlignment: MainAxisAlignment.center,
-          mainAxisSize: MainAxisSize.max,
-          children: [
-            const FSizedBox(height: 30),
-            ...mobileMeasureBtnList.map((e) {
-              return _buildMeasureBtn(e.itemMeta, e.itemMeta.name == activeName,
-                  e.displayName, e.icon);
-            }).toList(),
-          ]),
-    );
+  void initState() {
+    // application.switchAnnotation(
+    //     AnnotationType.label, measureData.getCommentsList[0]);
+    super.initState();
+  }
+
+  @override
+  void dispose() {
+    super.dispose();
   }
 
-  FWidget _buildMeasureBtn(
-      ItemMeta itemMeta, bool ifActive, String displayName, IconData icon) {
-    return FInkWell(
-      onTap: () {
-        if (ifActive) {
-          changeItem(
-            ItemMeta(
-              "None",
-              description: "None",
-              outputs: [
-                ItemOutputMeta("None", "None", VidUsUnit.cm2),
-              ],
+  @override
+  Widget build(BuildContext context) {
+    return Column(
+      children: [
+        const SizedBox(
+          height: 50,
+        ),
+        SizedBox(
+          width: 150,
+          height: 300,
+          child: Scrollbar(
+            controller: scrollController,
+            isAlwaysShown: true,
+            child: GridView.count(
+              controller: scrollController,
+              crossAxisCount: 1,
+              childAspectRatio: 3,
+              children: measureData.getCommentsList.map((e) {
+                return _buildNoteTools(e);
+              }).toList(),
             ),
-          );
-        } else {
-          changeItem(itemMeta);
-        }
-      },
-      child: Container(
-        margin: const EdgeInsets.fromLTRB(0, 10, 10, 10),
-        padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
-        decoration: ifActive
-            ? BoxDecoration(
-                border: Border.all(color: Colors.grey),
-                borderRadius: BorderRadiusGeometry.lerp(
-                    BorderRadius.circular(10), BorderRadius.circular(10), 10),
-              )
-            : BoxDecoration(
-                border: Border.all(color: Colors.transparent),
-                borderRadius: BorderRadiusGeometry.lerp(
-                    BorderRadius.circular(10), BorderRadius.circular(10), 10),
+          ),
+        ),
+      ],
+    );
+  }
+
+  Widget _buildNoteTools(String tools) {
+    const style = TextStyle(color: Colors.white, fontSize: 12);
+    const dragStyle = TextStyle(color: Colors.amber, fontSize: 12);
+    return Row(
+      mainAxisSize: MainAxisSize.max,
+      children: [
+        Draggable<String>(
+          data: tools,
+          dragAnchorStrategy: (data, context, offset) {
+            return const Offset(100, 50);
+          },
+          child: const Icon(
+            Icons.drag_indicator,
+            color: Colors.grey,
+          ),
+          feedback: Material(
+            color: Colors.transparent,
+            child: Text(tools, style: dragStyle),
+          ),
+          onDragStarted: () {
+            measureHandler.changedAnnotationType = AnnotationType.label;
+            application.switchAnnotation(AnnotationType.label, tools);
+          },
+        ),
+        Expanded(
+          child: OutlinedButton(
+            child: Text(tools, style: style),
+            onPressed: () {
+              PromptBox.toast('拖动添加');
+            },
+            style: OutlinedButton.styleFrom(
+              shape: RoundedRectangleBorder(
+                borderRadius: BorderRadius.circular(4),
               ),
-        child: FColumn(
-          children: [
-            const FSizedBox(
-              height: 10,
-            ),
-            FIcon(
-              icon,
-              color: ifActive
-                  ? Colors.white
-                  : const Color.fromARGB(255, 124, 124, 124),
-            ),
-            FText(
-              displayName,
-              style: TextStyle(
-                color: ifActive
-                    ? Colors.white
-                    : const Color.fromARGB(255, 124, 124, 124),
+              side: const BorderSide(
+                color: Color.fromRGBO(124, 124, 124, 1),
               ),
+              fixedSize: const Size.fromHeight(40),
             ),
-            const FSizedBox(
-              height: 10,
-            ),
-          ],
+          ),
+        ),
+        const FSizedBox(
+          width: 12,
         ),
-      ),
+      ],
     );
   }
 }
-
-class MobileMeasureBtn {
-  ItemMeta itemMeta;
-  String displayName;
-  IconData icon;
-  MobileMeasureBtn(
-      {required this.itemMeta, required this.displayName, required this.icon});
-}

+ 95 - 9
pubspec.lock

@@ -140,8 +140,8 @@ packages:
     dependency: "direct main"
     description:
       path: "."
-      ref: "7965aef"
-      resolved-ref: "7965aef6ad94b2b58744e63ea5072d594ac4775c"
+      ref: e6224fc
+      resolved-ref: e6224fce7a92d708135f43a3625e5c10086d45cb
       url: "http://git.ius.plus:88/Project-Wing/fis_lib_i18n.git"
     source: git
     version: "0.0.1"
@@ -149,8 +149,8 @@ packages:
     dependency: "direct main"
     description:
       path: "."
-      ref: "4a9569e"
-      resolved-ref: "4a9569e000e29ce50501d404d5e1b2254278be05"
+      ref: a2f6096
+      resolved-ref: a2f6096fae1d034202661cb631f6c9d9c6ef0227
       url: "http://git.ius.plus:88/Project-Wing/fis_lib_jsonrpc.git"
     source: git
     version: "0.0.1"
@@ -158,11 +158,20 @@ packages:
     dependency: "direct overridden"
     description:
       path: "."
-      ref: a0586aa
-      resolved-ref: a0586aa6b2d8454000d4aec0e2a61b9df765a9d3
+      ref: c67e307
+      resolved-ref: c67e307036b5e0ca4a8b4830e48e883d8a7ce78e
       url: "http://git.ius.plus/bakamaka.guan/fis_lib_business_components.git"
     source: git
     version: "0.0.1"
+  fis_lib_qrcode:
+    dependency: "direct overridden"
+    description:
+      path: "."
+      ref: f7fd36ad46
+      resolved-ref: f7fd36ad46057c8d6d1dc1fa5d41ee3d9fa21a78
+      url: "http://git.ius.plus/jimmy.jiang/fis_lib_qrcode.git"
+    source: git
+    version: "4.0.1"
   fis_theme:
     dependency: transitive
     description:
@@ -176,8 +185,8 @@ packages:
     dependency: "direct main"
     description:
       path: "."
-      ref: "46c75c6"
-      resolved-ref: "46c75c60f73150519bca8353f01d79a9033af12c"
+      ref: "92fdd3c"
+      resolved-ref: "92fdd3c96f94215ef8649b6ab27167b9f6417692"
       url: "http://git.ius.plus/Project-Wing/fis_lib_ui.git"
     source: git
     version: "0.0.1"
@@ -204,6 +213,13 @@ packages:
     description: flutter
     source: sdk
     version: "0.0.0"
+  flutter_easyloading:
+    dependency: "direct main"
+    description:
+      name: flutter_easyloading
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "3.0.3"
   flutter_keyboard_visibility:
     dependency: transitive
     description:
@@ -239,6 +255,13 @@ packages:
       url: "https://pub.flutter-io.cn"
     source: hosted
     version: "1.2.0"
+  flutter_spinkit:
+    dependency: transitive
+    description:
+      name: flutter_spinkit
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "5.1.0"
   flutter_test:
     dependency: "direct dev"
     description: flutter
@@ -445,6 +468,13 @@ packages:
       url: "https://pub.flutter-io.cn"
     source: hosted
     version: "4.2.4"
+  qr:
+    dependency: transitive
+    description:
+      name: qr
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "3.0.1"
   quiver:
     dependency: "direct main"
     description:
@@ -513,6 +543,62 @@ packages:
       url: "https://pub.flutter-io.cn"
     source: hosted
     version: "1.3.0"
+  url_launcher:
+    dependency: "direct main"
+    description:
+      name: url_launcher
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "6.1.5"
+  url_launcher_android:
+    dependency: transitive
+    description:
+      name: url_launcher_android
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "6.0.19"
+  url_launcher_ios:
+    dependency: transitive
+    description:
+      name: url_launcher_ios
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "6.0.17"
+  url_launcher_linux:
+    dependency: transitive
+    description:
+      name: url_launcher_linux
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "3.0.1"
+  url_launcher_macos:
+    dependency: transitive
+    description:
+      name: url_launcher_macos
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "3.0.1"
+  url_launcher_platform_interface:
+    dependency: transitive
+    description:
+      name: url_launcher_platform_interface
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "2.1.0"
+  url_launcher_web:
+    dependency: transitive
+    description:
+      name: url_launcher_web
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "2.0.13"
+  url_launcher_windows:
+    dependency: transitive
+    description:
+      name: url_launcher_windows
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "3.0.1"
   uuid:
     dependency: transitive
     description:
@@ -600,5 +686,5 @@ packages:
     source: hosted
     version: "5.3.1"
 sdks:
-  dart: ">=2.15.1 <3.0.0"
+  dart: ">=2.16.0 <3.0.0"
   flutter: ">=2.10.0"