Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios

This commit is contained in:
Ilya Laktyushin 2022-01-28 14:22:36 +03:00
commit 43b54be499
6 changed files with 46 additions and 10 deletions

View File

@ -660,6 +660,7 @@ public final class ReactionContextNode: ASDisplayNode, UIScrollViewDelegate {
theme: strongSelf.context.sharedContext.currentPresentationData.with({ $0 }).theme,
reaction: itemNode.item,
avatarPeers: [],
playHaptic: false,
isLarge: false,
targetView: targetView,
addStandaloneReactionAnimation: nil,
@ -719,11 +720,32 @@ public final class ReactionContextNode: ASDisplayNode, UIScrollViewDelegate {
guard let strongSelf = self else {
return
}
strongSelf.longPressRecognizer?.state = .cancelled
strongSelf.longPressRecognizer?.state = .ended
}, queue: .mainQueue())
self.longPressTimer?.start()
}
case .ended, .cancelled:
case .changed:
let point = recognizer.location(in: self.view)
var shouldCancel = false
if let itemNode = self.reactionItemNode(at: point) {
if self.highlightedReaction != itemNode.item.reaction {
shouldCancel = true
}
} else {
shouldCancel = true
}
if shouldCancel {
self.longPressRecognizer?.state = .cancelled
}
case .cancelled:
self.longPressTimer?.invalidate()
self.continuousHaptic = nil
self.highlightedReaction = nil
if let (size, insets, anchorRect) = self.validLayout {
self.updateLayout(size: size, insets: insets, anchorRect: anchorRect, transition: .animated(duration: 0.3, curve: .spring), animateInFromAnchorRect: nil, animateOutToAnchorRect: nil, animateReactionHighlight: true)
}
case .ended:
self.longPressTimer?.invalidate()
self.continuousHaptic = nil
self.didTriggerExpandedReaction = true
@ -871,16 +893,20 @@ public final class StandaloneReactionAnimation: ASDisplayNode {
self.isUserInteractionEnabled = false
}
public func animateReactionSelection(context: AccountContext, theme: PresentationTheme, reaction: ReactionContextItem, avatarPeers: [EnginePeer], isLarge: Bool, targetView: UIView, addStandaloneReactionAnimation: ((StandaloneReactionAnimation) -> Void)?, completion: @escaping () -> Void) {
self.animateReactionSelection(context: context, theme: theme, reaction: reaction, avatarPeers: avatarPeers, isLarge: isLarge, targetView: targetView, addStandaloneReactionAnimation: addStandaloneReactionAnimation, currentItemNode: nil, completion: completion)
public func animateReactionSelection(context: AccountContext, theme: PresentationTheme, reaction: ReactionContextItem, avatarPeers: [EnginePeer], playHaptic: Bool, isLarge: Bool, targetView: UIView, addStandaloneReactionAnimation: ((StandaloneReactionAnimation) -> Void)?, completion: @escaping () -> Void) {
self.animateReactionSelection(context: context, theme: theme, reaction: reaction, avatarPeers: avatarPeers, playHaptic: playHaptic, isLarge: isLarge, targetView: targetView, addStandaloneReactionAnimation: addStandaloneReactionAnimation, currentItemNode: nil, completion: completion)
}
func animateReactionSelection(context: AccountContext, theme: PresentationTheme, reaction: ReactionContextItem, avatarPeers: [EnginePeer], isLarge: Bool, targetView: UIView, addStandaloneReactionAnimation: ((StandaloneReactionAnimation) -> Void)?, currentItemNode: ReactionNode?, completion: @escaping () -> Void) {
func animateReactionSelection(context: AccountContext, theme: PresentationTheme, reaction: ReactionContextItem, avatarPeers: [EnginePeer], playHaptic: Bool, isLarge: Bool, targetView: UIView, addStandaloneReactionAnimation: ((StandaloneReactionAnimation) -> Void)?, currentItemNode: ReactionNode?, completion: @escaping () -> Void) {
guard let sourceSnapshotView = targetView.snapshotContentTree() else {
completion()
return
}
if playHaptic {
self.hapticFeedback.tap()
}
self.targetView = targetView
let itemNode: ReactionNode
@ -966,7 +992,7 @@ public final class StandaloneReactionAnimation: ASDisplayNode {
additionalAnimationNode.updateLayout(size: effectFrame.size)
self.addSubnode(additionalAnimationNode)
if !isLarge, let url = getAppBundle().url(forResource: "effectavatar", withExtension: "json"), let composition = LOTComposition(filePath: url.path) {
if !isLarge, !avatarPeers.isEmpty, let url = getAppBundle().url(forResource: "effectavatar", withExtension: "json"), let composition = LOTComposition(filePath: url.path) {
let view = LOTAnimationView(model: composition, in: getAppBundle())
view.animationSpeed = 1.0
view.backgroundColor = nil
@ -1036,6 +1062,7 @@ public final class StandaloneReactionAnimation: ASDisplayNode {
theme: itemNode.context.sharedContext.currentPresentationData.with({ $0 }).theme,
reaction: itemNode.item,
avatarPeers: avatarPeers,
playHaptic: false,
isLarge: false,
targetView: targetView,
addStandaloneReactionAnimation: nil,

View File

@ -171,6 +171,7 @@ class ReactionChatPreviewItemNode: ListViewItemNode {
largeApplicationAnimation: reaction.effectAnimation
),
avatarPeers: [],
playHaptic: false,
isLarge: false,
targetView: targetView,
addStandaloneReactionAnimation: nil,

File diff suppressed because one or more lines are too long

View File

@ -1295,6 +1295,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
largeApplicationAnimation: reaction.effectAnimation
),
avatarPeers: [],
playHaptic: false,
isLarge: false,
targetView: targetView,
addStandaloneReactionAnimation: { standaloneReactionAnimation in
@ -5925,7 +5926,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
}
var avatarPeers: [EnginePeer] = []
if let updatedReactionPeer = updatedReactionPeer {
if item.message.id.peerId.namespace != Namespaces.Peer.CloudUser, let updatedReactionPeer = updatedReactionPeer {
avatarPeers.append(updatedReactionPeer)
}
@ -5960,6 +5961,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
largeApplicationAnimation: reaction.effectAnimation
),
avatarPeers: avatarPeers,
playHaptic: true,
isLarge: updatedReactionIsLarge,
targetView: targetView,
addStandaloneReactionAnimation: { standaloneReactionAnimation in

View File

@ -487,7 +487,6 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
self.addSubnode(self.backgroundNode)
self.addSubnode(self.historyNodeContainer)
self.addSubnode(self.navigateButtons)
self.addSubnode(self.inputPanelBackgroundNode)
self.addSubnode(self.inputPanelBackgroundSeparatorNode)
@ -499,6 +498,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
}
self.addSubnode(self.messageTransitionNode)
self.addSubnode(self.navigateButtons)
self.addSubnode(self.presentationContextMarker)
self.navigationBar?.additionalContentNode.addSubnode(self.titleAccessoryPanelContainer)

View File

@ -2705,6 +2705,11 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
chatDisplayNode.messageTransitionNode.addMessageStandaloneReactionAnimation(messageId: item.message.id, standaloneReactionAnimation: standaloneReactionAnimation)
var avatarPeers: [EnginePeer] = []
if item.message.id.peerId.namespace != Namespaces.Peer.CloudUser, let updateReactionPeer = updateReactionPeer {
avatarPeers = [updateReactionPeer]
}
chatDisplayNode.addSubnode(standaloneReactionAnimation)
standaloneReactionAnimation.frame = chatDisplayNode.bounds
standaloneReactionAnimation.animateReactionSelection(
@ -2719,7 +2724,8 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
applicationAnimation: aroundAnimation,
largeApplicationAnimation: reaction.effectAnimation
),
avatarPeers: updateReactionPeer.flatMap({ [$0] }) ?? [],
avatarPeers: avatarPeers,
playHaptic: true,
isLarge: updatedReactionIsLarge,
targetView: targetView,
addStandaloneReactionAnimation: { [weak self] standaloneReactionAnimation in