From 81ee64d2ecdf0531b223dcb7f1307de6a6d7e80e Mon Sep 17 00:00:00 2001 From: Ilya Yelagov Date: Tue, 6 Dec 2022 21:21:59 +0400 Subject: [PATCH] Adding proper "live" animation --- .../Sources/Components/AnimatedCounterView.swift | 2 +- .../Components/MediaStreamComponent.swift | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/submodules/TelegramCallsUI/Sources/Components/AnimatedCounterView.swift b/submodules/TelegramCallsUI/Sources/Components/AnimatedCounterView.swift index a5cd532032..afb69f52a8 100644 --- a/submodules/TelegramCallsUI/Sources/Components/AnimatedCounterView.swift +++ b/submodules/TelegramCallsUI/Sources/Components/AnimatedCounterView.swift @@ -63,7 +63,7 @@ public final class AnimatedCountView: UIView { // } else { // self.countLabel.attributedText = NSAttributedString(string: text, attributes: [.font: UIFont.systemFont(ofSize: 54, weight: .semibold)]) // } - self.countLabel.attributedText = NSAttributedString(string: text, attributes: [.font: UIFont.systemFont(ofSize: 60, weight: .semibold)]) + self.countLabel.attributedText = NSAttributedString(string: text, font: Font.with(size: 60.0, design: .round, weight: .semibold, traits: [.monospacedNumbers]), textColor: .white) // self.countLabel.attributedText = NSAttributedString(string: text, attributes: [.font: UIFont.systemFont(ofSize: 60, weight: .semibold)]) // var timerSize = self.timerNode.updateLayout(CGSize(width: size.width + 100.0, height: size.height)) // if timerSize.width > size.width - 32.0 { diff --git a/submodules/TelegramCallsUI/Sources/Components/MediaStreamComponent.swift b/submodules/TelegramCallsUI/Sources/Components/MediaStreamComponent.swift index d1ff3a84a8..d32af0563a 100644 --- a/submodules/TelegramCallsUI/Sources/Components/MediaStreamComponent.swift +++ b/submodules/TelegramCallsUI/Sources/Components/MediaStreamComponent.swift @@ -83,14 +83,20 @@ final class StreamTitleComponent: Component { // TODO: animate wasLive = true // let frame = self.frame + let anim = CAKeyframeAnimation(keyPath: "transform.scale") + anim.values = [1.0, 1.4, 1.0] + anim.keyTimes = [0, 0.5, 1] + self.layer.add(anim, forKey: "transform") + +// UIView.transition(with: self, duration: <#T##TimeInterval#>, animations: <#T##(() -> Void)?##(() -> Void)?##() -> Void#>) UIView.animate(withDuration: 0.15, animations: { self.toggle(isLive: true) - self.transform = .init(scaleX: 1.5, y: 1.5) +// self.transform = .init(scaleX: 1.5, y: 1.5) }, completion: { _ in - UIView.animate(withDuration: 0.15) { - self.transform = .identity -// self.frame = frame - } +// UIView.animate(withDuration: 0.15) { +// self.transform = .identity +//// self.frame = frame +// } }) return }