Make icon vibrancy deselections match the deselection animation

This commit is contained in:
Maurice Parker 2019-10-23 11:47:21 -05:00
parent 2e489d4093
commit eea450bee3
3 changed files with 26 additions and 13 deletions

View File

@ -133,18 +133,12 @@ class MasterFeedTableViewCell : VibrantTableViewCell {
override func setHighlighted(_ highlighted: Bool, animated: Bool) {
super.setHighlighted(highlighted, animated: animated)
let tintColor = isHighlighted || isSelected ? AppAssets.vibrantTextColor : AppAssets.secondaryAccentColor
disclosureButton?.tintColor = tintColor
faviconImageView.tintColor = tintColor
updateVibrancy(animated: animated)
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
let tintColor = isHighlighted || isSelected ? AppAssets.vibrantTextColor : AppAssets.secondaryAccentColor
disclosureButton?.tintColor = tintColor
faviconImageView.tintColor = tintColor
updateVibrancy(animated: animated)
}
override func willTransition(to state: UITableViewCell.StateMask) {
@ -201,5 +195,14 @@ private extension MasterFeedTableViewCell {
disclosureButton?.isHidden = !isDisclosureAvailable
separatorInset = layout.separatorInsets
}
func updateVibrancy(animated: Bool) {
let tintColor = isHighlighted || isSelected ? AppAssets.vibrantTextColor : AppAssets.secondaryAccentColor
let duration = animated ? 0.5 : 0.0
UIView.animate(withDuration: duration) {
self.disclosureButton?.tintColor = tintColor
self.faviconImageView.tintColor = tintColor
}
}
}

View File

@ -15,16 +15,25 @@ class SettingsAccountTableViewCell: VibrantTableViewCell {
override func setHighlighted(_ highlighted: Bool, animated: Bool) {
super.setHighlighted(highlighted, animated: animated)
let tintColor = isHighlighted || isSelected ? AppAssets.vibrantTextColor : UIColor.label
accountImage?.tintColor = tintColor
accountNameLabel?.highlightedTextColor = tintColor
updateVibrancy(animated: animated)
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
updateVibrancy(animated: animated)
}
override func applyThemeProperties() {
super.applyThemeProperties()
accountNameLabel?.highlightedTextColor = AppAssets.vibrantTextColor
}
func updateVibrancy(animated: Bool) {
let tintColor = isHighlighted || isSelected ? AppAssets.vibrantTextColor : UIColor.label
accountImage?.tintColor = tintColor
accountNameLabel?.highlightedTextColor = tintColor
let duration = animated ? 0.5 : 0.0
UIView.animate(withDuration: duration) {
self.accountImage?.tintColor = tintColor
}
}
}

View File

@ -103,6 +103,7 @@ class SettingsViewController: UITableViewController {
cell.textLabel?.text = NSLocalizedString("Add Account", comment: "Accounts")
} else {
let acctCell = tableView.dequeueReusableCell(withIdentifier: "SettingsAccountTableViewCell", for: indexPath) as! SettingsAccountTableViewCell
acctCell.applyThemeProperties()
let account = sortedAccounts[indexPath.row]
acctCell.accountImage?.image = AppAssets.image(for: account.type)
acctCell.accountNameLabel?.text = account.nameForDisplay