mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Fix profile avatar blurring
This commit is contained in:
parent
16d80ea910
commit
c7e558f3ac
@ -3702,10 +3702,25 @@ private class DynamicIslandBlurNode: ASDisplayNode {
|
|||||||
private var effectView: UIVisualEffectView?
|
private var effectView: UIVisualEffectView?
|
||||||
private let fadeNode = ASDisplayNode()
|
private let fadeNode = ASDisplayNode()
|
||||||
private let gradientNode = ASImageNode()
|
private let gradientNode = ASImageNode()
|
||||||
|
|
||||||
|
private var hierarchyTrackingNode: HierarchyTrackingNode?
|
||||||
|
|
||||||
|
deinit {
|
||||||
|
self.animator?.stopAnimation(true)
|
||||||
|
}
|
||||||
|
|
||||||
override func didLoad() {
|
override func didLoad() {
|
||||||
super.didLoad()
|
super.didLoad()
|
||||||
|
|
||||||
|
let hierarchyTrackingNode = HierarchyTrackingNode({ [weak self] value in
|
||||||
|
if !value {
|
||||||
|
self?.animator?.stopAnimation(true)
|
||||||
|
self?.animator = nil
|
||||||
|
}
|
||||||
|
})
|
||||||
|
self.hierarchyTrackingNode = hierarchyTrackingNode
|
||||||
|
self.addSubnode(hierarchyTrackingNode)
|
||||||
|
|
||||||
self.fadeNode.backgroundColor = .black
|
self.fadeNode.backgroundColor = .black
|
||||||
self.fadeNode.alpha = 0.0
|
self.fadeNode.alpha = 0.0
|
||||||
|
|
||||||
@ -3733,25 +3748,33 @@ private class DynamicIslandBlurNode: ASDisplayNode {
|
|||||||
self.addSubnode(self.fadeNode)
|
self.addSubnode(self.fadeNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
func prepare() {
|
private var animator: UIViewPropertyAnimator?
|
||||||
guard let effectView = self.effectView, effectView.layer.animation(forKey: "effect") == nil else {
|
|
||||||
return
|
func prepare() -> Bool {
|
||||||
|
guard self.animator == nil else {
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
UIView.animate(withDuration: 1.0) {
|
let animator = UIViewPropertyAnimator(duration: 1.0, curve: .linear)
|
||||||
effectView.effect = UIBlurEffect(style: .dark)
|
self.animator = animator
|
||||||
|
self.effectView?.effect = nil
|
||||||
|
animator.addAnimations { [weak self] in
|
||||||
|
self?.effectView?.effect = UIBlurEffect(style: .dark)
|
||||||
}
|
}
|
||||||
effectView.layer.speed = 0.0
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func update(_ value: CGFloat) {
|
func update(_ value: CGFloat) {
|
||||||
let fadeAlpha = min(1.0, max(0.0, -0.25 + value * 1.55))
|
let fadeAlpha = min(1.0, max(0.0, -0.25 + value * 1.55))
|
||||||
if value > 0.0 {
|
if value > 0.0 {
|
||||||
self.prepare()
|
var value = value
|
||||||
self.effectView?.layer.timeOffset = max(0.0, -0.1 + value * 1.1)
|
let updated = self.prepare()
|
||||||
|
if value > 0.99 && updated {
|
||||||
|
value = 0.99
|
||||||
|
}
|
||||||
|
self.animator?.fractionComplete = max(0.0, -0.1 + value * 1.1)
|
||||||
} else {
|
} else {
|
||||||
self.effectView?.layer.removeAllAnimations()
|
self.animator?.stopAnimation(true)
|
||||||
self.effectView?.layer.speed = 1.0
|
self.animator = nil
|
||||||
self.effectView?.layer.timeOffset = 0.0
|
|
||||||
self.effectView?.effect = nil
|
self.effectView?.effect = nil
|
||||||
}
|
}
|
||||||
self.fadeNode.alpha = fadeAlpha
|
self.fadeNode.alpha = fadeAlpha
|
||||||
|
Loading…
x
Reference in New Issue
Block a user