[TF-1552] pr changes and fix formatting

This commit is contained in:
gmc 2024-07-30 19:31:58 +02:00
parent b2cd42d48d
commit 32d7692dfa

View File

@ -129,7 +129,6 @@ extension TokensViewController: TokensViewControlling {
// MARK: - Navibar icons // MARK: - Navibar icons
func updateNaviIcons(using state: TokensViewControllerAddState, hasUnreadNews: Bool) { func updateNaviIcons(using state: TokensViewControllerAddState, hasUnreadNews: Bool) {
func createNewsButton() -> UIBarButtonItem { func createNewsButton() -> UIBarButtonItem {
print("Create news icon called")
if presenter.hasUnreadNews { if presenter.hasUnreadNews {
let naviButton = UnreadNewsNaviButton() let naviButton = UnreadNewsNaviButton()
naviButton.translatesAutoresizingMaskIntoConstraints = false naviButton.translatesAutoresizingMaskIntoConstraints = false
@ -406,7 +405,10 @@ private extension TokensViewController {
newsImageView.centerXAnchor.constraint(equalTo: centerXAnchor), newsImageView.centerXAnchor.constraint(equalTo: centerXAnchor),
newsImageView.centerYAnchor.constraint(equalTo: centerYAnchor), newsImageView.centerYAnchor.constraint(equalTo: centerYAnchor),
badgeImageView.topAnchor.constraint(equalTo: topAnchor, constant: Theme.Metrics.halfSpacing), badgeImageView.topAnchor.constraint(equalTo: topAnchor, constant: Theme.Metrics.halfSpacing),
badgeImageView.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -Theme.Metrics.quaterSpacing), badgeImageView.trailingAnchor.constraint(
equalTo: trailingAnchor,
constant: -Theme.Metrics.quaterSpacing
),
badgeImageView.widthAnchor.constraint(equalToConstant: badgeWidth), badgeImageView.widthAnchor.constraint(equalToConstant: badgeWidth),
badgeImageView.heightAnchor.constraint(equalToConstant: badgeWidth) badgeImageView.heightAnchor.constraint(equalToConstant: badgeWidth)
]) ])
@ -415,38 +417,46 @@ private extension TokensViewController {
func animate() { func animate() {
let angle: Double = .pi / 12 let angle: Double = .pi / 12
let numberOfFrames: Double = 5 let numberOfFrames: Double = 5
let frameDuration = Double(1/numberOfFrames) let frameDuration = Double(0.7 / numberOfFrames)
UIView.animateKeyframes(withDuration: 1, delay: 0, animations: { [newsImageView] in UIView.animateKeyframes(
withDuration: 1,
delay: 0,
animations: { [newsImageView] in
UIView.addKeyframe(withRelativeStartTime: 0.0, relativeDuration: frameDuration) { UIView.addKeyframe(withRelativeStartTime: 0.0, relativeDuration: frameDuration) {
newsImageView.transform = CGAffineTransform(rotationAngle: -angle) newsImageView.transform = CGAffineTransform(rotationAngle: -angle)
} }
UIView.addKeyframe(withRelativeStartTime: frameDuration, relativeDuration: frameDuration) { UIView.addKeyframe(withRelativeStartTime: frameDuration, relativeDuration: frameDuration) {
newsImageView.transform = CGAffineTransform(rotationAngle: +angle) newsImageView.transform = CGAffineTransform(rotationAngle: +angle)
} }
UIView.addKeyframe(withRelativeStartTime: 2 * frameDuration, relativeDuration: frameDuration) { UIView.addKeyframe(withRelativeStartTime: 2 * frameDuration, relativeDuration: frameDuration) {
newsImageView.transform = CGAffineTransform(rotationAngle: -angle) newsImageView.transform = CGAffineTransform(rotationAngle: -angle)
} }
UIView.addKeyframe(withRelativeStartTime: 3 * frameDuration, relativeDuration: frameDuration) { UIView.addKeyframe(withRelativeStartTime: 3 * frameDuration, relativeDuration: frameDuration) {
newsImageView.transform = CGAffineTransform(rotationAngle: +angle) newsImageView.transform = CGAffineTransform(rotationAngle: +angle)
} }
UIView.addKeyframe(withRelativeStartTime: 4 * frameDuration, relativeDuration: frameDuration) { UIView.addKeyframe(withRelativeStartTime: 4 * frameDuration, relativeDuration: frameDuration) {
newsImageView.transform = CGAffineTransform.identity newsImageView.transform = CGAffineTransform.identity
} }
}, completion: { [badgeImageView, badgeWidth] _ in },
badgeImageView.isHidden = false completion: { [weak self] _ in
UIView.animate(withDuration: 0.3, animations: { self?.badgeImageView.isHidden = false
self?.animateBadge()
}
)
}
private func animateBadge() {
UIView.animate(
withDuration: 0.2,
animations: { [badgeImageView, badgeWidth] in
badgeImageView.transform = CGAffineTransform(scaleX: 12.0 / badgeWidth, y: 12.0 / badgeWidth) badgeImageView.transform = CGAffineTransform(scaleX: 12.0 / badgeWidth, y: 12.0 / badgeWidth)
}, completion: { _ in }, completion: { [badgeImageView, badgeWidth] _ in
UIView.animate(withDuration: 0.2, animations: { UIView.animate(withDuration: 0.15) {
badgeImageView.transform = CGAffineTransform(scaleX: 8.0 / badgeWidth, y: 8.0 / badgeWidth) badgeImageView.transform = CGAffineTransform(scaleX: 8.0 / badgeWidth, y: 8.0 / badgeWidth)
}) }
}) }
}) )
} }
} }
} }