From 03ee1379b2b5222bc63c1d9ea3c1545459ba72ba Mon Sep 17 00:00:00 2001 From: Isaac <> Date: Mon, 12 Aug 2024 12:20:02 +0400 Subject: [PATCH] Adjust stars animation --- .../Sources/ReactionContextNode.swift | 15 +++++++++++---- .../Sources/ReactionSelectionNode.swift | 6 ++++++ .../Sources/ChatMessageBubbleItemNode.swift | 1 - .../Sources/StringForMessageTimestampStatus.swift | 2 -- .../Sources/ChatMessageItemImpl.swift | 1 - 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/submodules/ReactionSelectionNode/Sources/ReactionContextNode.swift b/submodules/ReactionSelectionNode/Sources/ReactionContextNode.swift index c8ae04d025..5cc21aa8ff 100644 --- a/submodules/ReactionSelectionNode/Sources/ReactionContextNode.swift +++ b/submodules/ReactionSelectionNode/Sources/ReactionContextNode.swift @@ -2622,6 +2622,8 @@ public final class ReactionContextNode: ASDisplayNode, ASScrollViewDelegate { } } + foundItemNode?.animateHideEffects() + if let customReactionSource = self.customReactionSource { let itemNode = ReactionNode(context: self.context, theme: self.presentationData.theme, item: customReactionSource.item, icon: .none, animationCache: self.animationCache, animationRenderer: self.animationRenderer, loopIdle: false, isLocked: false, useDirectRendering: false) if let contents = customReactionSource.layer.contents { @@ -2673,7 +2675,7 @@ public final class ReactionContextNode: ASDisplayNode, ASScrollViewDelegate { if case .builtin = itemNode.item.reaction.rawValue { selfTargetBounds = selfTargetBounds.insetBy(dx: -selfTargetBounds.width * 0.5, dy: -selfTargetBounds.height * 0.5) } else if case .stars = itemNode.item.reaction.rawValue { - selfTargetBounds = selfTargetBounds.insetBy(dx: selfTargetBounds.width * 0.0, dy: selfTargetBounds.height * 0.0) + selfTargetBounds = selfTargetBounds.insetBy(dx: -selfTargetBounds.width * 0.13, dy: -selfTargetBounds.height * 0.13).offsetBy(dx: -0.5, dy: -0.5) } let selfTargetRect = self.view.convert(selfTargetBounds, from: targetView) @@ -2905,7 +2907,14 @@ public final class ReactionContextNode: ASDisplayNode, ASScrollViewDelegate { }) if !switchToInlineImmediately { - DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + min(5.0, 2.0 * UIView.animationDurationFactor()), execute: { + let maxDuration: Double + if case .stars = value { + maxDuration = 3.0 + } else { + maxDuration = 2.0 + } + + DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + min(5.0, maxDuration * UIView.animationDurationFactor()), execute: { if self.didTriggerExpandedReaction { self.animateFromItemNodeToReaction(itemNode: itemNode, targetView: targetView, hideNode: hideNode, completion: { [weak self] in if let strongSelf = self, strongSelf.didTriggerExpandedReaction, let addStandaloneReactionAnimation = addStandaloneReactionAnimation { @@ -3986,8 +3995,6 @@ public final class StandaloneReactionAnimation: ASDisplayNode { starView.isHidden = true } else { targetView.updateIsAnimationHidden(isAnimationHidden: true, transition: .immediate) - //TODO:release - //targetView.addSubnode(itemNode) } } else if let targetView = targetView as? UIImageView { starView.isHidden = true diff --git a/submodules/ReactionSelectionNode/Sources/ReactionSelectionNode.swift b/submodules/ReactionSelectionNode/Sources/ReactionSelectionNode.swift index 2da4a49198..79bc8bfbee 100644 --- a/submodules/ReactionSelectionNode/Sources/ReactionSelectionNode.swift +++ b/submodules/ReactionSelectionNode/Sources/ReactionSelectionNode.swift @@ -296,6 +296,12 @@ public final class ReactionNode: ASDisplayNode, ReactionItemNode { self.customContentsNode?.contents = contents } + public func animateHideEffects() { + if let starsEffectLayer = self.starsEffectLayer { + starsEffectLayer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false) + } + } + public func updateLayout(size: CGSize, isExpanded: Bool, largeExpanded: Bool, isPreviewing: Bool, transition: ContainedViewLayoutTransition) { let intrinsicSize = size diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift index a3eee1731e..6834eb6632 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift @@ -1550,7 +1550,6 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI } } - //TODO:release if let channel = firstMessage.peers[firstMessage.id.peerId] as? TelegramChannel, case let .broadcast(info) = channel.info, firstMessage.author?.id != channel.id { if info.flags.contains(.messagesShouldHaveProfiles) { var allowAuthor = incoming diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageDateAndStatusNode/Sources/StringForMessageTimestampStatus.swift b/submodules/TelegramUI/Components/Chat/ChatMessageDateAndStatusNode/Sources/StringForMessageTimestampStatus.swift index 107fa3575c..251d880612 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageDateAndStatusNode/Sources/StringForMessageTimestampStatus.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageDateAndStatusNode/Sources/StringForMessageTimestampStatus.swift @@ -127,7 +127,6 @@ public func stringForMessageTimestampStatus(accountPeerId: PeerId, message: Mess if let author = message.author as? TelegramUser { if let peer = message.peers[message.id.peerId] as? TelegramChannel, case .broadcast = peer.info { if let channel = message.peers[message.id.peerId] as? TelegramChannel, case let .broadcast(info) = channel.info, message.author?.id != channel.id, info.flags.contains(.messagesShouldHaveProfiles) { - //TODO:release } else { authorTitle = EnginePeer(author).displayTitle(strings: strings, displayOrder: nameDisplayOrder) } @@ -137,7 +136,6 @@ public func stringForMessageTimestampStatus(accountPeerId: PeerId, message: Mess } else { if let peer = message.peers[message.id.peerId] as? TelegramChannel, case .broadcast = peer.info { if let channel = message.peers[message.id.peerId] as? TelegramChannel, case let .broadcast(info) = channel.info, message.author?.id != channel.id, info.flags.contains(.messagesShouldHaveProfiles) { - //TODO:release } else { for attribute in message.attributes { if let attribute = attribute as? AuthorSignatureMessageAttribute { diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageItemImpl/Sources/ChatMessageItemImpl.swift b/submodules/TelegramUI/Components/Chat/ChatMessageItemImpl/Sources/ChatMessageItemImpl.swift index 9a4c368005..f7519dfeb3 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageItemImpl/Sources/ChatMessageItemImpl.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageItemImpl/Sources/ChatMessageItemImpl.swift @@ -345,7 +345,6 @@ public final class ChatMessageItemImpl: ChatMessageItem, CustomStringConvertible if !isBroadcastChannel { hasAvatar = true } else if let channel = message.peers[message.id.peerId] as? TelegramChannel, case let .broadcast(info) = channel.info, message.author?.id != channel.id { - //TODO:release if info.flags.contains(.messagesShouldHaveProfiles) { hasAvatar = true effectiveAuthor = message.author