Skip to content

Commit

Permalink
Adjust stars animation
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaac committed Aug 12, 2024
1 parent ea47613 commit 03ee137
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
15 changes: 11 additions & 4 deletions submodules/ReactionSelectionNode/Sources/ReactionContextNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 03ee137

Please sign in to comment.