From 1e440c199c95f786af9e5b16084bac4a493292ed Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Thu, 11 Nov 2021 22:34:31 +0400 Subject: [PATCH] Fix gallery crossfade in animation --- .../GalleryUI/Sources/GalleryControllerNode.swift | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/submodules/GalleryUI/Sources/GalleryControllerNode.swift b/submodules/GalleryUI/Sources/GalleryControllerNode.swift index a998a9f8d8..0c1152e64c 100644 --- a/submodules/GalleryUI/Sources/GalleryControllerNode.swift +++ b/submodules/GalleryUI/Sources/GalleryControllerNode.swift @@ -329,15 +329,18 @@ open class GalleryControllerNode: ASDisplayNode, UIScrollViewDelegate, UIGesture open func animateIn(animateContent: Bool, useSimpleAnimation: Bool) { let duration: Double = animateContent ? 0.2 : 0.3 - - self.backgroundNode.backgroundColor = self.backgroundNode.backgroundColor?.withAlphaComponent(0.0) + let fadeDuration: Double = 0.2 + + let backgroundColor = self.backgroundNode.backgroundColor ?? .black + self.statusBar?.alpha = 0.0 self.navigationBar?.alpha = 0.0 self.footerNode.alpha = 0.0 self.currentThumbnailContainerNode?.alpha = 0.0 - UIView.animate(withDuration: duration, animations: { - self.backgroundNode.backgroundColor = self.backgroundNode.backgroundColor?.withAlphaComponent(1.0) + self.backgroundNode.layer.animate(from: backgroundColor.withAlphaComponent(0.0).cgColor, to: backgroundColor.cgColor, keyPath: "backgroundColor", timingFunction: CAMediaTimingFunctionName.linear.rawValue, duration: fadeDuration) + + UIView.animate(withDuration: fadeDuration, delay: 0.0, options: [.curveLinear], animations: { if !self.areControlsHidden { self.statusBar?.alpha = 1.0 self.navigationBar?.alpha = 1.0