mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-01 07:57:01 +00:00
Playback animated stickers in notification content
This commit is contained in:
parent
afb14ea953
commit
9a37d4d5fe
@ -68,6 +68,7 @@ public final class NotificationViewControllerImpl {
|
||||
private let setPreferredContentSize: (CGSize) -> Void
|
||||
|
||||
private let imageNode = TransformImageNode()
|
||||
private var animatedStickerNode: AnimatedStickerNode?
|
||||
private var imageInfo: (isSticker: Bool, dimensions: CGSize)?
|
||||
|
||||
private let applyDisposable = MetaDisposable()
|
||||
@ -254,12 +255,43 @@ public final class NotificationViewControllerImpl {
|
||||
return (account, fileReference)
|
||||
}
|
||||
}
|
||||
|> deliverOnMainQueue).start(next: { [weak self] accountAndImage in
|
||||
|> deliverOnMainQueue).start(next: { [weak self, weak view] accountAndImage in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
if let fileReference = accountAndImage.1 {
|
||||
if file.isSticker {
|
||||
if file.isAnimatedSticker {
|
||||
let animatedStickerNode: AnimatedStickerNode
|
||||
if let current = strongSelf.animatedStickerNode {
|
||||
animatedStickerNode = current
|
||||
} else {
|
||||
animatedStickerNode = AnimatedStickerNode()
|
||||
strongSelf.animatedStickerNode = animatedStickerNode
|
||||
animatedStickerNode.started = {
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
strongSelf.imageNode.isHidden = true
|
||||
}
|
||||
if !strongSelf.imageNode.frame.width.isZero {
|
||||
animatedStickerNode.frame = strongSelf.imageNode.frame
|
||||
animatedStickerNode.updateLayout(size: strongSelf.imageNode.frame.size)
|
||||
}
|
||||
view?.addSubnode(animatedStickerNode)
|
||||
}
|
||||
strongSelf.imageNode.setSignal(chatMessageAnimatedSticker(postbox: accountAndImage.0.postbox, file: fileReference.media, small: false, size: CGSize(width: 512.0, height: 512.0)))
|
||||
animatedStickerNode.setup(account: accountAndImage.0, resource: fileReference.media.resource, width: 512, height: 512, mode: .direct)
|
||||
animatedStickerNode.visibility = true
|
||||
|
||||
accountAndImage.0.network.shouldExplicitelyKeepWorkerConnections.set(.single(true))
|
||||
strongSelf.fetchedDisposable.set(freeMediaFileInteractiveFetched(account: accountAndImage.0, fileReference: fileReference).start())
|
||||
} else if file.isSticker {
|
||||
if let animatedStickerNode = strongSelf.animatedStickerNode {
|
||||
animatedStickerNode.removeFromSupernode()
|
||||
strongSelf.animatedStickerNode = nil
|
||||
}
|
||||
strongSelf.imageNode.isHidden = false
|
||||
|
||||
strongSelf.imageNode.setSignal(chatMessageSticker(account: accountAndImage.0, file: file, small: false))
|
||||
|
||||
accountAndImage.0.network.shouldExplicitelyKeepWorkerConnections.set(.single(true))
|
||||
@ -288,6 +320,8 @@ public final class NotificationViewControllerImpl {
|
||||
apply()
|
||||
let displaySize = isSticker ? fittedSize : boundingSize
|
||||
self.imageNode.frame = CGRect(origin: CGPoint(x: floor((boundingSize.width - displaySize.width) / 2.0), y: 0.0), size: displaySize)
|
||||
self.animatedStickerNode?.frame = CGRect(origin: CGPoint(x: floor((boundingSize.width - displaySize.width) / 2.0), y: 0.0), size: displaySize)
|
||||
self.animatedStickerNode?.updateLayout(size: displaySize)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user