feat: Add long press functionality to menu items for category editing
This commit is contained in:
@@ -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,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user