Avatar improvements

This commit is contained in:
Ilya Laktyushin
2023-01-31 16:07:55 +04:00
parent a6009be37c
commit bbf21bfe17
7 changed files with 64 additions and 40 deletions

View File

@@ -180,11 +180,12 @@ final class AvatarPreviewComponent: Component {
self.imageView.frame = CGRect(origin: .zero, size: availableSize)
if previousBackground != component.background {
if let _ = previousBackground, !transition.animation.isImmediate, let snapshotView = self.imageView.snapshotContentTree() {
self.insertSubview(snapshotView, aboveSubview: self.imageView)
snapshotView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false, completion: { [weak snapshotView] _ in
snapshotView?.removeFromSuperview()
if let _ = previousBackground, !transition.animation.isImmediate {
UIView.transition(with: self.imageView, duration: 0.2, options: .transitionCrossDissolve, animations: {
self.imageView.image = component.background.generateImage(size: availableSize)
})
} else {
self.imageView.image = component.background.generateImage(size: availableSize)
}
self.imageView.image = component.background.generateImage(size: availableSize)
}