Pinch fixes

This commit is contained in:
Ali
2021-04-08 21:10:07 +04:00
parent 8fab0d8d3a
commit 5da389087b
5 changed files with 124 additions and 100 deletions

View File

@@ -21,7 +21,6 @@ private let inlineBotNameFont = nameFont
class ChatMessageStickerItemNode: ChatMessageItemView {
private let contextSourceNode: ContextExtractedContentContainingNode
private let containerNode: ContextControllerSourceNode
private let pinchContainerNode: PinchSourceContainerNode
let imageNode: TransformImageNode
private var placeholderNode: StickerShimmerEffectNode
var textNode: TextNode?
@@ -54,7 +53,6 @@ class ChatMessageStickerItemNode: ChatMessageItemView {
required init() {
self.contextSourceNode = ContextExtractedContentContainingNode()
self.containerNode = ContextControllerSourceNode()
self.pinchContainerNode = PinchSourceContainerNode()
self.imageNode = TransformImageNode()
self.placeholderNode = StickerShimmerEffectNode()
self.placeholderNode.isUserInteractionEnabled = false
@@ -121,8 +119,7 @@ class ChatMessageStickerItemNode: ChatMessageItemView {
self.imageNode.displaysAsynchronously = false
self.containerNode.addSubnode(self.contextSourceNode)
self.containerNode.targetNodeForActivationProgress = self.contextSourceNode.contentNode
self.pinchContainerNode.contentNode.addSubnode(self.containerNode)
self.addSubnode(self.pinchContainerNode)
self.addSubnode(self.containerNode)
self.contextSourceNode.contentNode.addSubnode(self.placeholderNode)
self.contextSourceNode.contentNode.addSubnode(self.imageNode)
self.contextSourceNode.contentNode.addSubnode(self.dateAndStatusNode)
@@ -138,23 +135,6 @@ class ChatMessageStickerItemNode: ChatMessageItemView {
}
item.controllerInteraction.openMessageReactions(item.message.id)
}
self.pinchContainerNode.activate = { [weak self] sourceNode in
guard let strongSelf = self, let item = strongSelf.item else {
return
}
item.controllerInteraction.activateMessagePinch(sourceNode)
}
self.pinchContainerNode.scaleUpdated = { [weak self] scale, transition in
guard let strongSelf = self else {
return
}
let factor: CGFloat = max(0.0, min(1.0, (scale - 1.0) * 8.0))
transition.updateAlpha(node: strongSelf.dateAndStatusNode, alpha: 1.0 - factor)
}
}
required init?(coder aDecoder: NSCoder) {
@@ -675,12 +655,9 @@ class ChatMessageStickerItemNode: ChatMessageItemView {
strongSelf.messageAccessibilityArea.frame = CGRect(origin: CGPoint(), size: layoutSize)
strongSelf.containerNode.frame = CGRect(origin: CGPoint(), size: layoutSize)
strongSelf.pinchContainerNode.frame = CGRect(origin: CGPoint(), size: layoutSize)
strongSelf.pinchContainerNode.update(size: layoutSize, transition: .immediate)
strongSelf.contextSourceNode.frame = CGRect(origin: CGPoint(), size: layoutSize)
strongSelf.contextSourceNode.contentNode.frame = CGRect(origin: CGPoint(), size: layoutSize)
strongSelf.contextSourceNode.contentRect = strongSelf.imageNode.frame
strongSelf.pinchContainerNode.contentRect = strongSelf.imageNode.frame
strongSelf.containerNode.targetNodeForActivationProgressContentRect = strongSelf.contextSourceNode.contentRect
dateAndStatusApply(false)