From b7f153594299f8afa27be7631ebb98bee3e7bd7a Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Mon, 27 Jun 2022 00:15:01 +0200 Subject: [PATCH] Fix video details offset --- Shared/Player/VideoDetailsPaddingModifier.swift | 8 ++++---- Shared/Player/VideoPlayerView.swift | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Shared/Player/VideoDetailsPaddingModifier.swift b/Shared/Player/VideoDetailsPaddingModifier.swift index 45c694d9..089fa0b5 100644 --- a/Shared/Player/VideoDetailsPaddingModifier.swift +++ b/Shared/Player/VideoDetailsPaddingModifier.swift @@ -4,20 +4,20 @@ import SwiftUI struct VideoDetailsPaddingModifier: ViewModifier { static var defaultAdditionalDetailsPadding = 0.0 - let geometry: GeometryProxy + let playerSize: CGSize let aspectRatio: Double? let minimumHeightLeft: Double let additionalPadding: Double let fullScreen: Bool init( - geometry: GeometryProxy, + playerSize: CGSize, aspectRatio: Double? = nil, minimumHeightLeft: Double? = nil, additionalPadding: Double? = nil, fullScreen: Bool = false ) { - self.geometry = geometry + self.playerSize = playerSize self.aspectRatio = aspectRatio ?? VideoPlayerView.defaultAspectRatio self.minimumHeightLeft = minimumHeightLeft ?? VideoPlayerView.defaultMinimumHeightLeft self.additionalPadding = additionalPadding ?? Self.defaultAdditionalDetailsPadding @@ -33,7 +33,7 @@ struct VideoDetailsPaddingModifier: ViewModifier { } var playerHeight: Double { - [geometry.size.width / usedAspectRatio, geometry.size.height - minimumHeightLeft].min()! + playerSize.height } var topPadding: Double { diff --git a/Shared/Player/VideoPlayerView.swift b/Shared/Player/VideoPlayerView.swift index 7d9a10f9..400134a0 100644 --- a/Shared/Player/VideoPlayerView.swift +++ b/Shared/Player/VideoPlayerView.swift @@ -240,7 +240,7 @@ struct VideoPlayerView: View { } .background(colorScheme == .dark ? Color.black : Color.white) .modifier(VideoDetailsPaddingModifier( - geometry: geometry, + playerSize: player.playerSize, aspectRatio: player.avPlayerBackend.controller?.aspectRatio, fullScreen: fullScreenDetails ))