12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- import 'package:fis_i18n/i18n.dart';
- import 'package:fis_measure/interfaces/process/workspace/application.dart';
- import 'package:fis_measure/process/workspace/measure_data_controller.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';
- class DragDeleteArea extends FStatefulWidget {
- const DragDeleteArea({Key? key}) : super(key: key);
- @override
- FState<DragDeleteArea> createState() => DragDeleteAreaState();
- }
- class DragDeleteAreaState extends FState<DragDeleteArea> {
- final measureData = Get.find<MeasureDataController>();
- bool _isDragOn = false;
- @override
- void initState() {
- super.initState();
- }
- @override
- void dispose() {
- super.dispose();
- }
- @override
- FWidget build(BuildContext context) {
- return FDragTarget<String>(
- onAccept: (data) async {
- measureData.annotationList.remove(data);
- final application = Get.find<IApplication>();
- final result = await measureData.deleteAnnotation(application, data);
- if (result ?? false) {
- PromptBox.toast(i18nBook.measure.annotationDeleted.translate([data]));
- }
- setState(() {
- _isDragOn = false;
- });
- },
- onWillAccept: (data) {
- setState(() {
- _isDragOn = true;
- });
- return true;
- },
- onLeave: (data) {
- setState(() {
- _isDragOn = false;
- });
- },
- builder: (context, candidateData, rejectedData) {
- return FContainer(
- width: 300,
- height: 50,
- padding: const EdgeInsets.only(left: 10, top: 5, bottom: 5),
- child: FContainer(
- decoration: BoxDecoration(
- color: const Color.fromARGB(255, 243, 108, 99),
- borderRadius: BorderRadius.circular(5),
- ),
- child: FCenter(
- child:
- FRow(mainAxisAlignment: MainAxisAlignment.center, children: [
- const FIcon(
- Icons.delete,
- color: Colors.white,
- ),
- FText(
- _isDragOn
- ? i18nBook.measure.releaseToDelete.t
- : i18nBook.measure.dragHereToDelete.t,
- textAlign: TextAlign.center,
- style: const TextStyle(color: Colors.white),
- ),
- ]),
- ),
- ),
- );
- },
- );
- }
- }
|