diff --git a/submodules/Display/Source/ListView.swift b/submodules/Display/Source/ListView.swift index 25a669b16c..b482bc67ad 100644 --- a/submodules/Display/Source/ListView.swift +++ b/submodules/Display/Source/ListView.swift @@ -3347,6 +3347,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture if progress == 1.0 { for itemNode in temporaryPreviousNodes { + itemNode.visibility = .none itemNode.removeFromSupernode() itemNode.extractedBackgroundNode?.removeFromSupernode() } @@ -3360,6 +3361,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture } else { animation.completion = { _ in for itemNode in temporaryPreviousNodes { + itemNode.visibility = .none itemNode.removeFromSupernode() itemNode.extractedBackgroundNode?.removeFromSupernode() } @@ -3442,6 +3444,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture private func removeItemNodeAtIndex(_ index: Int) { let node = self.itemNodes[index] self.itemNodes.remove(at: index) + node.visibility = .none node.removeFromSupernode() node.extractedBackgroundNode?.removeFromSupernode() node.accessoryItemNode?.removeFromSupernode() diff --git a/submodules/PremiumUI/Sources/FasterStarsView.swift b/submodules/PremiumUI/Sources/FasterStarsView.swift index f80b621f70..a96b632a1f 100644 --- a/submodules/PremiumUI/Sources/FasterStarsView.swift +++ b/submodules/PremiumUI/Sources/FasterStarsView.swift @@ -3,6 +3,7 @@ import UIKit import SceneKit import Display import AppBundle +import LegacyComponents final class FasterStarsView: UIView, PhoneDemoDecorationView { private let sceneView: SCNView @@ -55,23 +56,37 @@ final class FasterStarsView: UIView, PhoneDemoDecorationView { } self.playing = true - let speedAnimation = CABasicAnimation(keyPath: "speedFactor") - speedAnimation.fromValue = 1.0 - speedAnimation.toValue = 1.8 + let speedAnimation = POPBasicAnimation() + speedAnimation.property = (POPAnimatableProperty.property(withName: "speedFactor", initializer: { property in + property?.readBlock = { particleSystem, values in + values?.pointee = (particleSystem as! SCNParticleSystem).speedFactor + } + property?.writeBlock = { particleSystem, values in + (particleSystem as! SCNParticleSystem).speedFactor = values!.pointee + } + property?.threshold = 0.01 + }) as! POPAnimatableProperty) + speedAnimation.fromValue = 1.0 as NSNumber + speedAnimation.toValue = 3.0 as NSNumber + speedAnimation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.linear) speedAnimation.duration = 0.8 - speedAnimation.fillMode = .forwards - particles.addAnimation(speedAnimation, forKey: "speedFactor") + particles.pop_add(speedAnimation, forKey: "speedFactor") - particles.speedFactor = 3.0 - - let stretchAnimation = CABasicAnimation(keyPath: "stretchFactor") - stretchAnimation.fromValue = 0.05 - stretchAnimation.toValue = 0.3 + let stretchAnimation = POPBasicAnimation() + stretchAnimation.property = (POPAnimatableProperty.property(withName: "stretchFactor", initializer: { property in + property?.readBlock = { particleSystem, values in + values?.pointee = (particleSystem as! SCNParticleSystem).stretchFactor + } + property?.writeBlock = { particleSystem, values in + (particleSystem as! SCNParticleSystem).stretchFactor = values!.pointee + } + property?.threshold = 0.01 + }) as! POPAnimatableProperty) + stretchAnimation.fromValue = 0.05 as NSNumber + stretchAnimation.toValue = 0.3 as NSNumber + stretchAnimation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.linear) stretchAnimation.duration = 0.8 - stretchAnimation.fillMode = .forwards - particles.addAnimation(stretchAnimation, forKey: "stretchFactor") - - particles.stretchFactor = 0.3 + particles.pop_add(stretchAnimation, forKey: "stretchFactor") } func resetAnimation() { @@ -79,24 +94,38 @@ final class FasterStarsView: UIView, PhoneDemoDecorationView { return } self.playing = false - - let speedAnimation = CABasicAnimation(keyPath: "speedFactor") - speedAnimation.fromValue = 3.0 - speedAnimation.toValue = 1.0 + + let speedAnimation = POPBasicAnimation() + speedAnimation.property = (POPAnimatableProperty.property(withName: "speedFactor", initializer: { property in + property?.readBlock = { particleSystem, values in + values?.pointee = (particleSystem as! SCNParticleSystem).speedFactor + } + property?.writeBlock = { particleSystem, values in + (particleSystem as! SCNParticleSystem).speedFactor = values!.pointee + } + property?.threshold = 0.01 + }) as! POPAnimatableProperty) + speedAnimation.fromValue = 3.0 as NSNumber + speedAnimation.toValue = 1.0 as NSNumber + speedAnimation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.linear) speedAnimation.duration = 0.35 - speedAnimation.fillMode = .forwards - particles.addAnimation(speedAnimation, forKey: "speedFactor") + particles.pop_add(speedAnimation, forKey: "speedFactor") - particles.speedFactor = 1.0 - - let stretchAnimation = CABasicAnimation(keyPath: "stretchFactor") - stretchAnimation.fromValue = 0.3 - stretchAnimation.toValue = 0.05 + let stretchAnimation = POPBasicAnimation() + stretchAnimation.property = (POPAnimatableProperty.property(withName: "stretchFactor", initializer: { property in + property?.readBlock = { particleSystem, values in + values?.pointee = (particleSystem as! SCNParticleSystem).stretchFactor + } + property?.writeBlock = { particleSystem, values in + (particleSystem as! SCNParticleSystem).stretchFactor = values!.pointee + } + property?.threshold = 0.01 + }) as! POPAnimatableProperty) + stretchAnimation.fromValue = 0.3 as NSNumber + stretchAnimation.toValue = 0.05 as NSNumber + stretchAnimation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.linear) stretchAnimation.duration = 0.35 - stretchAnimation.fillMode = .forwards - particles.addAnimation(stretchAnimation, forKey: "stretchFactor") - - particles.stretchFactor = 0.05 + particles.pop_add(stretchAnimation, forKey: "stretchFactor") } override func layoutSubviews() { diff --git a/submodules/TelegramUI/Sources/ChatMediaInputNode.swift b/submodules/TelegramUI/Sources/ChatMediaInputNode.swift index 3eda31a7fb..e50820d4b6 100644 --- a/submodules/TelegramUI/Sources/ChatMediaInputNode.swift +++ b/submodules/TelegramUI/Sources/ChatMediaInputNode.swift @@ -295,7 +295,7 @@ func chatMediaInputGridEntries(view: ItemCollectionsView, savedStickers: Ordered let filteredTrending = trendingPacks.filter { !installedPacks.contains($0.info.id) } if !trendingIsDismissed && !filteredTrending.isEmpty { - entries.append(.trendingList(theme: theme, strings: strings, packs: filteredTrending, isPremium: false)) + entries.append(.trendingList(theme: theme, strings: strings, packs: filteredTrending, isPremium: trendingIsPremium)) } if let recentStickers = recentStickers, !recentStickers.items.isEmpty { diff --git a/submodules/TelegramUI/Sources/ChatMessageAnimatedStickerItemNode.swift b/submodules/TelegramUI/Sources/ChatMessageAnimatedStickerItemNode.swift index 8df35f3722..f6fbf62026 100644 --- a/submodules/TelegramUI/Sources/ChatMessageAnimatedStickerItemNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageAnimatedStickerItemNode.swift @@ -402,11 +402,11 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView { } } - private var visibilityStatus: Bool = false { + private var visibilityStatus: Bool? { didSet { if self.visibilityStatus != oldValue { self.updateVisibility() - self.haptic?.enabled = self.visibilityStatus + self.haptic?.enabled = self.visibilityStatus == true } } } @@ -593,28 +593,18 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView { } } - let isPlaying = self.visibilityStatus && !self.forceStopAnimations - if let animationNode = self.animationNode as? AnimatedStickerNode { - if !isPlaying { - for decorationNode in self.additionalAnimationNodes { - if let transitionNode = item.controllerInteraction.getMessageTransitionNode() { - decorationNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false, completion: { [weak decorationNode] _ in - if let decorationNode = decorationNode { - transitionNode.remove(decorationNode: decorationNode) - } - }) - } - } - self.additionalAnimationNodes.removeAll() - - if let overlayMeshAnimationNode = self.overlayMeshAnimationNode { - self.overlayMeshAnimationNode = nil - if let transitionNode = item.controllerInteraction.getMessageTransitionNode() { - transitionNode.remove(decorationNode: overlayMeshAnimationNode) - } + let isPlaying = self.visibilityStatus == true && !self.forceStopAnimations + if !isPlaying { + self.removeAdditionalAnimations() + + if let overlayMeshAnimationNode = self.overlayMeshAnimationNode { + self.overlayMeshAnimationNode = nil + if let transitionNode = item.controllerInteraction.getMessageTransitionNode() { + transitionNode.remove(decorationNode: overlayMeshAnimationNode) } } - + } + if let animationNode = self.animationNode as? AnimatedStickerNode { if self.isPlaying != isPlaying { self.isPlaying = isPlaying @@ -1721,10 +1711,20 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView { self.additionalAnimationNodes.append(decorationNode) - additionalAnimationNode.play() + additionalAnimationNode.visibility = true } } + private func removeAdditionalAnimations() { + for decorationNode in self.additionalAnimationNodes { + if let additionalAnimationNode = decorationNode.contentView.asyncdisplaykit_node as? AnimatedStickerNode { + additionalAnimationNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false, completion: { [weak additionalAnimationNode] _ in + additionalAnimationNode?.visibility = false + }) + } + } + } + private func gestureRecognized(gesture: TapLongTapOrDoubleTapGesture, location: CGPoint, recognizer: TapLongTapOrDoubleTapGestureRecognizer?) -> InternalBubbleTapAction? { switch gesture { case .tap: