can open the item menu on the right click for requests

This commit is contained in:
Clement
2024-10-05 23:08:39 -03:00
parent 04b486d198
commit 4c3002c20b
2 changed files with 103 additions and 72 deletions

View File

@ -49,81 +49,86 @@ class SidebarRequestCard extends StatelessWidget {
String nm = (name != null && name!.trim().isNotEmpty) String nm = (name != null && name!.trim().isNotEmpty)
? name! ? name!
: getRequestTitleFromUrl(url); : getRequestTitleFromUrl(url);
return Tooltip( return GestureDetector(
message: nm, onSecondaryTapUp: (details) {
triggerMode: TooltipTriggerMode.manual, showItemCardMenu(context, details, onMenuSelected);
waitDuration: const Duration(seconds: 1), },
child: Card( child: Tooltip(
shape: const RoundedRectangleBorder( message: nm,
borderRadius: kBorderRadius8, triggerMode: TooltipTriggerMode.manual,
), waitDuration: const Duration(seconds: 1),
elevation: isSelected ? 1 : 0, child: Card(
surfaceTintColor: isSelected ? surfaceTint : null, shape: const RoundedRectangleBorder(
color: isSelected borderRadius: kBorderRadius8,
? Theme.of(context).colorScheme.brightness == Brightness.dark ),
? colorVariant elevation: isSelected ? 1 : 0,
: color surfaceTintColor: isSelected ? surfaceTint : null,
: color, color: isSelected
margin: EdgeInsets.zero, ? Theme.of(context).colorScheme.brightness == Brightness.dark
child: InkWell( ? colorVariant
borderRadius: kBorderRadius8, : color
hoverColor: colorVariant, : color,
focusColor: colorVariant.withOpacity(0.5), margin: EdgeInsets.zero,
onTap: inEditMode ? null : onTap, child: InkWell(
// onDoubleTap: inEditMode ? null : onDoubleTap, borderRadius: kBorderRadius8,
onSecondaryTap: onSecondaryTap, hoverColor: colorVariant,
child: Padding( focusColor: colorVariant.withOpacity(0.5),
padding: EdgeInsets.only( onTap: inEditMode ? null : onTap,
left: 6, // onDoubleTap: inEditMode ? null : onDoubleTap,
right: isSelected ? 6 : 10, onSecondaryTap: onSecondaryTap,
top: 5, child: Padding(
bottom: 5, padding: EdgeInsets.only(
), left: 6,
child: SizedBox( right: isSelected ? 6 : 10,
height: 20, top: 5,
child: Row( bottom: 5,
children: [ ),
MethodBox(method: method), child: SizedBox(
kHSpacer4, height: 20,
Expanded( child: Row(
child: inEditMode children: [
? TextFormField( MethodBox(method: method),
key: ValueKey("$id-name"), kHSpacer4,
initialValue: name, Expanded(
// controller: controller, child: inEditMode
focusNode: focusNode, ? TextFormField(
//autofocus: true, key: ValueKey("$id-name"),
style: Theme.of(context).textTheme.bodyMedium, initialValue: name,
onTapOutside: (_) { // controller: controller,
onTapOutsideNameEditor?.call(); focusNode: focusNode,
//FocusScope.of(context).unfocus(); //autofocus: true,
}, style: Theme.of(context).textTheme.bodyMedium,
onFieldSubmitted: (value) { onTapOutside: (_) {
onTapOutsideNameEditor?.call(); onTapOutsideNameEditor?.call();
}, //FocusScope.of(context).unfocus();
onChanged: onChangedNameEditor, },
decoration: const InputDecoration( onFieldSubmitted: (value) {
isCollapsed: true, onTapOutsideNameEditor?.call();
contentPadding: EdgeInsets.zero, },
border: InputBorder.none, onChanged: onChangedNameEditor,
decoration: const InputDecoration(
isCollapsed: true,
contentPadding: EdgeInsets.zero,
border: InputBorder.none,
),
)
: Text(
nm,
softWrap: false,
overflow: TextOverflow.fade,
), ),
) ),
: Text( Visibility(
nm, visible: isSelected && !inEditMode,
softWrap: false, child: SizedBox(
overflow: TextOverflow.fade, width: 28,
), child: ItemCardMenu(
), onSelected: onMenuSelected,
Visibility( ),
visible: isSelected && !inEditMode,
child: SizedBox(
width: 28,
child: ItemCardMenu(
onSelected: onMenuSelected,
), ),
), ),
), ],
], ),
), ),
), ),
), ),

View File

@ -41,3 +41,29 @@ class ItemCardMenu extends StatelessWidget {
); );
} }
} }
/// Open the item card menu where the right click has been released
Future<void> showItemCardMenu(
BuildContext context,
TapUpDetails details,
Function(ItemMenuOption)? onSelected,
) async {
showMenu(
context: context,
position: RelativeRect.fromLTRB(
details.globalPosition.dx,
details.globalPosition.dy,
details.globalPosition.dx,
details.globalPosition.dy,
),
items: ItemMenuOption.values
.map<PopupMenuEntry<ItemMenuOption>>(
(e) => PopupMenuItem<ItemMenuOption>(
onTap: () => onSelected?.call(e),
value: e,
child: Text(e.label),
),
)
.toList(),
);
}