1
0
mirror of https://github.com/yattee/yattee.git synced 2025-04-28 16:00:33 +05:30

honour the aspect ratio when resizing

The `defaultMinimumHeightLeft? has been adjusted to make the radio of the video view 16:9 in its initial state. Also on macOS when resizing the window, the aspect ratio of the view now correlates with the video.
This commit is contained in:
Toni Förster 2023-11-21 13:47:51 +01:00
parent 987f6dcac8
commit 8900f96ce7
No known key found for this signature in database
GPG Key ID: 292F3E5086C83FC7
2 changed files with 5 additions and 8 deletions

View File

@ -27,10 +27,7 @@ struct VideoPlayerSizeModifier: ViewModifier {
content content
.frame(width: geometry.size.width) .frame(width: geometry.size.width)
.frame(maxHeight: maxHeight) .frame(maxHeight: maxHeight)
#if !os(macOS)
.aspectRatio(ratio, contentMode: usedAspectRatioContentMode) .aspectRatio(ratio, contentMode: usedAspectRatioContentMode)
#endif
} }
var ratio: CGFloat? { // swiftlint:disable:this no_cgfloat var ratio: CGFloat? { // swiftlint:disable:this no_cgfloat
@ -49,7 +46,7 @@ struct VideoPlayerSizeModifier: ViewModifier {
#if os(iOS) #if os(iOS)
fullScreen ? .fill : .fit fullScreen ? .fill : .fit
#else #else
.fit .fit
#endif #endif
} }

View File

@ -22,7 +22,7 @@ struct VideoPlayerView: View {
static let defaultAspectRatio = 16 / 9.0 static let defaultAspectRatio = 16 / 9.0
static var defaultMinimumHeightLeft: Double { static var defaultMinimumHeightLeft: Double {
#if os(macOS) #if os(macOS)
300 335
#else #else
200 200
#endif #endif
@ -315,7 +315,7 @@ struct VideoPlayerView: View {
.id(player.currentVideo?.cacheKey) .id(player.currentVideo?.cacheKey)
.transition(.opacity) .transition(.opacity)
} else { } else {
VStack {} VStack { }
} }
} }
#endif #endif
@ -393,7 +393,7 @@ struct VideoPlayerView: View {
} }
#endif #endif
} else { } else {
VStack {} VStack { }
} }
} }
.onChange(of: fullScreenPlayer) { newValue in .onChange(of: fullScreenPlayer) { newValue in
@ -508,6 +508,6 @@ struct VideoPlayerView_Previews: PreviewProvider {
return view return view
} }
func updateUIView(_: UIView, context _: Context) {} func updateUIView(_: UIView, context _: Context) { }
} }
#endif #endif