From de341d4ffed7f82be2a1eae8769fb90585a8cc73 Mon Sep 17 00:00:00 2001 From: HuyNguyen Date: Thu, 25 May 2023 10:08:10 +0700 Subject: [PATCH] TF-1862: Add ADR for ticket about how to use Draggable on the web (cherry picked from commit 8e4f767625ee12a3290223beec5cdfc4cf141b9c) --- ...-of-draggable-when-click-right-on-email.md | 49 +++++++++++++++++++ .../thread/presentation/thread_view.dart | 5 +- 2 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 docs/adr/0029-fix-show-widget-of-draggable-when-click-right-on-email.md diff --git a/docs/adr/0029-fix-show-widget-of-draggable-when-click-right-on-email.md b/docs/adr/0029-fix-show-widget-of-draggable-when-click-right-on-email.md new file mode 100644 index 000000000..6a0c34ed6 --- /dev/null +++ b/docs/adr/0029-fix-show-widget-of-draggable-when-click-right-on-email.md @@ -0,0 +1,49 @@ +# 29. Fix show widget of Draggable when click right on email + +Date: 2023-05-24 + +## Status + +- Issue: [#1743](https://github.com/linagora/tmail-flutter/issues/1862) + +## Context + +When user click right on email, the feedback widget of Draggable will show. + +## Root cause + +The childWhenDragging widget will still be draggable, including the ability to trigger the right-click event. +This is because the childWhenDragging widget is a part of the draggable behavior and inherits the drag-related properties and behaviors from the Draggable widget. +The Draggable widget allows you to customize the appearance and behavior of the dragged item during the dragging process by providing the feedback and childWhenDragging properties. +The feedback widget is used to display a visual representation of the dragged item, while the childWhenDragging widget is used to replace the original item when it is being dragged. + + +## Decision + +Wrap it with a GestureDetector and handle the right-click event as mentioned in the previous answer. This way, you can have separate behavior for the original item and the item being dragged. + +``` + GestureDetector( + behavior: HitTestBehavior.translucent, + onSecondaryTapDown: (details) { + // 1. Use empty callback to disable D&D on mouse right button + // 2. Call `showMenu` to show context menu + }, + child: Draggable>( + data: controller.listEmailDrag, + feedback: _buildFeedBackWidget(context), + childWhenDragging: _buildEmailItemWhenDragging(context, presentationEmail), + dragAnchorStrategy: pointerDragAnchorStrategy, + onDragStarted: () { + controller.calculateDragValue(presentationEmail); + controller.onDragMailBox(true); + }, + onDragEnd: (_) => controller.onDragMailBox(false), + onDraggableCanceled: (_,__) => controller.onDragMailBox(false), + child: _buildEmailItemNotDraggable(context, presentationEmail) + ), + ); +``` +## Consequences + +- Do not show the move dialog at all when I right click diff --git a/lib/features/thread/presentation/thread_view.dart b/lib/features/thread/presentation/thread_view.dart index 00c48b15f..5e0cd2f52 100644 --- a/lib/features/thread/presentation/thread_view.dart +++ b/lib/features/thread/presentation/thread_view.dart @@ -360,10 +360,7 @@ class ThreadView extends GetWidget Widget _buildEmailItemDraggable(BuildContext context, PresentationEmail presentationEmail) { return GestureDetector( behavior: HitTestBehavior.translucent, - onSecondaryTapDown: (details) { - // 1. Use empty callback to disable D&D on mouse right button - // 2. Call `showMenu` to show context menu - }, + onSecondaryTapDown: (_) {}, child: Draggable>( data: controller.listEmailDrag, feedback: _buildFeedBackWidget(context),