Fix chats search appearance animation

This commit is contained in:
Ilya Laktyushin 2020-10-19 13:34:21 +04:00
parent b074831fd3
commit 97ec1faf13

View File

@ -138,7 +138,7 @@ public final class SearchDisplayController {
self.contentNode.containerLayoutUpdated(ContainerViewLayout(size: size, metrics: LayoutMetrics(), deviceMetrics: layout.deviceMetrics, intrinsicInsets: layout.intrinsicInsets, safeInsets: safeInsets, statusBarHeight: nil, inputHeight: layout.inputHeight, inputHeightIsInteractivellyChanging: layout.inputHeightIsInteractivellyChanging, inVoiceOver: layout.inVoiceOver), navigationBarHeight: navigationBarHeight, transition: transition)
}
public func activate(insertSubnode: (ASDisplayNode, Bool) -> Void, placeholder: SearchBarPlaceholderNode?) {
public func activate(insertSubnode: @escaping (ASDisplayNode, Bool) -> Void, placeholder: SearchBarPlaceholderNode?) {
guard let (layout, navigationBarHeight) = self.containerLayout else {
return
}
@ -148,6 +148,8 @@ public final class SearchDisplayController {
if self.contentNode.hasDim {
self.backgroundNode.backgroundColor = .clear
} else {
self.backgroundNode.alpha = 0.0
}
var size = layout.size
@ -165,10 +167,22 @@ public final class SearchDisplayController {
contentNavigationBarHeight += 28.0
}
self.backgroundNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.25, timingFunction: CAMediaTimingFunctionName.easeOut.rawValue)
let _ = (self.contentNode.ready()
|> take(1)
|> deliverOnMainQueue).start(next: { [weak self] _ in
guard let strongSelf = self else {
return
}
if !strongSelf.contentNode.hasDim {
strongSelf.backgroundNode.alpha = 1.0
strongSelf.backgroundNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.25, timingFunction: CAMediaTimingFunctionName.easeOut.rawValue)
strongSelf.backgroundNode.layer.animateScale(from: 0.85, to: 1.0, duration: 0.5, timingFunction: kCAMediaTimingFunctionSpring)
}
})
if !self.contentNode.hasDim {
self.backgroundNode.layer.animateScale(from: 0.85, to: 1.0, duration: 0.5, timingFunction: kCAMediaTimingFunctionSpring)
if let placeholder = placeholder {
self.searchBar.placeholderString = placeholder.placeholderString
}