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) {
|
if (isTop) {
|
||||||
final availableHeight = anchorPosition.dy - padding - gap;
|
final availableHeight = anchorPosition.dy - padding - gap;
|
||||||
final positionBottom = screenSize.height - anchorPosition.dy + gap;
|
final positionBottom = screenSize.height - anchorPosition.dy + gap;
|
||||||
|
final clampedLeft = anchorPosition.dx.clamp(
|
||||||
|
padding,
|
||||||
|
screenSize.width - menuSize.width - padding,
|
||||||
|
);
|
||||||
|
|
||||||
return AnchoredSuggestionLayoutResult(
|
return AnchoredSuggestionLayoutResult(
|
||||||
availableHeight: availableHeight,
|
availableHeight: availableHeight,
|
||||||
left: anchorPosition.dx,
|
left: clampedLeft,
|
||||||
bottom: positionBottom,
|
bottom: positionBottom,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class _AiScribeContextMenuContentState extends State<AiScribeContextMenu> {
|
|||||||
widget.submenuController?.hide();
|
widget.submenuController?.hide();
|
||||||
widget.onActionSelected(menuAction);
|
widget.onActionSelected(menuAction);
|
||||||
},
|
},
|
||||||
onHoverShowSubmenu: (itemKey) =>
|
onSelectCategory: (itemKey) =>
|
||||||
menuAction.submenuActions?.isNotEmpty == true
|
menuAction.submenuActions?.isNotEmpty == true
|
||||||
? _showSubmenu(
|
? _showSubmenu(
|
||||||
context: context,
|
context: context,
|
||||||
|
|||||||
+12
-4
@@ -6,7 +6,7 @@ class AiScribeContextMenuItem extends StatefulWidget {
|
|||||||
final AiScribeContextMenuAction menuAction;
|
final AiScribeContextMenuAction menuAction;
|
||||||
final ImagePaths imagePaths;
|
final ImagePaths imagePaths;
|
||||||
final ValueChanged<AiScribeContextMenuAction> onSelectAction;
|
final ValueChanged<AiScribeContextMenuAction> onSelectAction;
|
||||||
final OnHoverShowSubmenu? onHoverShowSubmenu;
|
final OnHoverShowSubmenu onSelectCategory;
|
||||||
final VoidCallback? onHoverOtherItem;
|
final VoidCallback? onHoverOtherItem;
|
||||||
|
|
||||||
const AiScribeContextMenuItem({
|
const AiScribeContextMenuItem({
|
||||||
@@ -14,7 +14,7 @@ class AiScribeContextMenuItem extends StatefulWidget {
|
|||||||
required this.menuAction,
|
required this.menuAction,
|
||||||
required this.imagePaths,
|
required this.imagePaths,
|
||||||
required this.onSelectAction,
|
required this.onSelectAction,
|
||||||
this.onHoverShowSubmenu,
|
required this.onSelectCategory,
|
||||||
this.onHoverOtherItem,
|
this.onHoverOtherItem,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ class _AiScribeContextMenuItemState extends State<AiScribeContextMenuItem> {
|
|||||||
_hoverController?.enter();
|
_hoverController?.enter();
|
||||||
|
|
||||||
if (_itemKey != null) {
|
if (_itemKey != null) {
|
||||||
widget.onHoverShowSubmenu?.call(_itemKey!);
|
widget.onSelectCategory.call(_itemKey!);
|
||||||
} else {
|
} else {
|
||||||
widget.onHoverOtherItem?.call();
|
widget.onHoverOtherItem?.call();
|
||||||
}
|
}
|
||||||
@@ -55,7 +55,15 @@ class _AiScribeContextMenuItemState extends State<AiScribeContextMenuItem> {
|
|||||||
child: AiScribeMenuItem(
|
child: AiScribeMenuItem(
|
||||||
itemKey: _itemKey,
|
itemKey: _itemKey,
|
||||||
menuAction: widget.menuAction,
|
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,
|
imagePaths: widget.imagePaths,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ class AiScribeSubmenu extends StatelessWidget {
|
|||||||
clipBehavior: Clip.antiAlias,
|
clipBehavior: Clip.antiAlias,
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
itemCount: menuActions.length,
|
itemCount: menuActions.length,
|
||||||
itemBuilder: (_, index) {
|
itemBuilder: (_, index) {
|
||||||
final action = menuActions[index];
|
final action = menuActions[index];
|
||||||
|
|||||||
Reference in New Issue
Block a user