123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- 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_ui/index.dart';
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
- /// 注释项
- ///
- // ignore: must_be_immutable
- class MeasureLeftAnnotation extends StatefulWidget implements FWidget {
- const MeasureLeftAnnotation({Key? key}) : super(key: key);
- @override
- State<StatefulWidget> createState() => _MeasureLeftAnnotationState();
- }
- class _MeasureLeftAnnotationState extends State<MeasureLeftAnnotation> {
- // ignore: non_constant_identifier_names
- // static final C_SUPPORTED_TEXTS = measureData.annotationList;
- final scrollController = ScrollController();
- final application = Get.find<IApplication>();
- late final measureHandler = Get.find<MeasureHandler>();
- /// 数据
- late final measureData = Get.find<MeasureDataController>();
- void annotationListChanged(sender, e) {
- setState(() {});
- }
- @override
- void initState() {
- measureData.annotationListChanged.addListener(annotationListChanged);
- super.initState();
- }
- @override
- void dispose() {
- measureData.annotationListChanged.removeListener(annotationListChanged);
- super.dispose();
- }
- @override
- Widget build(BuildContext context) {
- return SizedBox(
- width: 300,
- child: Scrollbar(
- controller: scrollController,
- thumbVisibility: true,
- child: GridView.count(
- controller: scrollController,
- crossAxisCount: 2,
- childAspectRatio: 3,
- children: measureData.annotationList.map((e) {
- return _buildAnnotationTools(e);
- }).toList(),
- ),
- ),
- );
- }
- Widget _buildAnnotationTools(String tools) {
- const style = TextStyle(color: Colors.white, fontSize: 14);
- const dragStyle = TextStyle(color: Colors.amber, fontSize: 18);
- return Row(
- mainAxisSize: MainAxisSize.max,
- children: [
- const FSizedBox(
- width: 12,
- ),
- Expanded(
- child: Draggable<String>(
- data: tools,
- dragAnchorStrategy: (data, context, offset) {
- return Offset.zero;
- },
- child: OutlinedButton(
- child: Text(tools, style: style),
- onPressed: () {
- measureHandler.changedAnnotationType = AnnotationType.label;
- application.switchAnnotation(AnnotationType.label, tools);
- },
- style: OutlinedButton.styleFrom(
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(4),
- ),
- side: const BorderSide(
- color: Color.fromRGBO(124, 124, 124, 1),
- ),
- fixedSize: const Size.fromHeight(40),
- ),
- ),
- feedback: Material(
- color: Colors.transparent,
- child: Text(tools, style: dragStyle),
- ),
- onDragStarted: () {
- measureHandler.changedAnnotationType = AnnotationType.label;
- measureHandler.onDragStateChanged.emit(this, true);
- application.switchAnnotation(AnnotationType.label, tools);
- },
- onDragEnd: (details) {
- measureHandler.onDragStateChanged.emit(this, false);
- },
- onDragCompleted: () {
- measureHandler.onDragStateChanged.emit(this, false);
- },
- onDraggableCanceled: (velocity, offset) {
- measureHandler.onDragStateChanged.emit(this, false);
- },
- ),
- ),
- const FSizedBox(
- width: 12,
- ),
- ],
- );
- }
- }
|