Adding proper "live" animation

This commit is contained in:
Ilya Yelagov 2022-12-06 21:21:59 +04:00
parent a7e24996d8
commit 81ee64d2ec
2 changed files with 12 additions and 6 deletions

View File

@ -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 {

View File

@ -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
}