forked from Henry-Hiles/nexus
move showContextMenu to extension
This commit is contained in:
parent
5dc8fe14bd
commit
b9bc345b56
2 changed files with 38 additions and 37 deletions
35
lib/helpers/extensions/show_context_menu.dart
Normal file
35
lib/helpers/extensions/show_context_menu.dart
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import "package:flutter/material.dart";
|
||||
|
||||
extension ShowContextMenu on BuildContext {
|
||||
void showContextMenu({
|
||||
required Offset globalPosition,
|
||||
required VoidCallback onTap,
|
||||
}) {
|
||||
final overlay = Overlay.of(this).context.findRenderObject() as RenderBox;
|
||||
|
||||
showMenu(
|
||||
context: this,
|
||||
position: RelativeRect.fromLTRB(
|
||||
globalPosition.dx,
|
||||
globalPosition.dy,
|
||||
overlay.size.width - globalPosition.dx,
|
||||
overlay.size.height - globalPosition.dy,
|
||||
),
|
||||
color: Theme.of(this).colorScheme.surfaceContainerHighest,
|
||||
items: [
|
||||
PopupMenuItem(
|
||||
onTap: onTap,
|
||||
child: ListTile(leading: Icon(Icons.reply), title: Text("Reply")),
|
||||
),
|
||||
PopupMenuItem(
|
||||
onTap: onTap,
|
||||
child: ListTile(leading: Icon(Icons.edit), title: Text("Edit")),
|
||||
),
|
||||
PopupMenuItem(
|
||||
onTap: onTap,
|
||||
child: ListTile(leading: Icon(Icons.delete), title: Text("Delete")),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue