From 18726d061df402dc7ef0b0e69cc06564ca0bf3a6 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Thu, 22 Oct 2020 18:56:33 -0500 Subject: [PATCH] Remove zero duration animations. --- iOS/Add/AddComboTableViewCell.swift | 6 ++++- iOS/Add/SelectComboTableViewCell.swift | 7 +++++- .../Cell/MasterFeedTableViewCell.swift | 6 ++++- .../Cell/MasterTimelineTableViewCell.swift | 10 +++++++- iOS/Settings/SettingsComboTableViewCell.swift | 6 ++++- .../VibrantTableViewCell.swift | 25 ++++++++++++------- 6 files changed, 46 insertions(+), 14 deletions(-) diff --git a/iOS/Add/AddComboTableViewCell.swift b/iOS/Add/AddComboTableViewCell.swift index 83ae83e88..4e7c30155 100644 --- a/iOS/Add/AddComboTableViewCell.swift +++ b/iOS/Add/AddComboTableViewCell.swift @@ -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) diff --git a/iOS/Add/SelectComboTableViewCell.swift b/iOS/Add/SelectComboTableViewCell.swift index 890869bdd..d194a871a 100644 --- a/iOS/Add/SelectComboTableViewCell.swift +++ b/iOS/Add/SelectComboTableViewCell.swift @@ -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) } diff --git a/iOS/MasterFeed/Cell/MasterFeedTableViewCell.swift b/iOS/MasterFeed/Cell/MasterFeedTableViewCell.swift index 7b8390079..8bb30a720 100644 --- a/iOS/MasterFeed/Cell/MasterFeedTableViewCell.swift +++ b/iOS/MasterFeed/Cell/MasterFeedTableViewCell.swift @@ -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 } diff --git a/iOS/MasterTimeline/Cell/MasterTimelineTableViewCell.swift b/iOS/MasterTimeline/Cell/MasterTimelineTableViewCell.swift index 0ed459aa5..49b9f9ae8 100644 --- a/iOS/MasterTimeline/Cell/MasterTimelineTableViewCell.swift +++ b/iOS/MasterTimeline/Cell/MasterTimelineTableViewCell.swift @@ -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 { diff --git a/iOS/Settings/SettingsComboTableViewCell.swift b/iOS/Settings/SettingsComboTableViewCell.swift index ec1775600..9e0200a27 100644 --- a/iOS/Settings/SettingsComboTableViewCell.swift +++ b/iOS/Settings/SettingsComboTableViewCell.swift @@ -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 } } diff --git a/iOS/UIKit Extensions/VibrantTableViewCell.swift b/iOS/UIKit Extensions/VibrantTableViewCell.swift index 8a803c171..22d74deb0 100644 --- a/iOS/UIKit Extensions/VibrantTableViewCell.swift +++ b/iOS/UIKit Extensions/VibrantTableViewCell.swift @@ -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) + } } }