From d72991ca7db7f54c3a8a177e7d0b48707a5a991e Mon Sep 17 00:00:00 2001 From: Stephen Byatt <47413006+stephenb10@users.noreply.github.com> Date: Sat, 26 Jun 2021 20:50:04 +1000 Subject: [PATCH] Add animation when transitioning between the large and small view --- JellyfinPlayer/VideoPlayer.swift | 15 ++++++++++----- JellyfinPlayer/VideoUpNextView.swift | 2 -- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/JellyfinPlayer/VideoPlayer.swift b/JellyfinPlayer/VideoPlayer.swift index 66fdb0a6..2505f048 100644 --- a/JellyfinPlayer/VideoPlayer.swift +++ b/JellyfinPlayer/VideoPlayer.swift @@ -687,13 +687,18 @@ class PlayerViewController: UIViewController, GCKDiscoveryManagerListener, GCKRe } func smallNextUpView() { - upNextViewModel.largeView = false - upNextView.frame = smallView + UIView.animate(withDuration: 0.2, delay: 0, options: .curveEaseIn) { [self] in + upNextViewModel.largeView = false + upNextView.frame = smallView + } } func largeNextUpView() { - upNextViewModel.largeView = true - upNextView.frame = largeView + UIView.animate(withDuration: 0.1, delay: 0, options: .curveEaseOut) { [self] in + upNextViewModel.largeView = true + upNextView.frame = largeView + } + } func setupNextUpView() { @@ -973,9 +978,9 @@ extension PlayerViewController: VLCMediaPlayerDelegate { timeText.text = String(mediaPlayer.remainingTime.stringValue.dropFirst()) if CACurrentMediaTime() - controlsAppearTime > 5 { + self.smallNextUpView() UIView.animate(withDuration: 0.5, delay: 0, options: .curveEaseOut, animations: { self.videoControlsView.alpha = 0.0 - self.smallNextUpView() }, completion: { (_: Bool) in self.videoControlsView.isHidden = true self.videoControlsView.alpha = 1 diff --git a/JellyfinPlayer/VideoUpNextView.swift b/JellyfinPlayer/VideoUpNextView.swift index 0fa3f5de..e04207d0 100644 --- a/JellyfinPlayer/VideoUpNextView.swift +++ b/JellyfinPlayer/VideoUpNextView.swift @@ -76,8 +76,6 @@ struct VideoUpNextView: View { .cornerRadius(5) .shadow(radius: 10) ) - - } else { return AnyView(EmptyView())