diff --git a/submodules/Display/Source/ContainedViewLayoutTransition.swift b/submodules/Display/Source/ContainedViewLayoutTransition.swift index be1d3e8a6e..9246b9bad3 100644 --- a/submodules/Display/Source/ContainedViewLayoutTransition.swift +++ b/submodules/Display/Source/ContainedViewLayoutTransition.swift @@ -692,7 +692,7 @@ public extension ContainedViewLayoutTransition { } } - func updateFrame(layer: CALayer, frame: CGRect, beginWithCurrentState: Bool = false, completion: ((Bool) -> Void)? = nil) { + func updateFrame(layer: CALayer, frame: CGRect, beginWithCurrentState: Bool = false, delay: Double = 0.0, completion: ((Bool) -> Void)? = nil) { if layer.frame.equalTo(frame) { completion?(true) } else { @@ -712,7 +712,7 @@ public extension ContainedViewLayoutTransition { previousFrame = layer.frame } layer.frame = frame - layer.animateFrame(from: previousFrame, to: frame, duration: duration, timingFunction: curve.timingFunction, mediaTimingFunction: curve.mediaTimingFunction, completion: { result in + layer.animateFrame(from: previousFrame, to: frame, duration: duration, delay: delay, timingFunction: curve.timingFunction, mediaTimingFunction: curve.mediaTimingFunction, completion: { result in if let completion = completion { completion(result) } @@ -1572,7 +1572,7 @@ public struct CombinedTransition { } public extension ContainedViewLayoutTransition { - func animateView(allowUserInteraction: Bool = false, _ f: @escaping () -> Void, completion: ((Bool) -> Void)? = nil) { + func animateView(allowUserInteraction: Bool = false, delay: Double = 0.0, _ f: @escaping () -> Void, completion: ((Bool) -> Void)? = nil) { switch self { case .immediate: f() @@ -1582,7 +1582,7 @@ public extension ContainedViewLayoutTransition { if allowUserInteraction { options.insert(.allowUserInteraction) } - UIView.animate(withDuration: duration, delay: 0.0, options: options, animations: { + UIView.animate(withDuration: duration, delay: delay, options: options, animations: { f() }, completion: completion) } diff --git a/submodules/TelegramUI/Sources/ChatControllerNode.swift b/submodules/TelegramUI/Sources/ChatControllerNode.swift index c8f71da026..04490e4f90 100644 --- a/submodules/TelegramUI/Sources/ChatControllerNode.swift +++ b/submodules/TelegramUI/Sources/ChatControllerNode.swift @@ -576,14 +576,6 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { self.contentContainerNode.addSubnode(navigationBar) } -// Queue.mainQueue().after(0.2) { -// self.updateIsLoading(isLoading: true, animated: false) -// } -// -// Queue.mainQueue().after(3.0) { -// self.updateIsLoading(isLoading: false, animated: true) -// } - self.inputPanelContainerNode.expansionUpdated = { [weak self] transition in guard let strongSelf = self else { return @@ -1736,10 +1728,21 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { } if let inputPanelBackgroundContent = self.inputPanelBackgroundContent { - var apparentInputBackgroundFrame = apparentInputBackgroundFrame - apparentInputBackgroundFrame.size.height += 34.0 - transition.updateFrame(node: inputPanelBackgroundContent, frame: CGRect(origin: .zero, size: apparentInputBackgroundFrame.size), beginWithCurrentState: true) - inputPanelBackgroundContent.update(rect: apparentInputBackgroundFrame, within: layout.size, transition: transition) + var extensionValue: CGFloat = 0.0 + if let inputNode = self.inputNode { + extensionValue = inputNode.topBackgroundExtension + } + let apparentInputBackgroundFrame = CGRect(origin: .zero, size: CGSize(width: apparentInputBackgroundFrame.width, height: apparentInputBackgroundFrame.height + extensionValue)) + var transition = transition + var delay: Double = 0.0 + if apparentInputBackgroundFrame.height > inputPanelBackgroundContent.frame.height { + transition = .immediate + } else if case let .animated(_, curve) = transition, case .spring = curve { + delay = 0.3 + } + + transition.updateFrame(node: inputPanelBackgroundContent, frame: CGRect(origin: .zero, size: apparentInputBackgroundFrame.size), beginWithCurrentState: true, delay: delay) + inputPanelBackgroundContent.update(rect: apparentInputBackgroundFrame, within: layout.size, delay: delay, transition: transition) } transition.updateFrame(node: self.contentDimNode, frame: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: layout.size.width, height: apparentInputBackgroundFrame.origin.y))) diff --git a/submodules/WallpaperBackgroundNode/Sources/WallpaperBackgroundNode.swift b/submodules/WallpaperBackgroundNode/Sources/WallpaperBackgroundNode.swift index 83dc46b817..a671119aa5 100644 --- a/submodules/WallpaperBackgroundNode/Sources/WallpaperBackgroundNode.swift +++ b/submodules/WallpaperBackgroundNode/Sources/WallpaperBackgroundNode.swift @@ -45,6 +45,7 @@ public protocol WallpaperBubbleBackgroundNode: ASDisplayNode { var implicitContentUpdate: Bool { get set } func update(rect: CGRect, within containerSize: CGSize, transition: ContainedViewLayoutTransition) + func update(rect: CGRect, within containerSize: CGSize, delay: Double, transition: ContainedViewLayoutTransition) func update(rect: CGRect, within containerSize: CGSize, transition: CombinedTransition) func update(rect: CGRect, within containerSize: CGSize, animator: ControlledTransitionAnimator) func offset(value: CGPoint, animationCurve: ContainedViewLayoutTransitionCurve, duration: Double) @@ -474,25 +475,29 @@ final class WallpaperBackgroundNodeImpl: ASDisplayNode, WallpaperBackgroundNode self.update(rect: rect, within: containerSize) } } - + func update(rect: CGRect, within containerSize: CGSize, transition: ContainedViewLayoutTransition = .immediate) { + self.update(rect: rect, within: containerSize, delay: 0.0, transition: transition) + } + + func update(rect: CGRect, within containerSize: CGSize, delay: Double = 0.0, transition: ContainedViewLayoutTransition = .immediate) { self.currentLayout = (rect, containerSize) let shiftedContentsRect = CGRect(origin: CGPoint(x: rect.minX / containerSize.width, y: rect.minY / containerSize.height), size: CGSize(width: rect.width / containerSize.width, height: rect.height / containerSize.height)) - transition.updateFrame(layer: self.contentNode.layer, frame: self.bounds) - transition.animateView { + transition.updateFrame(layer: self.contentNode.layer, frame: self.bounds, delay: delay) + transition.animateView(delay: delay) { self.contentNode.layer.contentsRect = shiftedContentsRect } if let cleanWallpaperNode = self.cleanWallpaperNode { - transition.updateFrame(layer: cleanWallpaperNode.layer, frame: self.bounds) - transition.animateView { + transition.updateFrame(layer: cleanWallpaperNode.layer, frame: self.bounds, delay: delay) + transition.animateView(delay: delay) { cleanWallpaperNode.layer.contentsRect = shiftedContentsRect } } if let gradientWallpaperNode = self.gradientWallpaperNode { - transition.updateFrame(layer: gradientWallpaperNode.layer, frame: self.bounds) - transition.animateView { + transition.updateFrame(layer: gradientWallpaperNode.layer, frame: self.bounds, delay: delay) + transition.animateView(delay: delay) { gradientWallpaperNode.layer.contentsRect = shiftedContentsRect } } @@ -1421,6 +1426,10 @@ final class WallpaperBackgroundNodeMergedImpl: ASDisplayNode, WallpaperBackgroun } func update(rect: CGRect, within containerSize: CGSize, transition: ContainedViewLayoutTransition = .immediate) { + self.update(rect: rect, within: containerSize, delay: 0.0, transition: transition) + } + + func update(rect: CGRect, within containerSize: CGSize, delay: Double, transition: ContainedViewLayoutTransition = .immediate) { self.currentLayout = (rect, containerSize) let shiftedContentsRect = CGRect(origin: CGPoint(x: rect.minX / containerSize.width, y: rect.minY / containerSize.height), size: CGSize(width: rect.width / containerSize.width, height: rect.height / containerSize.height))