12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- 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 'input_position_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();
- // // 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();
- }
- final type = currentItem!.type;
- switch (type) {
- case AnnotationType.label:
- return const AnnotationLabelDragTargetPanel();
- case AnnotationType.input:
- return const AnnotationInputPositionPanel();
- case AnnotationType.arrow:
- return const AnnotationArrowGesturePanel();
- }
- }
- }
|