mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Voice Chat Fixes
This commit is contained in:
@@ -26,10 +26,18 @@ final class VoiceChatTimerNode: ASDisplayNode {
|
||||
|
||||
private var updateTimer: SwiftSignalKit.Timer?
|
||||
|
||||
private let hierarchyTrackingNode: HierarchyTrackingNode
|
||||
private var isCurrentlyInHierarchy = false
|
||||
|
||||
init(strings: PresentationStrings, dateTimeFormat: PresentationDateTimeFormat) {
|
||||
self.strings = strings
|
||||
self.dateTimeFormat = dateTimeFormat
|
||||
|
||||
var updateInHierarchy: ((Bool) -> Void)?
|
||||
self.hierarchyTrackingNode = HierarchyTrackingNode({ value in
|
||||
updateInHierarchy?(value)
|
||||
})
|
||||
|
||||
self.titleNode = ImmediateTextNode()
|
||||
self.subtitleNode = ImmediateTextNode()
|
||||
|
||||
@@ -37,7 +45,10 @@ final class VoiceChatTimerNode: ASDisplayNode {
|
||||
|
||||
super.init()
|
||||
|
||||
self.addSubnode(self.hierarchyTrackingNode)
|
||||
|
||||
self.allowsGroupOpacity = true
|
||||
self.isUserInteractionEnabled = false
|
||||
|
||||
self.foregroundGradientLayer.type = .radial
|
||||
self.foregroundGradientLayer.colors = [pink.cgColor, purple.cgColor, purple.cgColor]
|
||||
@@ -53,6 +64,13 @@ final class VoiceChatTimerNode: ASDisplayNode {
|
||||
self.addSubnode(self.subtitleNode)
|
||||
|
||||
self.maskView.addSubnode(self.timerNode)
|
||||
|
||||
updateInHierarchy = { [weak self] value in
|
||||
if let strongSelf = self {
|
||||
strongSelf.isCurrentlyInHierarchy = value
|
||||
strongSelf.updateAnimations()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
deinit {
|
||||
@@ -60,7 +78,15 @@ final class VoiceChatTimerNode: ASDisplayNode {
|
||||
}
|
||||
|
||||
func animateIn() {
|
||||
self.foregroundView.layer.animateSpring(from: 0.01 as NSNumber, to: 1.0 as NSNumber, keyPath: "transform.scale", duration: 0.42, damping: 104.0)
|
||||
self.foregroundView.layer.animateSpring(from: 0.1 as NSNumber, to: 1.0 as NSNumber, keyPath: "transform.scale", duration: 0.6, damping: 100.0)
|
||||
}
|
||||
|
||||
private func updateAnimations() {
|
||||
if self.isInHierarchy {
|
||||
self.setupGradientAnimations()
|
||||
} else {
|
||||
self.foregroundGradientLayer.removeAllAnimations()
|
||||
}
|
||||
}
|
||||
|
||||
private func setupGradientAnimations() {
|
||||
@@ -78,9 +104,9 @@ final class VoiceChatTimerNode: ASDisplayNode {
|
||||
animation.toValue = newValue
|
||||
|
||||
CATransaction.setCompletionBlock { [weak self] in
|
||||
// if let isCurrentlyInHierarchy = self?.isCurrentlyInHierarchy, isCurrentlyInHierarchy {
|
||||
if let isCurrentlyInHierarchy = self?.isCurrentlyInHierarchy, isCurrentlyInHierarchy {
|
||||
self?.setupGradientAnimations()
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
self.foregroundGradientLayer.add(animation, forKey: "movement")
|
||||
@@ -90,7 +116,7 @@ final class VoiceChatTimerNode: ASDisplayNode {
|
||||
|
||||
func update(size: CGSize, scheduleTime: Int32?, transition: ContainedViewLayoutTransition) {
|
||||
if self.validLayout == nil {
|
||||
self.setupGradientAnimations()
|
||||
self.updateAnimations()
|
||||
}
|
||||
self.validLayout = size
|
||||
|
||||
|
||||
Reference in New Issue
Block a user