Remove zero duration animations.

This commit is contained in:
Maurice Parker 2020-10-22 18:56:33 -05:00
parent 642eb1ae33
commit 18726d061d
6 changed files with 46 additions and 14 deletions

View File

@ -17,7 +17,11 @@ class AddComboTableViewCell: VibrantTableViewCell {
super.updateVibrancy(animated: animated)
let iconTintColor = isHighlighted || isSelected ? AppAssets.vibrantTextColor : AppAssets.secondaryAccentColor
UIView.animate(withDuration: duration(animated: animated)) {
if animated {
UIView.animate(withDuration: Self.duration) {
self.icon.tintColor = iconTintColor
}
} else {
self.icon.tintColor = iconTintColor
}
updateLabelVibrancy(label, color: labelColor, animated: animated)

View File

@ -17,9 +17,14 @@ class SelectComboTableViewCell: VibrantTableViewCell {
super.updateVibrancy(animated: animated)
let iconTintColor = isHighlighted || isSelected ? AppAssets.vibrantTextColor : UIColor.label
UIView.animate(withDuration: duration(animated: animated)) {
if animated {
UIView.animate(withDuration: Self.duration) {
self.icon.tintColor = iconTintColor
}
} else {
self.icon.tintColor = iconTintColor
}
updateLabelVibrancy(label, color: labelColor, animated: animated)
}

View File

@ -167,7 +167,11 @@ class MasterFeedTableViewCell : VibrantTableViewCell {
}
}
UIView.animate(withDuration: duration(animated: animated)) {
if animated {
UIView.animate(withDuration: Self.duration) {
self.iconView.tintColor = iconTintColor
}
} else {
self.iconView.tintColor = iconTintColor
}

View File

@ -59,7 +59,15 @@ class MasterTimelineTableViewCell: VibrantTableViewCell {
updateLabelVibrancy(dateView, color: secondaryLabelColor, animated: animated)
updateLabelVibrancy(feedNameView, color: secondaryLabelColor, animated: animated)
UIView.animate(withDuration: duration(animated: animated)) {
if animated {
UIView.animate(withDuration: Self.duration) {
if self.isHighlighted || self.isSelected {
self.unreadIndicatorView.backgroundColor = AppAssets.vibrantTextColor
} else {
self.unreadIndicatorView.backgroundColor = AppAssets.secondaryAccentColor
}
}
} else {
if self.isHighlighted || self.isSelected {
self.unreadIndicatorView.backgroundColor = AppAssets.vibrantTextColor
} else {

View File

@ -18,7 +18,11 @@ class SettingsComboTableViewCell: VibrantTableViewCell {
updateLabelVibrancy(comboNameLabel, color: labelColor, animated: animated)
let tintColor = isHighlighted || isSelected ? AppAssets.vibrantTextColor : UIColor.label
UIView.animate(withDuration: duration(animated: animated)) {
if animated {
UIView.animate(withDuration: Self.duration) {
self.comboImage?.tintColor = tintColor
}
} else {
self.comboImage?.tintColor = tintColor
}
}

View File

@ -9,7 +9,9 @@
import UIKit
class VibrantTableViewCell: UITableViewCell {
static let duration: TimeInterval = 0.6
var labelColor: UIColor {
return isHighlighted || isSelected ? AppAssets.vibrantTextColor : UIColor.label
}
@ -54,16 +56,16 @@ class VibrantTableViewCell: UITableViewCell {
updateLabelVibrancy(textLabel, color: labelColor, animated: animated)
updateLabelVibrancy(detailTextLabel, color: labelColor, animated: animated)
}
func duration(animated: Bool) -> TimeInterval {
return animated ? 0.6 : 0.0
}
func updateLabelVibrancy(_ label: UILabel?, color: UIColor, animated: Bool) {
guard let label = label else { return }
UIView.transition(with: label, duration: duration(animated: animated), options: .transitionCrossDissolve, animations: {
if animated {
UIView.transition(with: label, duration: Self.duration, options: .transitionCrossDissolve, animations: {
label.textColor = color
}, completion: nil)
} else {
label.textColor = color
}, completion: nil)
}
}
}
@ -94,10 +96,15 @@ class VibrantBasicTableViewCell: VibrantTableViewCell {
private func updateIconVibrancy(_ icon: UIImageView?, color: UIColor, image: UIImage?, animated: Bool) {
guard let icon = icon else { return }
UIView.transition(with: icon, duration: duration(animated: animated), options: .transitionCrossDissolve, animations: {
if animated {
UIView.transition(with: icon, duration: Self.duration, options: .transitionCrossDissolve, animations: {
icon.tintColor = color
icon.image = image
}, completion: nil)
} else {
icon.tintColor = color
icon.image = image
}, completion: nil)
}
}
}