From 9510d91d61c6d8ec2b3f8ab1a162762378343686 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toni=20F=C3=B6rster?= Date: Wed, 28 Aug 2024 12:32:38 +0200 Subject: [PATCH] Hide VideoActions Bar when no buttons is visible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Toni Förster --- .../Player/Video Details/VideoActions.swift | 4 +++ .../Player/Video Details/VideoDetails.swift | 25 ++++++++++++------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Shared/Player/Video Details/VideoActions.swift b/Shared/Player/Video Details/VideoActions.swift index f269300a..613e4396 100644 --- a/Shared/Player/Video Details/VideoActions.swift +++ b/Shared/Player/Video Details/VideoActions.swift @@ -86,6 +86,10 @@ struct VideoActions: View { } } + func isAnyActionVisible() -> Bool { + return Action.allCases.contains { isVisible($0) } + } + func isActionable(_ action: Action) -> Bool { switch action { case .share: diff --git a/Shared/Player/Video Details/VideoDetails.swift b/Shared/Player/Video Details/VideoDetails.swift index 0eb460d8..173fd830 100644 --- a/Shared/Player/Video Details/VideoDetails.swift +++ b/Shared/Player/Video Details/VideoDetails.swift @@ -235,15 +235,22 @@ struct VideoDetails: View { ) #endif // swiftlint:enable trailing_closure - - VideoActions(video: player.videoForDisplay) - .padding(.vertical, 5) - .frame(maxHeight: 50) - .frame(maxWidth: .infinity) - .borderTop(height: 0.5, color: Color("ControlsBorderColor")) - .borderBottom(height: 0.5, color: Color("ControlsBorderColor")) - .animation(nil, value: player.currentItem) - .frame(minWidth: 0, maxWidth: .infinity) + if VideoActions().isAnyActionVisible() { + VideoActions(video: player.videoForDisplay) + .padding(.vertical, 5) + .frame(maxHeight: 50) + .frame(maxWidth: .infinity) + .borderTop(height: 0.5, color: Color("ControlsBorderColor")) + .borderBottom(height: 0.5, color: Color("ControlsBorderColor")) + .animation(nil, value: player.currentItem) + .frame(minWidth: 0, maxWidth: .infinity) + } else { + Rectangle() + .fill(Color.clear) + .frame(height: 0.5) + .frame(maxWidth: .infinity) + .background(Color("ControlsBorderColor")) + } ScrollViewReader { proxy in pageView