From 2069de55ae70ae4fceaefa6c3999c96f3ca3bc55 Mon Sep 17 00:00:00 2001 From: Marcos Date: Fri, 22 May 2026 10:54:56 +0200 Subject: [PATCH] feat: Add long press functionality to menu items for category editing --- lib/widgets/menu_drawer.dart | 37 ++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/lib/widgets/menu_drawer.dart b/lib/widgets/menu_drawer.dart index 397860f..8038279 100644 --- a/lib/widgets/menu_drawer.dart +++ b/lib/widgets/menu_drawer.dart @@ -56,23 +56,24 @@ class MenuDrawer extends StatelessWidget { label: category.name, selected: selectedItem == categoryId, onTap: () => onMenuItemTapped?.call(categoryId), + onLongPress: onEditCategory == null + ? null + : () => onEditCategory?.call(category), iconColor: Color(category.colorValue ?? 0xFFFFC107), textColor: Color(category.colorValue ?? 0xFFFFC107), - trailing: selectedItem == categoryId - ? IconButton( - padding: const EdgeInsets.all(8), - constraints: const BoxConstraints( - minWidth: 0, - minHeight: 0, - ), - icon: const Icon( - Icons.more_vert, - color: Colors.white70, - size: 20, - ), - onPressed: () => onEditCategory?.call(category), - ) - : null, + trailing: IconButton( + padding: const EdgeInsets.all(8), + constraints: const BoxConstraints( + minWidth: 0, + minHeight: 0, + ), + icon: const Icon( + Icons.more_vert, + color: Colors.white70, + size: 20, + ), + onPressed: () => onEditCategory?.call(category), + ), ); }).toList(), ), @@ -113,6 +114,7 @@ class _MenuItemTile extends StatefulWidget { required this.label, this.selected = false, this.onTap, + this.onLongPress, this.iconColor, this.textColor, this.trailing, @@ -122,6 +124,7 @@ class _MenuItemTile extends StatefulWidget { final String label; final bool selected; final VoidCallback? onTap; + final VoidCallback? onLongPress; final Color? iconColor; final Color? textColor; final Widget? trailing; @@ -140,6 +143,7 @@ class _MenuItemTileState extends State<_MenuItemTile> { ? Colors.white.withValues(alpha: 0.10) : Colors.transparent; final Color foregroundColor = active ? Colors.white : Colors.white70; + final Widget? trailing = _hovering ? widget.trailing : null; return MouseRegion( onEnter: (_) { @@ -166,12 +170,13 @@ class _MenuItemTileState extends State<_MenuItemTile> { child: ListTile( contentPadding: const EdgeInsets.only(left: 16, right: 8), leading: Icon(widget.icon, color: widget.iconColor ?? foregroundColor), - trailing: widget.trailing, + trailing: trailing, title: Text( widget.label, style: TextStyle(color: widget.textColor ?? foregroundColor, fontSize: 14), ), onTap: widget.onTap, + onLongPress: widget.onLongPress, ), ), ),