From 6bc58f10b23c22b47d7986ad45c557813728ef2e Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Wed, 27 May 2026 23:03:40 +0200 Subject: [PATCH] Open macOS inline player sheet at correct size when video is loaded MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The inline-sheet content declared only a minWidth/minHeight floor, so .presentationSizing(.fitted) opened the sheet at 640x360 and SheetWindowResizer corrected it a runloop tick later — a visible small-then-resize flash when re-opening the sheet while a video plays. Feed the already-computed aspect-derived size as the frame's ideal size so .fitted opens the sheet at the correct size immediately when the video dimensions are known; the resizer's first pass then no-ops on its guard. The floor (no max) is kept so content still tracks later animated resizes. --- Yattee/ContentView.swift | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Yattee/ContentView.swift b/Yattee/ContentView.swift index c016d86a..d390f7a2 100644 --- a/Yattee/ContentView.swift +++ b/Yattee/ContentView.swift @@ -95,11 +95,17 @@ struct ContentView: View { )) { let size = expandedSheetSize(appEnvironment: appEnvironment) ExpandedPlayerSheet() - // Only a floor — the content fills the sheet window so it tracks - // the window's animated resize with no gap. Do NOT pin an exact - // size here: a fixed frame snaps instantly while the window - // animates, exposing the window background as bars. - .frame(minWidth: 640, minHeight: 360) + // Floor keeps the content flexible so it tracks the window's + // animated resize with no gap — do NOT pin an exact (max) size: + // a fixed frame snaps instantly while the window animates, + // exposing the window background as bars. The ideal size makes + // `.presentationSizing(.fitted)` open the sheet at the correct + // aspect immediately when the video size is already known (e.g. + // re-opening while playing), avoiding a small-then-resize flash. + .frame( + minWidth: 640, idealWidth: size.width, + minHeight: 360, idealHeight: size.height + ) .presentationSizing(.fitted) // `.presentationSizing(.fitted)` only fits the sheet once, at // presentation. Resize the backing window directly when the