From 9def7fc8ace3476e19eedb5b756fe2f78d946df0 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Tue, 23 Aug 2022 23:15:00 +0200 Subject: [PATCH] Fix animation of overlays --- Shared/Player/VideoPlayerView.swift | 56 +++++++++++++++-------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/Shared/Player/VideoPlayerView.swift b/Shared/Player/VideoPlayerView.swift index dc758a52..d8c2d5e4 100644 --- a/Shared/Player/VideoPlayerView.swift +++ b/Shared/Player/VideoPlayerView.swift @@ -60,42 +60,46 @@ struct VideoPlayerView: View { var body: some View { ZStack(alignment: overlayAlignment) { videoPlayer + .zIndex(-1) #if os(iOS) - .gesture(playerControls.presentingControlsOverlay ? videoPlayerCloseControlsOverlayGesture : nil) + .gesture(playerControls.presentingControlsOverlay ? videoPlayerCloseControlsOverlayGesture : nil) #endif - if playerControls.presentingControlsOverlay { - HStack { + VStack { + if playerControls.presentingControlsOverlay { HStack { - ControlsOverlay() - #if os(tvOS) - .onExitCommand { - withAnimation(PlayerControls.animation) { - playerControls.hideOverlays() + HStack { + ControlsOverlay() + #if os(tvOS) + .onExitCommand { + withAnimation(PlayerControls.animation) { + playerControls.hideOverlays() + } } - } - .onPlayPauseCommand { - player.togglePlay() + .onPlayPauseCommand { + player.togglePlay() + } + #endif + .padding() + .modifier(ControlBackgroundModifier()) + .clipShape(RoundedRectangle(cornerRadius: 4)) + } + #if !os(tvOS) + .frame(maxWidth: fullScreenLayout ? .infinity : player.playerSize.width) + #endif + + #if !os(tvOS) + if !fullScreenLayout && sidebarQueue { + Spacer() } #endif - .padding() - .modifier(ControlBackgroundModifier()) - .clipShape(RoundedRectangle(cornerRadius: 4)) - .transition(.opacity) } - #if !os(tvOS) - .frame(maxWidth: fullScreenLayout ? .infinity : player.playerSize.width) - #endif - - #if !os(tvOS) - if !fullScreenLayout && sidebarQueue { - Spacer() - } + #if os(tvOS) + .clipShape(RoundedRectangle(cornerRadius: 10)) #endif + .zIndex(1) + .transition(.opacity) } - #if os(tvOS) - .clipShape(RoundedRectangle(cornerRadius: 10)) - #endif } } .onAppear {