feat: Add long press functionality to menu items for category editing

This commit is contained in:
2026-05-22 10:54:56 +02:00
parent e0f226d3bc
commit 2069de55ae
+10 -5
View File
@@ -56,10 +56,12 @@ 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(
trailing: IconButton(
padding: const EdgeInsets.all(8),
constraints: const BoxConstraints(
minWidth: 0,
@@ -71,8 +73,7 @@ class MenuDrawer extends StatelessWidget {
size: 20,
),
onPressed: () => onEditCategory?.call(category),
)
: null,
),
);
}).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,
),
),
),