From a2cd3397c9862fa829ed0a4fd7de78c7f3dc523c Mon Sep 17 00:00:00 2001 From: edde746 <86283021+edde746@users.noreply.github.com> Date: Thu, 5 Mar 2026 14:25:23 +0100 Subject: [PATCH] fix: desktop context menu position and bottom sheet sizing --- lib/screens/media_detail_screen.dart | 29 ++++++++++++++++------------ lib/widgets/overlay_sheet.dart | 12 +++++++++++- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/lib/screens/media_detail_screen.dart b/lib/screens/media_detail_screen.dart index 07465dc3..4ec8fada 100644 --- a/lib/screens/media_detail_screen.dart +++ b/lib/screens/media_detail_screen.dart @@ -44,6 +44,7 @@ import '../widgets/app_bar_back_button.dart'; import '../utils/desktop_window_padding.dart'; import '../widgets/horizontal_scroll_with_arrows.dart'; import '../widgets/media_context_menu.dart'; +import '../widgets/overlay_sheet.dart'; import '../widgets/placeholder_container.dart'; import '../mixins/watch_state_aware.dart'; import '../mixins/deletion_aware.dart'; @@ -728,17 +729,19 @@ class _MediaDetailScreenState extends State with WatchStateAw key: _contextMenuKey, item: metadata, onRefresh: (_) => _loadFullMetadata(), - child: IconButton.filledTonal( - onPressed: () { - final renderBox = context.findRenderObject() as RenderBox?; - if (renderBox != null) { - final position = renderBox.localToGlobal(renderBox.size.center(Offset.zero)); - _contextMenuKey.currentState?.showContextMenu(context, position: position); - } - }, - icon: const AppIcon(Symbols.more_vert_rounded, fill: 1), - iconSize: 20, - style: IconButton.styleFrom(minimumSize: const Size(48, 48), maximumSize: const Size(48, 48)), + child: Builder( + builder: (buttonContext) => IconButton.filledTonal( + onPressed: () { + final renderBox = buttonContext.findRenderObject() as RenderBox?; + if (renderBox != null) { + final position = renderBox.localToGlobal(renderBox.size.center(Offset.zero)); + _contextMenuKey.currentState?.showContextMenu(buttonContext, position: position); + } + }, + icon: const AppIcon(Symbols.more_vert_rounded, fill: 1), + iconSize: 20, + style: IconButton.styleFrom(minimumSize: const Size(48, 48), maximumSize: const Size(48, 48)), + ), ), ), ], @@ -1859,7 +1862,8 @@ class _MediaDetailScreenState extends State with WatchStateAw final size = MediaQuery.of(context).size; final headerHeight = size.height * 0.6; - final content = Focus( + final content = OverlaySheetHost( + child: Focus( onKeyEvent: handleBack, child: Scaffold( body: Stack( @@ -2227,6 +2231,7 @@ class _MediaDetailScreenState extends State with WatchStateAw ], ), ), + ), ); final blockSystemBack = Platform.isAndroid && InputModeTracker.isKeyboardMode(context); diff --git a/lib/widgets/overlay_sheet.dart b/lib/widgets/overlay_sheet.dart index 68411725..4899693b 100644 --- a/lib/widgets/overlay_sheet.dart +++ b/lib/widgets/overlay_sheet.dart @@ -121,10 +121,20 @@ class OverlaySheetController { showDragHandle: showDragHandle, ); } + // Apply the same default constraints the overlay system uses so sheets + // shown without an OverlaySheetHost still have sensible sizing on desktop. + final effectiveConstraints = constraints ?? () { + final size = MediaQuery.of(context).size; + final isDesktop = size.width > 600; + return BoxConstraints( + maxWidth: isDesktop ? 700 : double.infinity, + maxHeight: isDesktop ? 400 : size.height * 0.75, + ); + }(); return showModalBottomSheet( context: context, builder: builder, - constraints: constraints, + constraints: effectiveConstraints, backgroundColor: backgroundColor ?? Theme.of(context).colorScheme.surface, barrierColor: Colors.black54, isScrollControlled: isScrollControlled,