From ccdfdf781d6afed0f3915e6919e90b35d6550dd3 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Sat, 15 Nov 2025 00:04:30 +0100 Subject: [PATCH] Add window fullscreen detection and improve iPad controls spacing Adds fullscreen detection utility to Constants.swift to determine if the window occupies the full screen on iOS. Uses this to conditionally add leading padding to player controls on iPad in non-fullscreen windows, preventing overlap with system window controls. --- Shared/Constants.swift | 26 +++++++++++++++++++++ Shared/Player/Controls/PlayerControls.swift | 8 +++++++ 2 files changed, 34 insertions(+) diff --git a/Shared/Constants.swift b/Shared/Constants.swift index e21b41c8..27e381c7 100644 --- a/Shared/Constants.swift +++ b/Shared/Constants.swift @@ -39,6 +39,32 @@ enum Constants { #endif } + static var isWindowFullscreen: Bool { + #if os(iOS) + guard let windowScene = UIApplication.shared.connectedScenes + .filter({ $0.activationState == .foregroundActive }) + .compactMap({ $0 as? UIWindowScene }) + .first, + let window = windowScene.windows.first + else { + return false + } + + let screenBounds = windowScene.screen.bounds + let windowBounds = window.frame + + // Check if window size matches screen bounds (accounting for small differences) + return abs(windowBounds.width - screenBounds.width) < 1 && + abs(windowBounds.height - screenBounds.height) < 1 + #else + return false + #endif + } + + static var iPadSystemControlsWidth: CGFloat { + 50 + } + static var isTvOS: Bool { #if os(tvOS) true diff --git a/Shared/Player/Controls/PlayerControls.swift b/Shared/Player/Controls/PlayerControls.swift index 64a68edf..0e355e96 100644 --- a/Shared/Player/Controls/PlayerControls.swift +++ b/Shared/Player/Controls/PlayerControls.swift @@ -329,6 +329,14 @@ struct PlayerControls: View { var buttonsBar: some View { HStack(spacing: playerControlsLayout.buttonsSpacing) { + #if os(iOS) + // On iPad in resizable windows, add leading space to avoid system window controls + if Constants.isIPad, !Constants.isWindowFullscreen { + Spacer() + .frame(width: Constants.iPadSystemControlsWidth) + } + #endif + fullscreenButton pipButton