12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import 'package:fis_measure/interfaces/enums/annotation.dart';
- import 'package:fis_measure/interfaces/process/annotations/annotation.dart';
- import 'package:fis_measure/interfaces/process/workspace/application.dart';
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
- import '../positioned_cursor.dart';
- import 'arrow_gesture_panel.dart';
- import 'label_drag_target_pannel.dart';
- /// 移动端注释手势层
- class AnnotationTouchLayer extends StatefulWidget {
- const AnnotationTouchLayer({Key? key}) : super(key: key);
- @override
- State<AnnotationTouchLayer> createState() => _AnnotationTouchLayerState();
- }
- class _AnnotationTouchLayerState extends State<AnnotationTouchLayer> {
- late final application = Get.find<IApplication>();
- final mouseState = Get.put<IMouseState>(MouseState());
- IAnnotationItem? currentItem;
- @override
- void initState() {
- currentItem = application.activeAnnotationItem;
- application.activeAnnotationItemChanged.addListener(_onItemChanged);
- super.initState();
- }
- @override
- void dispose() {
- application.activeAnnotationItemChanged.removeListener(_onItemChanged);
- super.dispose();
- }
- void _onItemChanged(Object sender, IAnnotationItem? item) {
- if (!mounted) return;
- if (item?.type != currentItem?.type) {
- setState(() {
- currentItem = item;
- });
- } else {
- currentItem = item;
- }
- }
- @override
- Widget build(BuildContext context) {
- return _buildItemPanel();
- }
- Widget _buildItemPanel() {
- if (currentItem == null) {
- return const SizedBox();
- }
- final type = currentItem!.type;
- switch (type) {
- case AnnotationType.label:
- return const AnnotationLabelDragTargetPanel();
- case AnnotationType.input:
- return Container();
- case AnnotationType.arrow:
- return const AnnotationArrowGesturePanel();
- }
- }
- }
|