Display reactions with all message types

This commit is contained in:
Ali 2021-11-16 21:00:15 +04:00
parent 60b9b135e3
commit a02157d1b2
16 changed files with 213 additions and 14 deletions

View File

@ -865,7 +865,7 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
var edited = false
var viewCount: Int? = nil
var dateReplies = 0
let dateReactions: [MessageReaction] = []
var dateReactions: [MessageReaction] = []
for attribute in item.message.attributes {
if let _ = attribute as? EditedMessageAttribute, isEmoji {
edited = true
@ -875,6 +875,10 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
if let channel = item.message.peers[item.message.id.peerId] as? TelegramChannel, case .group = channel.info {
dateReplies = Int(attribute.count)
}
} else if let attribute = attribute as? PendingReactionsMessageAttribute {
if let value = attribute.value {
dateReactions = [MessageReaction(value: value, count: 1, isSelected: true)]
}
}
}
@ -1295,6 +1299,45 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
} else {
strongSelf.dateAndStatusNode.pressed = nil
}
if let (_, f) = strongSelf.awaitingAppliedReaction {
/*var bounds = strongSelf.bounds
let offset = bounds.origin.x
bounds.origin.x = 0.0
strongSelf.bounds = bounds
var shadowBounds = strongSelf.shadowNode.bounds
let shadowOffset = shadowBounds.origin.x
shadowBounds.origin.x = 0.0
strongSelf.shadowNode.bounds = shadowBounds
if !offset.isZero {
strongSelf.layer.animateBoundsOriginXAdditive(from: offset, to: 0.0, duration: 0.2, timingFunction: kCAMediaTimingFunctionSpring)
}
if !shadowOffset.isZero {
strongSelf.shadowNode.layer.animateBoundsOriginXAdditive(from: shadowOffset, to: 0.0, duration: 0.2, timingFunction: kCAMediaTimingFunctionSpring)
}
if let swipeToReplyNode = strongSelf.swipeToReplyNode {
strongSelf.swipeToReplyNode = nil
swipeToReplyNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false, completion: { [weak swipeToReplyNode] _ in
swipeToReplyNode?.removeFromSupernode()
})
swipeToReplyNode.layer.animateScale(from: 1.0, to: 0.2, duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false)
}
*/
strongSelf.awaitingAppliedReaction = nil
/*var targetNode: ASDisplayNode?
var hideTarget = false
if let awaitingAppliedReaction = awaitingAppliedReaction {
for contentNode in strongSelf.contentNodes {
if let (reactionNode, count) = contentNode.reactionTargetNode(value: awaitingAppliedReaction) {
targetNode = reactionNode
hideTarget = count == 1
break
}
}
}
strongSelf.reactionRecognizer?.complete(into: targetNode, hideTarget: hideTarget)*/
f()
}
}
})
}
@ -2197,6 +2240,13 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
}
}
}
override func targetReactionNode(value: String) -> (ASDisplayNode, ASDisplayNode)? {
if !self.dateAndStatusNode.isHidden {
return self.dateAndStatusNode.reactionNode(value: value)
}
return nil
}
}
struct AnimatedEmojiSoundsConfiguration {

View File

@ -224,7 +224,7 @@ final class ChatMessageAttachedContentNode: ASDisplayNode {
private var contentFileNode: ChatMessageInteractiveFileNode?
private var buttonNode: ChatMessageAttachedContentButtonNode?
private let statusNode: ChatMessageDateAndStatusNode
let statusNode: ChatMessageDateAndStatusNode
private var additionalImageBadgeNode: ChatMessageInteractiveMediaBadge?
private var linkHighlightingNode: LinkHighlightingNode?
@ -322,7 +322,7 @@ final class ChatMessageAttachedContentNode: ASDisplayNode {
}
var viewCount: Int?
var dateReplies = 0
let dateReactions: [MessageReaction] = []
var dateReactions: [MessageReaction] = []
for attribute in message.attributes {
if let attribute = attribute as? EditedMessageAttribute {
edited = !attribute.isHidden
@ -332,6 +332,10 @@ final class ChatMessageAttachedContentNode: ASDisplayNode {
if let channel = message.peers[message.id.peerId] as? TelegramChannel, case .group = channel.info {
dateReplies = Int(attribute.count)
}
} else if let attribute = attribute as? PendingReactionsMessageAttribute {
if let value = attribute.value {
dateReactions = [MessageReaction(value: value, count: 1, isSelected: true)]
}
}
}

View File

@ -1470,7 +1470,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
}
var viewCount: Int?
var dateReplies = 0
let dateReactions: [MessageReaction] = []
var dateReactions: [MessageReaction] = []
for attribute in message.attributes {
if let attribute = attribute as? EditedMessageAttribute {
edited = !attribute.isHidden
@ -1480,6 +1480,10 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
if let channel = message.peers[message.id.peerId] as? TelegramChannel, case .group = channel.info {
dateReplies = Int(attribute.count)
}
} else if let attribute = attribute as? PendingReactionsMessageAttribute {
if let value = attribute.value {
dateReactions = [MessageReaction(value: value, count: 1, isSelected: true)]
}
}
}

View File

@ -154,7 +154,7 @@ class ChatMessageContactBubbleContentNode: ChatMessageBubbleContentNode {
}
var viewCount: Int?
var dateReplies = 0
let dateReactions: [MessageReaction] = []
var dateReactions: [MessageReaction] = []
for attribute in item.message.attributes {
if let attribute = attribute as? EditedMessageAttribute {
edited = !attribute.isHidden
@ -164,6 +164,10 @@ class ChatMessageContactBubbleContentNode: ChatMessageBubbleContentNode {
if let channel = item.message.peers[item.message.id.peerId] as? TelegramChannel, case .group = channel.info {
dateReplies = Int(attribute.count)
}
} else if let attribute = attribute as? PendingReactionsMessageAttribute {
if let value = attribute.value {
dateReactions = [MessageReaction(value: value, count: 1, isSelected: true)]
}
}
}
@ -364,4 +368,11 @@ class ChatMessageContactBubbleContentNode: ChatMessageBubbleContentNode {
let _ = item.controllerInteraction.openMessage(item.message, .default)
}
}
override func reactionTargetNode(value: String) -> (ASDisplayNode, ASDisplayNode)? {
if !self.dateAndStatusNode.isHidden {
return self.dateAndStatusNode.reactionNode(value: value)
}
return nil
}
}

View File

@ -160,4 +160,11 @@ class ChatMessageFileBubbleContentNode: ChatMessageBubbleContentNode {
override func animateRemoved(_ currentTimestamp: Double, duration: Double) {
self.interactiveFileNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false)
}
override func reactionTargetNode(value: String) -> (ASDisplayNode, ASDisplayNode)? {
if !self.interactiveFileNode.dateAndStatusNode.isHidden {
return self.interactiveFileNode.dateAndStatusNode.reactionNode(value: value)
}
return nil
}
}

View File

@ -139,4 +139,11 @@ final class ChatMessageGameBubbleContentNode: ChatMessageBubbleContentNode {
}
return self.contentNode.transitionNode(media: media)
}
override func reactionTargetNode(value: String) -> (ASDisplayNode, ASDisplayNode)? {
if !self.contentNode.statusNode.isHidden {
return self.contentNode.statusNode.reactionNode(value: value)
}
return nil
}
}

View File

@ -1243,4 +1243,11 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureRecognizerD
actionButtonsNode.frame = actionButtonsFrame
}
}
override func targetReactionNode(value: String) -> (ASDisplayNode, ASDisplayNode)? {
if !self.interactiveVideoNode.dateAndStatusNode.isHidden {
return self.interactiveVideoNode.dateAndStatusNode.reactionNode(value: value)
}
return nil
}
}

View File

@ -34,7 +34,7 @@ final class ChatMessageInteractiveFileNode: ASDisplayNode {
private let waveformNode: AudioWaveformNode
private let waveformForegroundNode: AudioWaveformNode
private var waveformScrubbingNode: MediaPlayerScrubbingNode?
private let dateAndStatusNode: ChatMessageDateAndStatusNode
let dateAndStatusNode: ChatMessageDateAndStatusNode
private let consumableContentNode: ASImageNode
private var iconNode: TransformImageNode?
@ -305,7 +305,7 @@ final class ChatMessageInteractiveFileNode: ASDisplayNode {
}
var viewCount: Int?
var dateReplies = 0
let dateReactions: [MessageReaction] = []
var dateReactions: [MessageReaction] = []
for attribute in message.attributes {
if let attribute = attribute as? EditedMessageAttribute {
edited = !attribute.isHidden
@ -315,6 +315,10 @@ final class ChatMessageInteractiveFileNode: ASDisplayNode {
if let channel = message.peers[message.id.peerId] as? TelegramChannel, case .group = channel.info {
dateReplies = Int(attribute.count)
}
} else if let attribute = attribute as? PendingReactionsMessageAttribute {
if let value = attribute.value {
dateReactions = [MessageReaction(value: value, count: 1, isSelected: true)]
}
}
}
if forcedIsEdited {

View File

@ -50,7 +50,7 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
private var durationBackgroundNode: NavigationBackgroundNode?
private var durationNode: ChatInstantVideoMessageDurationNode?
private let dateAndStatusNode: ChatMessageDateAndStatusNode
let dateAndStatusNode: ChatMessageDateAndStatusNode
private let infoBackgroundNode: ASImageNode
private let muteIconNode: ASImageNode
@ -262,7 +262,7 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
let sentViaBot = false
var viewCount: Int? = nil
var dateReplies = 0
let dateReactions: [MessageReaction] = []
var dateReactions: [MessageReaction] = []
for attribute in item.message.attributes {
if let attribute = attribute as? EditedMessageAttribute {
edited = !attribute.isHidden
@ -272,6 +272,10 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
if let channel = item.message.peers[item.message.id.peerId] as? TelegramChannel, case .group = channel.info {
dateReplies = Int(attribute.count)
}
} else if let attribute = attribute as? PendingReactionsMessageAttribute {
if let value = attribute.value {
dateReactions = [MessageReaction(value: value, count: 1, isSelected: true)]
}
}
}

View File

@ -135,4 +135,11 @@ final class ChatMessageInvoiceBubbleContentNode: ChatMessageBubbleContentNode {
}
return self.contentNode.transitionNode(media: media)
}
override func reactionTargetNode(value: String) -> (ASDisplayNode, ASDisplayNode)? {
if !self.contentNode.statusNode.isHidden {
return self.contentNode.statusNode.reactionNode(value: value)
}
return nil
}
}

View File

@ -183,7 +183,7 @@ class ChatMessageMapBubbleContentNode: ChatMessageBubbleContentNode {
}
var viewCount: Int?
var dateReplies = 0
let dateReactions: [MessageReaction] = []
var dateReactions: [MessageReaction] = []
for attribute in item.message.attributes {
if let attribute = attribute as? EditedMessageAttribute {
edited = !attribute.isHidden
@ -193,6 +193,10 @@ class ChatMessageMapBubbleContentNode: ChatMessageBubbleContentNode {
if let channel = item.message.peers[item.message.id.peerId] as? TelegramChannel, case .group = channel.info {
dateReplies = Int(attribute.count)
}
} else if let attribute = attribute as? PendingReactionsMessageAttribute {
if let value = attribute.value {
dateReactions = [MessageReaction(value: value, count: 1, isSelected: true)]
}
}
}
@ -486,4 +490,11 @@ class ChatMessageMapBubbleContentNode: ChatMessageBubbleContentNode {
}
}
}
override func reactionTargetNode(value: String) -> (ASDisplayNode, ASDisplayNode)? {
if !self.dateAndStatusNode.isHidden {
return self.dateAndStatusNode.reactionNode(value: value)
}
return nil
}
}

View File

@ -152,7 +152,7 @@ class ChatMessageMediaBubbleContentNode: ChatMessageBubbleContentNode {
}
var viewCount: Int?
var dateReplies = 0
let dateReactions: [MessageReaction] = []
var dateReactions: [MessageReaction] = []
for attribute in item.message.attributes {
if let attribute = attribute as? EditedMessageAttribute {
if case .mosaic = preparePosition {
@ -165,6 +165,10 @@ class ChatMessageMediaBubbleContentNode: ChatMessageBubbleContentNode {
if let channel = item.message.peers[item.message.id.peerId] as? TelegramChannel, case .group = channel.info {
dateReplies = Int(attribute.count)
}
} else if let attribute = attribute as? PendingReactionsMessageAttribute {
if let value = attribute.value {
dateReactions = [MessageReaction(value: value, count: 1, isSelected: true)]
}
}
}
@ -387,4 +391,11 @@ class ChatMessageMediaBubbleContentNode: ChatMessageBubbleContentNode {
return false
}
override func reactionTargetNode(value: String) -> (ASDisplayNode, ASDisplayNode)? {
if !self.interactiveImageNode.dateAndStatusNode.isHidden {
return self.interactiveImageNode.dateAndStatusNode.reactionNode(value: value)
}
return nil
}
}

View File

@ -1024,7 +1024,7 @@ class ChatMessagePollBubbleContentNode: ChatMessageBubbleContentNode {
}
var viewCount: Int?
var dateReplies = 0
let dateReactions: [MessageReaction] = []
var dateReactions: [MessageReaction] = []
for attribute in item.message.attributes {
if let attribute = attribute as? EditedMessageAttribute {
edited = !attribute.isHidden
@ -1034,6 +1034,10 @@ class ChatMessagePollBubbleContentNode: ChatMessageBubbleContentNode {
if let channel = item.message.peers[item.message.id.peerId] as? TelegramChannel, case .group = channel.info {
dateReplies = Int(attribute.count)
}
} else if let attribute = attribute as? PendingReactionsMessageAttribute {
if let value = attribute.value {
dateReactions = [MessageReaction(value: value, count: 1, isSelected: true)]
}
}
}
@ -1748,6 +1752,13 @@ class ChatMessagePollBubbleContentNode: ChatMessageBubbleContentNode {
transition.updateSublayerTransformScale(node: self.solutionButtonNode, scale: displaySolutionButton ? 1.0 : 0.1)
}
}
override func reactionTargetNode(value: String) -> (ASDisplayNode, ASDisplayNode)? {
if !self.statusNode.isHidden {
return self.statusNode.reactionNode(value: value)
}
return nil
}
}
private enum PeerAvatarReference: Equatable {

View File

@ -53,7 +53,7 @@ class ChatMessageRestrictedBubbleContentNode: ChatMessageBubbleContentNode {
var viewCount: Int?
var rawText = ""
var dateReplies = 0
let dateReactions: [MessageReaction] = []
var dateReactions: [MessageReaction] = []
for attribute in item.message.attributes {
if let attribute = attribute as? EditedMessageAttribute {
edited = !attribute.isHidden
@ -65,6 +65,10 @@ class ChatMessageRestrictedBubbleContentNode: ChatMessageBubbleContentNode {
if let channel = item.message.peers[item.message.id.peerId] as? TelegramChannel, case .group = channel.info {
dateReplies = Int(attribute.count)
}
} else if let attribute = attribute as? PendingReactionsMessageAttribute {
if let value = attribute.value {
dateReactions = [MessageReaction(value: value, count: 1, isSelected: true)]
}
}
}

View File

@ -459,7 +459,7 @@ class ChatMessageStickerItemNode: ChatMessageItemView {
var edited = false
var viewCount: Int? = nil
var dateReplies = 0
let dateReactions: [MessageReaction] = []
var dateReactions: [MessageReaction] = []
for attribute in item.message.attributes {
if let _ = attribute as? EditedMessageAttribute, isEmoji {
edited = true
@ -469,6 +469,10 @@ class ChatMessageStickerItemNode: ChatMessageItemView {
if let channel = item.message.peers[item.message.id.peerId] as? TelegramChannel, case .group = channel.info {
dateReplies = Int(attribute.count)
}
} else if let attribute = attribute as? PendingReactionsMessageAttribute {
if let value = attribute.value {
dateReactions = [MessageReaction(value: value, count: 1, isSelected: true)]
}
}
}
@ -925,6 +929,45 @@ class ChatMessageStickerItemNode: ChatMessageItemView {
} else {
strongSelf.dateAndStatusNode.pressed = nil
}
if let (_, f) = strongSelf.awaitingAppliedReaction {
/*var bounds = strongSelf.bounds
let offset = bounds.origin.x
bounds.origin.x = 0.0
strongSelf.bounds = bounds
var shadowBounds = strongSelf.shadowNode.bounds
let shadowOffset = shadowBounds.origin.x
shadowBounds.origin.x = 0.0
strongSelf.shadowNode.bounds = shadowBounds
if !offset.isZero {
strongSelf.layer.animateBoundsOriginXAdditive(from: offset, to: 0.0, duration: 0.2, timingFunction: kCAMediaTimingFunctionSpring)
}
if !shadowOffset.isZero {
strongSelf.shadowNode.layer.animateBoundsOriginXAdditive(from: shadowOffset, to: 0.0, duration: 0.2, timingFunction: kCAMediaTimingFunctionSpring)
}
if let swipeToReplyNode = strongSelf.swipeToReplyNode {
strongSelf.swipeToReplyNode = nil
swipeToReplyNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false, completion: { [weak swipeToReplyNode] _ in
swipeToReplyNode?.removeFromSupernode()
})
swipeToReplyNode.layer.animateScale(from: 1.0, to: 0.2, duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false)
}
*/
strongSelf.awaitingAppliedReaction = nil
/*var targetNode: ASDisplayNode?
var hideTarget = false
if let awaitingAppliedReaction = awaitingAppliedReaction {
for contentNode in strongSelf.contentNodes {
if let (reactionNode, count) = contentNode.reactionTargetNode(value: awaitingAppliedReaction) {
targetNode = reactionNode
hideTarget = count == 1
break
}
}
}
strongSelf.reactionRecognizer?.complete(into: targetNode, hideTarget: hideTarget)*/
f()
}
}
})
}
@ -1468,4 +1511,11 @@ class ChatMessageStickerItemNode: ChatMessageItemView {
}
}
}
override func targetReactionNode(value: String) -> (ASDisplayNode, ASDisplayNode)? {
if !self.dateAndStatusNode.isHidden {
return self.dateAndStatusNode.reactionNode(value: value)
}
return nil
}
}

View File

@ -542,4 +542,11 @@ final class ChatMessageWebpageBubbleContentNode: ChatMessageBubbleContentNode {
let contentNodeFrame = self.contentNode.frame
self.contentNode.updateTouchesAtPoint(point.flatMap { $0.offsetBy(dx: -contentNodeFrame.minX, dy: -contentNodeFrame.minY) })
}
override func reactionTargetNode(value: String) -> (ASDisplayNode, ASDisplayNode)? {
if !self.contentNode.statusNode.isHidden {
return self.contentNode.statusNode.reactionNode(value: value)
}
return nil
}
}