瀏覽代碼

Add long-press action for menu item

vishnukvmd 2 年之前
父節點
當前提交
827375fb08
共有 1 個文件被更改,包括 6 次插入1 次删除
  1. 6 1
      lib/ui/components/menu_item_widget/menu_item_widget.dart

+ 6 - 1
lib/ui/components/menu_item_widget/menu_item_widget.dart

@@ -31,6 +31,7 @@ class MenuItemWidget extends StatefulWidget {
   final double trailingExtraMargin;
   final FutureVoidCallback? onTap;
   final VoidCallback? onDoubleTap;
+  final VoidCallback? onLongPress;
   final Color? menuItemColor;
   final bool alignCaptionedTextToLeft;
 
@@ -74,6 +75,7 @@ class MenuItemWidget extends StatefulWidget {
     this.trailingExtraMargin = 0.0,
     this.onTap,
     this.onDoubleTap,
+    this.onLongPress,
     this.menuItemColor,
     this.alignCaptionedTextToLeft = false,
     this.singleBorderRadius = 4.0,
@@ -144,6 +146,7 @@ class _MenuItemWidgetState extends State<MenuItemWidget> {
         : GestureDetector(
             onTap: _onTap,
             onDoubleTap: widget.onDoubleTap,
+            onLongPress: widget.onLongPress,
             onTapDown: _onTapDown,
             onTapUp: _onTapUp,
             onTapCancel: _onCancel,
@@ -260,7 +263,9 @@ class _MenuItemWidgetState extends State<MenuItemWidget> {
   }
 
   bool hasPassedGestureCallbacks() {
-    return widget.onDoubleTap != null || widget.onTap != null;
+    return widget.onDoubleTap != null ||
+        widget.onTap != null ||
+        widget.onLongPress != null;
   }
 
   void _onTapUp(details) {