mirror of
https://github.com/yattee/yattee.git
synced 2024-12-23 14:03:41 +00:00
Player view layout changes
This commit is contained in:
parent
eca685ae29
commit
328119f0e0
@ -100,23 +100,6 @@ struct VideoPlayerView: View {
|
|||||||
Self._printChanges()
|
Self._printChanges()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if os(macOS)
|
|
||||||
return GeometryReader { geometry in
|
|
||||||
HSplitView {
|
|
||||||
content
|
|
||||||
}
|
|
||||||
.onAppear {
|
|
||||||
playerSize = geometry.size
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.alert(isPresented: $navigation.presentingAlertInVideoPlayer) { navigation.alert }
|
|
||||||
.onOpenURL { url in
|
|
||||||
URLBookmarkModel.shared.saveBookmark(url)
|
|
||||||
OpenURLHandler.shared.handle(url)
|
|
||||||
}
|
|
||||||
.frame(minWidth: 950, minHeight: 700)
|
|
||||||
#else
|
|
||||||
return GeometryReader { geometry in
|
return GeometryReader { geometry in
|
||||||
HStack(spacing: 0) {
|
HStack(spacing: 0) {
|
||||||
content
|
content
|
||||||
@ -124,13 +107,14 @@ struct VideoPlayerView: View {
|
|||||||
playerSize = geometry.size
|
playerSize = geometry.size
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onChange(of: geometry.size) { size in
|
.onChange(of: geometry.size) { _ in
|
||||||
self.playerSize = size
|
self.playerSize = geometry.size
|
||||||
}
|
}
|
||||||
.onChange(of: fullScreenDetails) { value in
|
.onChange(of: fullScreenDetails) { value in
|
||||||
player.backend.setNeedsDrawing(!value)
|
player.backend.setNeedsDrawing(!value)
|
||||||
}
|
}
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
|
.padding(.bottom, playerEdgesIgnoringSafeArea == [.bottom] ? 0 : geometry.safeAreaInsets.bottom)
|
||||||
.frame(width: playerWidth.isNil ? nil : Double(playerWidth!), height: playerHeight.isNil ? nil : Double(playerHeight!))
|
.frame(width: playerWidth.isNil ? nil : Double(playerWidth!), height: playerHeight.isNil ? nil : Double(playerHeight!))
|
||||||
.ignoresSafeArea(.all, edges: playerEdgesIgnoringSafeArea)
|
.ignoresSafeArea(.all, edges: playerEdgesIgnoringSafeArea)
|
||||||
.onChange(of: player.presentingPlayer) { newValue in
|
.onChange(of: player.presentingPlayer) { newValue in
|
||||||
@ -193,7 +177,6 @@ struct VideoPlayerView: View {
|
|||||||
.backport
|
.backport
|
||||||
.persistentSystemOverlays(!fullScreenPlayer)
|
.persistentSystemOverlays(!fullScreenPlayer)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateSidebarQueue() {
|
func updateSidebarQueue() {
|
||||||
@ -287,7 +270,7 @@ struct VideoPlayerView: View {
|
|||||||
return [.vertical]
|
return [.vertical]
|
||||||
}
|
}
|
||||||
|
|
||||||
return []
|
return [.bottom]
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -305,8 +288,9 @@ struct VideoPlayerView: View {
|
|||||||
.ignoresSafeArea()
|
.ignoresSafeArea()
|
||||||
#else
|
#else
|
||||||
GeometryReader { geometry in
|
GeometryReader { geometry in
|
||||||
|
ZStack {
|
||||||
player.playerBackendView
|
player.playerBackendView
|
||||||
#if !os(tvOS)
|
}
|
||||||
.modifier(
|
.modifier(
|
||||||
VideoPlayerSizeModifier(
|
VideoPlayerSizeModifier(
|
||||||
geometry: geometry,
|
geometry: geometry,
|
||||||
@ -314,16 +298,12 @@ struct VideoPlayerView: View {
|
|||||||
fullScreen: fullScreenPlayer
|
fullScreen: fullScreenPlayer
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.overlay(playerPlaceholder)
|
|
||||||
#endif
|
|
||||||
.frame(maxWidth: fullScreenPlayer ? .infinity : nil, maxHeight: fullScreenPlayer ? .infinity : nil)
|
.frame(maxWidth: fullScreenPlayer ? .infinity : nil, maxHeight: fullScreenPlayer ? .infinity : nil)
|
||||||
.onHover { hovering in
|
.onHover { hovering in
|
||||||
hoveringPlayer = hovering
|
hoveringPlayer = hovering
|
||||||
hovering ? player.controls.show() : player.controls.hide()
|
hovering ? player.controls.show() : player.controls.hide()
|
||||||
}
|
}
|
||||||
#if !os(tvOS)
|
|
||||||
.gesture(player.controls.presentingOverlays ? nil : playerDragGesture)
|
.gesture(player.controls.presentingOverlays ? nil : playerDragGesture)
|
||||||
#endif
|
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
.onAppear(perform: {
|
.onAppear(perform: {
|
||||||
NSEvent.addLocalMonitorForEvents(matching: [.mouseMoved]) {
|
NSEvent.addLocalMonitorForEvents(matching: [.mouseMoved]) {
|
||||||
@ -340,9 +320,8 @@ struct VideoPlayerView: View {
|
|||||||
|
|
||||||
.background(Color.black)
|
.background(Color.black)
|
||||||
|
|
||||||
#if !os(tvOS)
|
|
||||||
if !fullScreenPlayer {
|
if !fullScreenPlayer {
|
||||||
VideoDetails(page: $detailsPage, sidebarQueue: $sidebarQueue, fullScreen: $fullScreenDetails, bottomPadding: detailsNeedBottomPadding)
|
VideoDetails(video: player.currentVideo, page: $detailsPage, sidebarQueue: $sidebarQueue, fullScreen: $fullScreenDetails, bottomPadding: detailsNeedBottomPadding)
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
.ignoresSafeArea(.all, edges: .bottom)
|
.ignoresSafeArea(.all, edges: .bottom)
|
||||||
#endif
|
#endif
|
||||||
@ -355,8 +334,8 @@ struct VideoPlayerView: View {
|
|||||||
player.setNeedsDrawing(true)
|
player.setNeedsDrawing(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.transition(.opacity)
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -476,7 +455,7 @@ struct VideoPlayerView: View {
|
|||||||
.foregroundColor(.gray)
|
.foregroundColor(.gray)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
.background(Color.black)
|
.background(colorScheme == .dark ? Color.black : .white)
|
||||||
.contentShape(Rectangle())
|
.contentShape(Rectangle())
|
||||||
.frame(width: player.playerSize.width, height: player.playerSize.height)
|
.frame(width: player.playerSize.width, height: player.playerSize.height)
|
||||||
}
|
}
|
||||||
@ -493,7 +472,7 @@ struct VideoPlayerView_Previews: PreviewProvider {
|
|||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
VideoPlayerView()
|
VideoPlayerView()
|
||||||
.onAppear {
|
.onAppear {
|
||||||
OutroViewModel.shared.prepareForEmptyPlayerPlaceholder(.init(.fixture))
|
WatchNextViewModel.shared.prepareForEmptyPlayerPlaceholder(.init(.fixture))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user