mirror of
https://github.com/foss42/apidash.git
synced 2025-05-26 02:36:31 +08:00
can open the item menu on the right click for requests
This commit is contained in:
@ -49,7 +49,11 @@ class SidebarRequestCard extends StatelessWidget {
|
||||
String nm = (name != null && name!.trim().isNotEmpty)
|
||||
? name!
|
||||
: getRequestTitleFromUrl(url);
|
||||
return Tooltip(
|
||||
return GestureDetector(
|
||||
onSecondaryTapUp: (details) {
|
||||
showItemCardMenu(context, details, onMenuSelected);
|
||||
},
|
||||
child: Tooltip(
|
||||
message: nm,
|
||||
triggerMode: TooltipTriggerMode.manual,
|
||||
waitDuration: const Duration(seconds: 1),
|
||||
@ -129,6 +133,7 @@ class SidebarRequestCard extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -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(),
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user