Implement VibrantBasicTableViewCell

This commit is contained in:
Mihael Cholakov
2020-01-12 23:53:08 +02:00
parent 77b470a720
commit 9368d1033d
4 changed files with 50 additions and 8 deletions

View File

@@ -67,3 +67,35 @@ class VibrantTableViewCell: UITableViewCell {
}
}
class VibrantBasicTableViewCell: VibrantTableViewCell {
@IBOutlet private var label: UILabel!
@IBOutlet private var icon: UIImageView!
@IBInspectable var imageNormal: UIImage?
@IBInspectable var imageSelected: UIImage?
var iconTint: UIColor {
return isHighlighted || isSelected ? .systemBackground : AppAssets.primaryAccentColor
}
var iconImage: UIImage? {
return isHighlighted || isSelected ? imageSelected : imageNormal
}
override func updateVibrancy(animated: Bool) {
super.updateVibrancy(animated: animated)
updateIconVibrancy(icon, color: iconTint, image: iconImage, animated: animated)
updateLabelVibrancy(label, color: labelColor, animated: animated)
}
private func updateIconVibrancy(_ icon: UIImageView?, color: UIColor, image: UIImage?, animated: Bool) {
guard let icon = icon else { return }
UIView.transition(with: label, duration: duration(animated: animated), options: .transitionCrossDissolve, animations: {
icon.tintColor = color
icon.image = image
}, completion: nil)
}
}