mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Various fixes
This commit is contained in:
@@ -63,7 +63,7 @@ final class MessageReactionButtonsNode: ASDisplayNode {
|
||||
private var backgroundMaskButtons: [String: UIView] = [:]
|
||||
|
||||
var reactionSelected: ((String) -> Void)?
|
||||
var openReactionPreview: ((ContextGesture?, ContextExtractedContentContainingNode, String) -> Void)?
|
||||
var openReactionPreview: ((ContextGesture?, ContextExtractedContentContainingView, String) -> Void)?
|
||||
|
||||
override init() {
|
||||
self.container = ReactionButtonsAsyncLayoutContainer()
|
||||
@@ -304,23 +304,23 @@ final class MessageReactionButtonsNode: ASDisplayNode {
|
||||
strongSelf.backgroundMaskButtons[item.value] = itemMaskView
|
||||
}
|
||||
|
||||
if item.node.supernode == nil {
|
||||
strongSelf.addSubnode(item.node)
|
||||
if item.node.view.superview == nil {
|
||||
strongSelf.view.addSubview(item.node.view)
|
||||
if animation.isAnimated {
|
||||
item.node.layer.animateScale(from: 0.01, to: 1.0, duration: 0.4, timingFunction: kCAMediaTimingFunctionSpring)
|
||||
item.node.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
|
||||
item.node.view.layer.animateScale(from: 0.01, to: 1.0, duration: 0.4, timingFunction: kCAMediaTimingFunctionSpring)
|
||||
item.node.view.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
|
||||
}
|
||||
item.node.frame = itemFrame
|
||||
item.node.view.frame = itemFrame
|
||||
} else {
|
||||
animation.animator.updateFrame(layer: item.node.layer, frame: itemFrame, completion: nil)
|
||||
animation.animator.updateFrame(layer: item.node.view.layer, frame: itemFrame, completion: nil)
|
||||
}
|
||||
|
||||
let itemValue = item.value
|
||||
let itemNode = item.node
|
||||
item.node.isGestureEnabled = true
|
||||
item.node.view.isGestureEnabled = true
|
||||
let canViewReactionList = canViewMessageReactionList(message: message)
|
||||
item.node.activateAfterCompletion = !canViewReactionList
|
||||
item.node.activated = { [weak itemNode] gesture, _ in
|
||||
item.node.view.activateAfterCompletion = !canViewReactionList
|
||||
item.node.view.activated = { [weak itemNode] gesture, _ in
|
||||
guard let strongSelf = self, let itemNode = itemNode else {
|
||||
gesture.cancel()
|
||||
return
|
||||
@@ -328,9 +328,9 @@ final class MessageReactionButtonsNode: ASDisplayNode {
|
||||
if !canViewReactionList {
|
||||
return
|
||||
}
|
||||
strongSelf.openReactionPreview?(gesture, itemNode.containerNode, itemValue)
|
||||
strongSelf.openReactionPreview?(gesture, itemNode.view.containerView, itemValue)
|
||||
}
|
||||
item.node.additionalActivationProgressLayer = itemMaskView.layer
|
||||
item.node.view.additionalActivationProgressLayer = itemMaskView.layer
|
||||
|
||||
if itemMaskView.superview == nil {
|
||||
strongSelf.backgroundMaskView?.addSubview(itemMaskView)
|
||||
@@ -364,12 +364,12 @@ final class MessageReactionButtonsNode: ASDisplayNode {
|
||||
|
||||
for node in reactionButtons.removedNodes {
|
||||
if animation.isAnimated {
|
||||
node.layer.animateScale(from: 1.0, to: 0.01, duration: 0.2, removeOnCompletion: false)
|
||||
node.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false, completion: { [weak node] _ in
|
||||
node?.removeFromSupernode()
|
||||
node.view.layer.animateScale(from: 1.0, to: 0.01, duration: 0.2, removeOnCompletion: false)
|
||||
node.view.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false, completion: { [weak node] _ in
|
||||
node?.view.removeFromSuperview()
|
||||
})
|
||||
} else {
|
||||
node.removeFromSupernode()
|
||||
node.view.removeFromSuperview()
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -409,7 +409,7 @@ final class MessageReactionButtonsNode: ASDisplayNode {
|
||||
func reactionTargetView(value: String) -> UIView? {
|
||||
for (key, button) in self.container.buttons {
|
||||
if key == value {
|
||||
return button.iconView
|
||||
return button.view.iconView
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -417,20 +417,20 @@ final class MessageReactionButtonsNode: ASDisplayNode {
|
||||
|
||||
func animateIn(animation: ListViewItemUpdateAnimation) {
|
||||
for (_, button) in self.container.buttons {
|
||||
animation.animator.animateScale(layer: button.layer, from: 0.01, to: 1.0, completion: nil)
|
||||
animation.animator.animateScale(layer: button.view.layer, from: 0.01, to: 1.0, completion: nil)
|
||||
}
|
||||
}
|
||||
|
||||
func animateOut(animation: ListViewItemUpdateAnimation) {
|
||||
for (_, button) in self.container.buttons {
|
||||
animation.animator.updateScale(layer: button.layer, scale: 0.01, completion: nil)
|
||||
animation.animator.updateScale(layer: button.view.layer, scale: 0.01, completion: nil)
|
||||
}
|
||||
}
|
||||
|
||||
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
||||
for (_, button) in self.container.buttons {
|
||||
if button.frame.contains(point) {
|
||||
if let result = button.hitTest(self.view.convert(point, to: button.view), with: event) {
|
||||
if button.view.frame.contains(point) {
|
||||
if let result = button.view.hitTest(self.view.convert(point, to: button.view), with: event) {
|
||||
return result
|
||||
}
|
||||
}
|
||||
@@ -600,7 +600,7 @@ final class ChatMessageReactionButtonsNode: ASDisplayNode {
|
||||
private let buttonsNode: MessageReactionButtonsNode
|
||||
|
||||
var reactionSelected: ((String) -> Void)?
|
||||
var openReactionPreview: ((ContextGesture?, ContextExtractedContentContainingNode, String) -> Void)?
|
||||
var openReactionPreview: ((ContextGesture?, ContextExtractedContentContainingView, String) -> Void)?
|
||||
|
||||
override init() {
|
||||
self.buttonsNode = MessageReactionButtonsNode()
|
||||
|
||||
Reference in New Issue
Block a user