From 9485d7e9b53b7f46aa6ee11f065524d93e5a6472 Mon Sep 17 00:00:00 2001 From: relikd Date: Wed, 22 Apr 2020 22:30:19 +0200 Subject: [PATCH] Fix pull back animation for new recording --- main/Recordings/VCRecordings.swift | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/main/Recordings/VCRecordings.swift b/main/Recordings/VCRecordings.swift index da2e30d..e317d2e 100644 --- a/main/Recordings/VCRecordings.swift +++ b/main/Recordings/VCRecordings.swift @@ -33,10 +33,19 @@ class VCRecordings: UIViewController, UINavigationControllerDelegate { stopTimer(animate: false) } - func navigationController(_ navigationController: UINavigationController, willShow vc: UIViewController, animated: Bool) { - let isRoot = (vc == navigationController.viewControllers.first) - UIView.animate(withDuration: 0.3) { - self.startNewRecView.isHidden = !isRoot // hide "new recording" if details open + func navigationController(_ nav: UINavigationController, willShow vc: UIViewController, animated: Bool) { + hideNewRecording(isRootVC: (vc == nav.viewControllers.first), didShow: false) + } + + func navigationController(_ nav: UINavigationController, didShow vc: UIViewController, animated: Bool) { + hideNewRecording(isRootVC: (vc == nav.viewControllers.first), didShow: true) + } + + private func hideNewRecording(isRootVC: Bool, didShow: Bool) { + if isRootVC == didShow { + UIView.animate(withDuration: 0.3) { + self.startNewRecView.isHidden = !isRootVC // hide "new recording" if details open + } } }