Minor tvOS layout fixes

This commit is contained in:
Arkadiusz Fal 2022-06-26 14:55:23 +02:00
parent 993e602ca3
commit d330771fef
5 changed files with 27 additions and 20 deletions

View File

@ -85,12 +85,6 @@ final class PlayerControlsModel: ObservableObject {
} }
func resetTimer() { func resetTimer() {
#if os(tvOS)
if !presentingControls {
show()
}
#endif
removeTimer() removeTimer()
guard let player = player, !player.musicMode else { guard let player = player, !player.musicMode else {

View File

@ -69,6 +69,9 @@ struct PlayerControls: View {
.offset(y: -25) .offset(y: -25)
.zIndex(1) .zIndex(1)
} }
#if os(tvOS)
.offset(y: -100)
#endif
.frame(maxWidth: 500) .frame(maxWidth: 500)
.padding(.bottom, 2) .padding(.bottom, 2)
} }
@ -260,7 +263,9 @@ struct PlayerControls: View {
HStack(spacing: 20) { HStack(spacing: 20) {
restartVideoButton restartVideoButton
advanceToNextItemButton advanceToNextItemButton
musicModeButton #if !os(tvOS)
musicModeButton
#endif
} }
.frame(maxWidth: .infinity, alignment: .trailing) .frame(maxWidth: .infinity, alignment: .trailing)
} }

View File

@ -109,6 +109,9 @@ struct TimelineView: View {
HStack(spacing: 4) { HStack(spacing: 4) {
Text((dragging ? projectedValue : nil)?.formattedAsPlaybackTime(allowZero: true) ?? playerTime.currentPlaybackTime) Text((dragging ? projectedValue : nil)?.formattedAsPlaybackTime(allowZero: true) ?? playerTime.currentPlaybackTime)
.frame(minWidth: 35) .frame(minWidth: 35)
#if os(tvOS)
.font(.system(size: 20))
#endif
ZStack(alignment: .center) { ZStack(alignment: .center) {
ZStack(alignment: .leading) { ZStack(alignment: .leading) {
@ -209,6 +212,9 @@ struct TimelineView: View {
Text(dragging ? playerTime.durationPlaybackTime : playerTime.withoutSegmentsPlaybackTime) Text(dragging ? playerTime.durationPlaybackTime : playerTime.withoutSegmentsPlaybackTime)
.clipShape(RoundedRectangle(cornerRadius: 3)) .clipShape(RoundedRectangle(cornerRadius: 3))
.frame(minWidth: 35) .frame(minWidth: 35)
#if os(tvOS)
.font(.system(size: 20))
#endif
} }
.clipShape(RoundedRectangle(cornerRadius: 3)) .clipShape(RoundedRectangle(cornerRadius: 3))
.font(.system(size: 9).monospacedDigit()) .font(.system(size: 9).monospacedDigit())

View File

@ -141,22 +141,22 @@ struct VideoPlayerView: View {
playerView playerView
.ignoresSafeArea(.all, edges: .all) .ignoresSafeArea(.all, edges: .all)
.onMoveCommand { direction in .onMoveCommand { direction in
if direction == .up || direction == .down {
playerControls.show()
}
playerControls.resetTimer()
guard !playerControls.presentingControls else {
return
}
if direction == .left { if direction == .left {
playerControls.resetTimer()
player.backend.seek(relative: .secondsInDefaultTimescale(-10)) player.backend.seek(relative: .secondsInDefaultTimescale(-10))
} }
if direction == .right { if direction == .right {
playerControls.resetTimer()
player.backend.seek(relative: .secondsInDefaultTimescale(10)) player.backend.seek(relative: .secondsInDefaultTimescale(10))
} }
if direction == .up {
playerControls.show()
playerControls.resetTimer()
}
if direction == .down {
playerControls.show()
playerControls.resetTimer()
}
} }
#else #else
GeometryReader { geometry in GeometryReader { geometry in

View File

@ -78,9 +78,11 @@ struct VideoContextMenuView: View {
} }
} }
Section { #if !os(tvOS)
ShareButton(contentItem: .init(video: video)) Section {
} ShareButton(contentItem: .init(video: video))
}
#endif
if !inChannelView, !inChannelPlaylistView { if !inChannelView, !inChannelPlaylistView {
Section { Section {