From e98dae6d488e64b21f1d4a236391e58a709736a0 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Sun, 26 Jun 2022 14:55:23 +0200 Subject: [PATCH] Minor tvOS layout fixes --- Model/Player/PlayerControlsModel.swift | 6 ------ Shared/Player/Controls/PlayerControls.swift | 7 ++++++- Shared/Player/TimelineView.swift | 6 ++++++ Shared/Player/VideoPlayerView.swift | 20 ++++++++++---------- Shared/Views/VideoContextMenuView.swift | 8 +++++--- 5 files changed, 27 insertions(+), 20 deletions(-) diff --git a/Model/Player/PlayerControlsModel.swift b/Model/Player/PlayerControlsModel.swift index 707ee2e4..94df7f44 100644 --- a/Model/Player/PlayerControlsModel.swift +++ b/Model/Player/PlayerControlsModel.swift @@ -85,12 +85,6 @@ final class PlayerControlsModel: ObservableObject { } func resetTimer() { - #if os(tvOS) - if !presentingControls { - show() - } - #endif - removeTimer() guard let player = player, !player.musicMode else { diff --git a/Shared/Player/Controls/PlayerControls.swift b/Shared/Player/Controls/PlayerControls.swift index 33874697..8dfe6413 100644 --- a/Shared/Player/Controls/PlayerControls.swift +++ b/Shared/Player/Controls/PlayerControls.swift @@ -69,6 +69,9 @@ struct PlayerControls: View { .offset(y: -25) .zIndex(1) } + #if os(tvOS) + .offset(y: -100) + #endif .frame(maxWidth: 500) .padding(.bottom, 2) } @@ -260,7 +263,9 @@ struct PlayerControls: View { HStack(spacing: 20) { restartVideoButton advanceToNextItemButton - musicModeButton + #if !os(tvOS) + musicModeButton + #endif } .frame(maxWidth: .infinity, alignment: .trailing) } diff --git a/Shared/Player/TimelineView.swift b/Shared/Player/TimelineView.swift index d22c2735..07d577be 100644 --- a/Shared/Player/TimelineView.swift +++ b/Shared/Player/TimelineView.swift @@ -109,6 +109,9 @@ struct TimelineView: View { HStack(spacing: 4) { Text((dragging ? projectedValue : nil)?.formattedAsPlaybackTime(allowZero: true) ?? playerTime.currentPlaybackTime) .frame(minWidth: 35) + #if os(tvOS) + .font(.system(size: 20)) + #endif ZStack(alignment: .center) { ZStack(alignment: .leading) { @@ -209,6 +212,9 @@ struct TimelineView: View { Text(dragging ? playerTime.durationPlaybackTime : playerTime.withoutSegmentsPlaybackTime) .clipShape(RoundedRectangle(cornerRadius: 3)) .frame(minWidth: 35) + #if os(tvOS) + .font(.system(size: 20)) + #endif } .clipShape(RoundedRectangle(cornerRadius: 3)) .font(.system(size: 9).monospacedDigit()) diff --git a/Shared/Player/VideoPlayerView.swift b/Shared/Player/VideoPlayerView.swift index 0104a90d..d47d6de1 100644 --- a/Shared/Player/VideoPlayerView.swift +++ b/Shared/Player/VideoPlayerView.swift @@ -141,22 +141,22 @@ struct VideoPlayerView: View { playerView .ignoresSafeArea(.all, edges: .all) .onMoveCommand { direction in + if direction == .up || direction == .down { + playerControls.show() + } + + playerControls.resetTimer() + + guard !playerControls.presentingControls else { + return + } + if direction == .left { - playerControls.resetTimer() player.backend.seek(relative: .secondsInDefaultTimescale(-10)) } if direction == .right { - playerControls.resetTimer() player.backend.seek(relative: .secondsInDefaultTimescale(10)) } - if direction == .up { - playerControls.show() - playerControls.resetTimer() - } - if direction == .down { - playerControls.show() - playerControls.resetTimer() - } } #else GeometryReader { geometry in diff --git a/Shared/Views/VideoContextMenuView.swift b/Shared/Views/VideoContextMenuView.swift index 13de210c..5082fbfb 100644 --- a/Shared/Views/VideoContextMenuView.swift +++ b/Shared/Views/VideoContextMenuView.swift @@ -78,9 +78,11 @@ struct VideoContextMenuView: View { } } - Section { - ShareButton(contentItem: .init(video: video)) - } + #if !os(tvOS) + Section { + ShareButton(contentItem: .init(video: video)) + } + #endif if !inChannelView, !inChannelPlaylistView { Section {