Adjust Scribe context menu to support tablet screens
- Support tap in addition to hover for context menu - Improve clamping for greater screen sizes to avoid Scribe getting off screen - Set a padding to 0 to avoid random padding depending on screen sizes
This commit is contained in:
@@ -154,10 +154,14 @@ class AnchoredModalLayoutCalculator {
|
||||
if (isTop) {
|
||||
final availableHeight = anchorPosition.dy - padding - gap;
|
||||
final positionBottom = screenSize.height - anchorPosition.dy + gap;
|
||||
final clampedLeft = anchorPosition.dx.clamp(
|
||||
padding,
|
||||
screenSize.width - menuSize.width - padding,
|
||||
);
|
||||
|
||||
return AnchoredSuggestionLayoutResult(
|
||||
availableHeight: availableHeight,
|
||||
left: anchorPosition.dx,
|
||||
left: clampedLeft,
|
||||
bottom: positionBottom,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ class _AiScribeContextMenuContentState extends State<AiScribeContextMenu> {
|
||||
widget.submenuController?.hide();
|
||||
widget.onActionSelected(menuAction);
|
||||
},
|
||||
onHoverShowSubmenu: (itemKey) =>
|
||||
onSelectCategory: (itemKey) =>
|
||||
menuAction.submenuActions?.isNotEmpty == true
|
||||
? _showSubmenu(
|
||||
context: context,
|
||||
|
||||
+12
-4
@@ -6,7 +6,7 @@ class AiScribeContextMenuItem extends StatefulWidget {
|
||||
final AiScribeContextMenuAction menuAction;
|
||||
final ImagePaths imagePaths;
|
||||
final ValueChanged<AiScribeContextMenuAction> onSelectAction;
|
||||
final OnHoverShowSubmenu? onHoverShowSubmenu;
|
||||
final OnHoverShowSubmenu onSelectCategory;
|
||||
final VoidCallback? onHoverOtherItem;
|
||||
|
||||
const AiScribeContextMenuItem({
|
||||
@@ -14,7 +14,7 @@ class AiScribeContextMenuItem extends StatefulWidget {
|
||||
required this.menuAction,
|
||||
required this.imagePaths,
|
||||
required this.onSelectAction,
|
||||
this.onHoverShowSubmenu,
|
||||
required this.onSelectCategory,
|
||||
this.onHoverOtherItem,
|
||||
});
|
||||
|
||||
@@ -44,7 +44,7 @@ class _AiScribeContextMenuItemState extends State<AiScribeContextMenuItem> {
|
||||
_hoverController?.enter();
|
||||
|
||||
if (_itemKey != null) {
|
||||
widget.onHoverShowSubmenu?.call(_itemKey!);
|
||||
widget.onSelectCategory.call(_itemKey!);
|
||||
} else {
|
||||
widget.onHoverOtherItem?.call();
|
||||
}
|
||||
@@ -55,7 +55,15 @@ class _AiScribeContextMenuItemState extends State<AiScribeContextMenuItem> {
|
||||
child: AiScribeMenuItem(
|
||||
itemKey: _itemKey,
|
||||
menuAction: widget.menuAction,
|
||||
onSelectAction: widget.onSelectAction,
|
||||
onSelectAction: (menuAction) {
|
||||
if (menuAction.submenuActions?.isNotEmpty == true) {
|
||||
if (_itemKey != null) {
|
||||
widget.onSelectCategory.call(_itemKey!);
|
||||
}
|
||||
} else {
|
||||
widget.onSelectAction(menuAction);
|
||||
}
|
||||
},
|
||||
imagePaths: widget.imagePaths,
|
||||
)
|
||||
);
|
||||
|
||||
@@ -24,6 +24,7 @@ class AiScribeSubmenu extends StatelessWidget {
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
padding: EdgeInsets.zero,
|
||||
itemCount: menuActions.length,
|
||||
itemBuilder: (_, index) {
|
||||
final action = menuActions[index];
|
||||
|
||||
Reference in New Issue
Block a user