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:
@@ -91,7 +91,7 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
|
||||
}
|
||||
let dateAndStatusNode: ChatMessageDateAndStatusNode
|
||||
private var badgeNode: ChatMessageInteractiveMediaBadge?
|
||||
private var tapRecognizer: UITapGestureRecognizer?
|
||||
private var tapRecognizer: TapLongTapOrDoubleTapGestureRecognizer?
|
||||
|
||||
private var context: AccountContext?
|
||||
private var message: Message?
|
||||
@@ -150,6 +150,7 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
|
||||
|
||||
var activateLocalContent: (InteractiveMediaNodeActivateContent) -> Void = { _ in }
|
||||
var activatePinch: ((PinchSourceContainerNode) -> Void)?
|
||||
var updateMessageReaction: ((Message, ChatControllerInteractionReaction) -> Void)?
|
||||
|
||||
override init() {
|
||||
self.pinchContainerNode = PinchSourceContainerNode()
|
||||
@@ -267,9 +268,18 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
|
||||
override func didLoad() {
|
||||
super.didLoad()
|
||||
|
||||
let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.imageTap(_:)))
|
||||
self.imageNode.view.addGestureRecognizer(tapRecognizer)
|
||||
self.tapRecognizer = tapRecognizer
|
||||
let recognizer = TapLongTapOrDoubleTapGestureRecognizer(target: self, action: #selector(self.imageTap(_:)))
|
||||
recognizer.tapActionAtPoint = { [weak self] point in
|
||||
guard let strongSelf = self else {
|
||||
return .fail
|
||||
}
|
||||
if !strongSelf.imageNode.bounds.contains(point) {
|
||||
return .fail
|
||||
}
|
||||
return .waitForDoubleTap
|
||||
}
|
||||
self.imageNode.view.addGestureRecognizer(recognizer)
|
||||
self.tapRecognizer = recognizer
|
||||
}
|
||||
|
||||
private func progressPressed(canActivate: Bool) {
|
||||
@@ -320,26 +330,33 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
|
||||
}
|
||||
}
|
||||
|
||||
@objc func imageTap(_ recognizer: UITapGestureRecognizer) {
|
||||
@objc func imageTap(_ recognizer: TapLongTapOrDoubleTapGestureRecognizer) {
|
||||
if case .ended = recognizer.state {
|
||||
let point = recognizer.location(in: self.imageNode.view)
|
||||
if let _ = self.attributes?.updatingMedia {
|
||||
if let statusNode = self.statusNode, statusNode.frame.contains(point) {
|
||||
self.progressPressed(canActivate: true)
|
||||
}
|
||||
} else if let fetchStatus = self.fetchStatus, case .Local = fetchStatus {
|
||||
var videoContentMatch = true
|
||||
if let content = self.videoContent, case let .message(stableId, mediaId) = content.nativeId {
|
||||
videoContentMatch = self.message?.stableId == stableId && self.media?.id == mediaId
|
||||
}
|
||||
self.activateLocalContent((self.automaticPlayback ?? false) && videoContentMatch ? .automaticPlayback : .default)
|
||||
} else {
|
||||
if let message = self.message, message.flags.isSending {
|
||||
if let statusNode = self.statusNode, statusNode.frame.contains(point) {
|
||||
self.progressPressed(canActivate: true)
|
||||
if let (gesture, point) = recognizer.lastRecognizedGestureAndLocation, let message = self.message {
|
||||
if case .doubleTap = gesture {
|
||||
if canAddMessageReactions(message: message) {
|
||||
self.updateMessageReaction?(message, .default)
|
||||
}
|
||||
} else {
|
||||
self.progressPressed(canActivate: true)
|
||||
if let _ = self.attributes?.updatingMedia {
|
||||
if let statusNode = self.statusNode, statusNode.frame.contains(point) {
|
||||
self.progressPressed(canActivate: true)
|
||||
}
|
||||
} else if let fetchStatus = self.fetchStatus, case .Local = fetchStatus {
|
||||
var videoContentMatch = true
|
||||
if let content = self.videoContent, case let .message(stableId, mediaId) = content.nativeId {
|
||||
videoContentMatch = self.message?.stableId == stableId && self.media?.id == mediaId
|
||||
}
|
||||
self.activateLocalContent((self.automaticPlayback ?? false) && videoContentMatch ? .automaticPlayback : .default)
|
||||
} else {
|
||||
if let message = self.message, message.flags.isSending {
|
||||
if let statusNode = self.statusNode, statusNode.frame.contains(point) {
|
||||
self.progressPressed(canActivate: true)
|
||||
}
|
||||
} else {
|
||||
self.progressPressed(canActivate: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -475,7 +492,7 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
|
||||
impressionCount: dateAndStatus.viewCount,
|
||||
dateText: dateAndStatus.dateText,
|
||||
type: dateAndStatus.type,
|
||||
layoutInput: .standalone,
|
||||
layoutInput: .standalone(reactionSettings: shouldDisplayInlineDateReactions(message: message) ? ChatMessageDateAndStatusNode.StandaloneReactionSettings() : nil),
|
||||
constrainedSize: CGSize(width: nativeSize.width - 30.0, height: CGFloat.greatestFiniteMagnitude),
|
||||
availableReactions: associatedData.availableReactions,
|
||||
reactions: dateAndStatus.dateReactions,
|
||||
@@ -868,15 +885,15 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
|
||||
imageApply()
|
||||
|
||||
if let statusApply = statusApply {
|
||||
let dateAndStatusFrame = CGRect(origin: CGPoint(x: cleanImageFrame.width - layoutConstants.image.statusInsets.right - statusSize.width, y: cleanImageFrame.height - layoutConstants.image.statusInsets.bottom - statusSize.height), size: statusSize)
|
||||
if strongSelf.dateAndStatusNode.supernode == nil {
|
||||
strongSelf.pinchContainerNode.contentNode.addSubnode(strongSelf.dateAndStatusNode)
|
||||
statusApply(.None)
|
||||
strongSelf.dateAndStatusNode.frame = dateAndStatusFrame
|
||||
} else {
|
||||
transition.animator.updateFrame(layer: strongSelf.dateAndStatusNode.layer, frame: dateAndStatusFrame, completion: nil)
|
||||
statusApply(transition)
|
||||
}
|
||||
statusApply(transition)
|
||||
|
||||
let dateAndStatusFrame = CGRect(origin: CGPoint(x: cleanImageFrame.width - layoutConstants.image.statusInsets.right - statusSize.width, y: cleanImageFrame.height - layoutConstants.image.statusInsets.bottom - statusSize.height), size: statusSize)
|
||||
|
||||
strongSelf.dateAndStatusNode.frame = dateAndStatusFrame
|
||||
strongSelf.dateAndStatusNode.bounds = CGRect(origin: CGPoint(), size: dateAndStatusFrame.size)
|
||||
} else if strongSelf.dateAndStatusNode.supernode != nil {
|
||||
strongSelf.dateAndStatusNode.removeFromSupernode()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user