mirror of
https://github.com/yattee/yattee.git
synced 2024-11-10 08:18:19 +00:00
70c089e696
Fix environment objects Hide video player placeholder on tvOS Queue improvements
54 lines
1.5 KiB
Swift
54 lines
1.5 KiB
Swift
import Foundation
|
|
import SwiftUI
|
|
|
|
struct VideoDetailsPaddingModifier: ViewModifier {
|
|
static var defaultAdditionalDetailsPadding: Double {
|
|
#if os(macOS)
|
|
20
|
|
#else
|
|
35
|
|
#endif
|
|
}
|
|
|
|
let geometry: GeometryProxy
|
|
let aspectRatio: Double?
|
|
let minimumHeightLeft: Double
|
|
let additionalPadding: Double
|
|
let fullScreen: Bool
|
|
|
|
init(
|
|
geometry: GeometryProxy,
|
|
aspectRatio: Double? = nil,
|
|
minimumHeightLeft: Double? = nil,
|
|
additionalPadding: Double? = nil,
|
|
fullScreen: Bool = false
|
|
) {
|
|
self.geometry = geometry
|
|
self.aspectRatio = aspectRatio ?? VideoPlayerView.defaultAspectRatio
|
|
self.minimumHeightLeft = minimumHeightLeft ?? VideoPlayerView.defaultMinimumHeightLeft
|
|
self.additionalPadding = additionalPadding ?? VideoDetailsPaddingModifier.defaultAdditionalDetailsPadding
|
|
self.fullScreen = fullScreen
|
|
}
|
|
|
|
var usedAspectRatio: Double {
|
|
guard aspectRatio != nil else {
|
|
return VideoPlayerView.defaultAspectRatio
|
|
}
|
|
|
|
return [aspectRatio!, VideoPlayerView.defaultAspectRatio].min()!
|
|
}
|
|
|
|
var playerHeight: Double {
|
|
[geometry.size.width / usedAspectRatio, geometry.size.height - minimumHeightLeft].min()!
|
|
}
|
|
|
|
var topPadding: Double {
|
|
fullScreen ? 0 : (playerHeight + additionalPadding)
|
|
}
|
|
|
|
func body(content: Content) -> some View {
|
|
content
|
|
.padding(.top, topPadding)
|
|
}
|
|
}
|