Simplified/corrected highlighted/selected appearance of feed and timeline cells.

- Set the highlighted text color on labels in table cells. This will be used
  for both the highlight and selected states automatically. (And since it is
  used for both states, we avoid anachronistic state where we have black
  text on a dark blue background in light mode as we transition from none ->
  highlighted -> selected.)

- Keep the selected/highlighted overrides to adjust colors for non-UIControl
  subelements.
This commit is contained in:
Jim Correia 2019-09-02 22:39:01 -07:00
parent 932f6fdd30
commit 061872b7ff
5 changed files with 51 additions and 18 deletions

View File

@ -96,10 +96,6 @@ struct AppAssets {
return UIImage(systemName: "safari")!
}()
static var selectedTextColor: UIColor = {
return UIColor(named: "selectedTextColor")!
}()
static var settingsImage: UIImage = {
return UIImage(named: "settingsImage")!
}()
@ -128,6 +124,10 @@ struct AppAssets {
return UIImage(systemName: "star")!
}()
static var tableViewCellHighlightedTextColor: UIColor = {
return UIColor(named: "tableViewCellHighlightedTextColor")!
}()
static var tableViewCellSelectionColor: UIColor = {
return UIColor(named: "tableViewCellSelectionColor")!
}()

View File

@ -104,11 +104,24 @@ class MasterFeedTableViewCell : NNWTableViewCell {
super.init(coder: coder)
commonInit()
}
override func applyThemeProperties() {
super.applyThemeProperties()
titleView.highlightedTextColor = AppAssets.tableViewCellHighlightedTextColor
}
override func setHighlighted(_ highlighted: Bool, animated: Bool) {
super.setHighlighted(highlighted, animated: animated)
let tintColor = isHighlighted || isSelected ? AppAssets.tableViewCellHighlightedTextColor : AppAssets.netNewsWireBlueColor
faviconImageView.tintColor = tintColor
}
override func setSelected(_ selected: Bool, animated: Bool) {
titleView.textColor = selected ? AppAssets.selectedTextColor : UIColor.label
faviconImageView.tintColor = selected ? AppAssets.selectedTextColor : AppAssets.netNewsWireBlueColor
super.setSelected(selected, animated: animated)
let tintColor = isHighlighted || isSelected ? AppAssets.tableViewCellHighlightedTextColor : AppAssets.netNewsWireBlueColor
faviconImageView.tintColor = tintColor
}
override func willTransition(to state: UITableViewCell.StateMask) {

View File

@ -38,21 +38,31 @@ class MasterTimelineTableViewCell: NNWTableViewCell {
commonInit()
}
override func applyThemeProperties() {
super.applyThemeProperties()
let highlightedTextColor = AppAssets.tableViewCellHighlightedTextColor
titleView.highlightedTextColor = highlightedTextColor
summaryView.highlightedTextColor = highlightedTextColor
dateView.highlightedTextColor = highlightedTextColor
feedNameView.highlightedTextColor = highlightedTextColor
}
override var frame: CGRect {
didSet {
setNeedsLayout()
}
}
override func setHighlighted(_ highlighted: Bool, animated: Bool) {
super.setHighlighted(highlighted, animated: animated)
unreadIndicatorView.isSelected = isHighlighted || isSelected
}
override func setSelected(_ selected: Bool, animated: Bool) {
let selectedTextColor = selected ? AppAssets.selectedTextColor : UIColor.label
titleView.textColor = selectedTextColor
summaryView.textColor = selectedTextColor
dateView.textColor = selectedTextColor
feedNameView.textColor = selectedTextColor
unreadIndicatorView.isSelected = selected
super.setSelected(selected, animated: animated)
unreadIndicatorView.isSelected = isHighlighted || isSelected
}
override func sizeThatFits(_ size: CGSize) -> CGSize {

View File

@ -32,11 +32,8 @@ class MasterUnreadIndicatorView: UIView {
}()
override func draw(_ dirtyRect: CGRect) {
if isSelected {
AppAssets.selectedTextColor.setFill()
} else {
AppAssets.timelineUnreadCircleColor.setFill()
}
let color = isSelected ? AppAssets.tableViewCellHighlightedTextColor : AppAssets.timelineUnreadCircleColor
color.setFill()
MasterUnreadIndicatorView.bezierPath.fill()
}

View File

@ -15,6 +15,19 @@
"green" : "1.000"
}
}
},
{
"idiom" : "universal",
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"platform" : "ios",
"reference" : "labelColor"
}
}
]
}