Merge pull request #949 from correia/issue-948

Fix for issue #948 — bad highlight state for table cell views in light mode.
This commit is contained in:
Maurice Parker
2019-09-03 11:56:14 -05:00
committed by GitHub
8 changed files with 143 additions and 38 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,14 @@ struct AppAssets {
return UIImage(systemName: "star")!
}()
static var tableViewCellHighlightedTextColor: UIColor = {
return UIColor(named: "tableViewCellHighlightedTextColor")!
}()
static var tableViewCellSelectionColor: UIColor = {
return UIColor(named: "tableViewCellSelectionColor")!
}()
static var timelineStarImage: UIImage = {
let image = UIImage(systemName: "star.fill")!
return image.withTintColor(AppAssets.starColor, renderingMode: .alwaysOriginal)

View File

@@ -15,7 +15,7 @@ protocol MasterFeedTableViewCellDelegate: class {
func disclosureSelected(_ sender: MasterFeedTableViewCell, expanding: Bool)
}
class MasterFeedTableViewCell : UITableViewCell {
class MasterFeedTableViewCell : NNWTableViewCell {
weak var delegate: MasterFeedTableViewCellDelegate?
var allowDisclosureSelection = false
@@ -104,11 +104,24 @@ class MasterFeedTableViewCell : UITableViewCell {
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) {
@@ -141,19 +154,12 @@ class MasterFeedTableViewCell : UITableViewCell {
private extension MasterFeedTableViewCell {
func commonInit() {
theme()
addSubviewAtInit(unreadCountView)
addSubviewAtInit(faviconImageView)
addSubviewAtInit(titleView)
addDisclosureView()
}
func theme() {
let bgView = UIView()
bgView.backgroundColor = AppAssets.netNewsWireBlueColor
selectedBackgroundView = bgView
}
func addDisclosureView() {
disclosureButton = NonIntrinsicButton(type: .roundedRect)

View File

@@ -9,7 +9,7 @@
import UIKit
import RSCore
class MasterTimelineTableViewCell: UITableViewCell {
class MasterTimelineTableViewCell: NNWTableViewCell {
private let titleView = MasterTimelineTableViewCell.multiLineUILabel()
private let summaryView = MasterTimelineTableViewCell.multiLineUILabel()
@@ -38,21 +38,31 @@ class MasterTimelineTableViewCell: UITableViewCell {
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 {
@@ -124,7 +134,6 @@ private extension MasterTimelineTableViewCell {
func commonInit() {
theme()
addAccessoryView()
addSubviewAtInit(titleView, hidden: false)
addSubviewAtInit(summaryView, hidden: true)
@@ -136,12 +145,6 @@ private extension MasterTimelineTableViewCell {
}
func theme() {
let bgView = UIView()
bgView.backgroundColor = AppAssets.netNewsWireBlueColor
selectedBackgroundView = bgView
}
func addAccessoryView() {
accessoryView = UIImageView(image: AppAssets.chevronRightImage)
}

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"
}
}
]
}

View File

@@ -0,0 +1,38 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
},
"colors" : [
{
"idiom" : "universal",
"color" : {
"color-space" : "srgb",
"components" : {
"red" : "0.031",
"alpha" : "1.000",
"blue" : "0.933",
"green" : "0.416"
}
}
},
{
"idiom" : "universal",
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"red" : "0.267",
"alpha" : "1.000",
"blue" : "0.886",
"green" : "0.565"
}
}
}
]
}

View File

@@ -0,0 +1,32 @@
//
// NNWTableViewCell.swift
// NetNewsWire-iOS
//
// Created by Jim Correia on 9/2/19.
// Copyright © 2019 Ranchero Software. All rights reserved.
//
import UIKit
class NNWTableViewCell: UITableViewCell {
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
commonInit()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
commonInit()
}
private func commonInit() {
applyThemeProperties()
}
/// Subclass overrides should call super
func applyThemeProperties() {
let selectedBackgroundView = UIView(frame: .zero)
selectedBackgroundView.backgroundColor = AppAssets.tableViewCellSelectionColor
self.selectedBackgroundView = selectedBackgroundView
}
}