mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Reaction improvements
This commit is contained in:
@@ -44,6 +44,8 @@ final class ReactionNode: ASDisplayNode {
|
||||
private var stillAnimationNode: AnimatedStickerNode?
|
||||
private var animationNode: AnimatedStickerNode?
|
||||
|
||||
private var dismissedStillAnimationNodes: [AnimatedStickerNode] = []
|
||||
|
||||
private var fetchStickerDisposable: Disposable?
|
||||
private var fetchFullAnimationDisposable: Disposable?
|
||||
|
||||
@@ -81,14 +83,6 @@ final class ReactionNode: ASDisplayNode {
|
||||
strongSelf.animateInAnimationNode = nil
|
||||
}
|
||||
|
||||
/*self.stillAnimationNode.started = { [weak self] in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
strongSelf.animateInAnimationNode.isHidden = true
|
||||
strongSelf.animateInAnimationNode.visibility = false
|
||||
}*/
|
||||
|
||||
self.fetchStickerDisposable = fetchedMediaResource(mediaBox: context.account.postbox.mediaBox, reference: .standalone(resource: item.appearAnimation.resource)).start()
|
||||
self.fetchStickerDisposable = fetchedMediaResource(mediaBox: context.account.postbox.mediaBox, reference: .standalone(resource: item.stillAnimation.resource)).start()
|
||||
self.fetchStickerDisposable = fetchedMediaResource(mediaBox: context.account.postbox.mediaBox, reference: .standalone(resource: item.listAnimation.resource)).start()
|
||||
@@ -185,13 +179,13 @@ final class ReactionNode: ASDisplayNode {
|
||||
self.validSize = size
|
||||
}
|
||||
|
||||
/*if isPreviewing {
|
||||
if isPreviewing {
|
||||
if self.stillAnimationNode == nil {
|
||||
let stillAnimationNode = AnimatedStickerNode()
|
||||
self.stillAnimationNode = stillAnimationNode
|
||||
self.addSubnode(stillAnimationNode)
|
||||
|
||||
stillAnimationNode.setup(source: AnimatedStickerResourceSource(account: self.context.account, resource: self.item.stillAnimation.resource), width: Int(animationDisplaySize.width * 2.0), height: Int(animationDisplaySize.height * 2.0), playbackMode: .once, mode: .direct(cachePathPrefix: self.context.account.postbox.mediaBox.shortLivedResourceCachePathPrefix(self.item.stillAnimation.resource.id)))
|
||||
stillAnimationNode.setup(source: AnimatedStickerResourceSource(account: self.context.account, resource: self.item.stillAnimation.resource), width: Int(animationDisplaySize.width * 2.0), height: Int(animationDisplaySize.height * 2.0), playbackMode: .loop, mode: .direct(cachePathPrefix: self.context.account.postbox.mediaBox.shortLivedResourceCachePathPrefix(self.item.stillAnimation.resource.id)))
|
||||
stillAnimationNode.position = animationFrame.center
|
||||
stillAnimationNode.bounds = CGRect(origin: CGPoint(), size: animationFrame.size)
|
||||
stillAnimationNode.updateLayout(size: animationFrame.size)
|
||||
@@ -199,9 +193,12 @@ final class ReactionNode: ASDisplayNode {
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
let _ = strongSelf
|
||||
strongSelf.staticAnimationNode.alpha = 0.0
|
||||
}
|
||||
stillAnimationNode.visibility = true
|
||||
|
||||
transition.animateTransformScale(node: stillAnimationNode, from: self.staticAnimationNode.bounds.width / animationFrame.width)
|
||||
transition.animatePositionAdditive(node: stillAnimationNode, offset: CGPoint(x: self.staticAnimationNode.frame.midX - animationFrame.midX, y: self.staticAnimationNode.frame.midY - animationFrame.midY))
|
||||
} else {
|
||||
if let stillAnimationNode = self.stillAnimationNode {
|
||||
transition.updatePosition(node: stillAnimationNode, position: animationFrame.center, beginWithCurrentState: true)
|
||||
@@ -210,8 +207,24 @@ final class ReactionNode: ASDisplayNode {
|
||||
}
|
||||
} else if let stillAnimationNode = self.stillAnimationNode {
|
||||
self.stillAnimationNode = nil
|
||||
stillAnimationNode.removeFromSupernode()
|
||||
}*/
|
||||
self.dismissedStillAnimationNodes.append(stillAnimationNode)
|
||||
|
||||
transition.updatePosition(node: stillAnimationNode, position: animationFrame.center, beginWithCurrentState: true)
|
||||
transition.updateTransformScale(node: stillAnimationNode, scale: animationFrame.size.width / stillAnimationNode.bounds.width, beginWithCurrentState: true)
|
||||
|
||||
stillAnimationNode.alpha = 0.0
|
||||
stillAnimationNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.14, completion: { [weak self, weak stillAnimationNode] _ in
|
||||
guard let strongSelf = self, let stillAnimationNode = stillAnimationNode else {
|
||||
return
|
||||
}
|
||||
stillAnimationNode.removeFromSupernode()
|
||||
strongSelf.dismissedStillAnimationNodes.removeAll(where: { $0 === stillAnimationNode })
|
||||
})
|
||||
|
||||
let previousAlpha = CGFloat(self.staticAnimationNode.layer.presentation()?.opacity ?? self.staticAnimationNode.layer.opacity)
|
||||
self.staticAnimationNode.alpha = 1.0
|
||||
self.staticAnimationNode.layer.animateAlpha(from: previousAlpha, to: 1.0, duration: 0.08)
|
||||
}
|
||||
|
||||
if !self.didSetupStillAnimation {
|
||||
if self.animationNode == nil {
|
||||
|
||||
Reference in New Issue
Block a user