This commit is contained in:
Brent Simmons 2019-11-02 18:20:06 -07:00
commit bef824b02f
12 changed files with 105 additions and 125 deletions

View File

@ -10,6 +10,8 @@ import RSCore
import Account
struct AppAssets {
static let layerSpeed: Float = 1.5
static var accountLocalPadImage: UIImage = {
return UIImage(named: "accountLocalPad")!
@ -161,10 +163,6 @@ struct AppAssets {
return UIImage(systemName: "star.fill")!
}()
static var timelineBackgroundColor: UIColor = {
return UIColor(named: "timelineBackgroundColor")!
}()
static var timelineStarImage: UIImage = {
let image = UIImage(systemName: "star.fill")!
return image.withTintColor(AppAssets.starColor, renderingMode: .alwaysOriginal)

View File

@ -127,19 +127,8 @@ class MasterFeedTableViewCell : VibrantTableViewCell {
override func applyThemeProperties() {
super.applyThemeProperties()
titleView.highlightedTextColor = AppAssets.vibrantTextColor
}
override func setHighlighted(_ highlighted: Bool, animated: Bool) {
super.setHighlighted(highlighted, animated: animated)
updateVibrancy(animated: animated)
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
updateVibrancy(animated: animated)
}
override func willTransition(to state: UITableViewCell.StateMask) {
super.willTransition(to: state)
isShowingEditControl = state.contains(.showingEditControl)
@ -163,6 +152,15 @@ class MasterFeedTableViewCell : VibrantTableViewCell {
}
}
override func updateVibrancy(animated: Bool) {
super.updateVibrancy(animated: animated)
let avatarTintColor = isHighlighted || isSelected ? AppAssets.vibrantTextColor : AppAssets.secondaryAccentColor
UIView.animate(withDuration: duration(animated: animated)) {
self.avatarView.tintColor = avatarTintColor
}
updateLabelVibrancy(titleView, animated: animated)
}
}
private extension MasterFeedTableViewCell {
@ -199,14 +197,6 @@ private extension MasterFeedTableViewCell {
bottomSeparatorView.setFrameIfNotEqual(layout.separatorRect)
}
func updateVibrancy(animated: Bool) {
let avatarTintColor = isHighlighted || isSelected ? AppAssets.vibrantTextColor : AppAssets.secondaryAccentColor
let duration = animated ? 0.6 : 0.0
UIView.animate(withDuration: duration) {
self.avatarView.tintColor = avatarTintColor
}
}
func hideView(_ view: UIView) {
if !view.isHidden {
view.isHidden = true

View File

@ -75,7 +75,7 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
tableView.layer.speed = 2.0
tableView.layer.speed = AppAssets.layerSpeed
}
// MARK: Notifications

View File

@ -34,35 +34,27 @@ class MasterTimelineTableViewCell: VibrantTableViewCell {
commonInit()
}
override func applyThemeProperties() {
super.applyThemeProperties()
let highlightedTextColor = AppAssets.vibrantTextColor
titleView.highlightedTextColor = highlightedTextColor
summaryView.highlightedTextColor = highlightedTextColor
dateView.highlightedTextColor = highlightedTextColor
feedNameView.highlightedTextColor = highlightedTextColor
backgroundColor = AppAssets.timelineBackgroundColor
}
override var frame: CGRect {
didSet {
setNeedsLayout()
}
}
override func setHighlighted(_ highlighted: Bool, animated: Bool) {
super.setHighlighted(highlighted, animated: animated)
unreadIndicatorView.isSelected = isHighlighted || isSelected
override func updateVibrancy(animated: Bool) {
updateLabelVibrancy(titleView, animated: animated)
updateLabelVibrancy(summaryView, animated: animated)
updateLabelVibrancy(dateView, animated: animated)
updateLabelVibrancy(feedNameView, animated: animated)
UIView.animate(withDuration: duration(animated: animated)) {
if self.isHighlighted || self.isSelected {
self.unreadIndicatorView.backgroundColor = AppAssets.vibrantTextColor
} else {
self.unreadIndicatorView.backgroundColor = AppAssets.secondaryAccentColor
}
}
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
unreadIndicatorView.isSelected = isHighlighted || isSelected
}
override func sizeThatFits(_ size: CGSize) -> CGSize {
let layout = updatedLayout(width: size.width)
return CGSize(width: size.width, height: layout.height)

View File

@ -10,31 +10,10 @@ import UIKit
class MasterUnreadIndicatorView: UIView {
var isSelected = false {
didSet {
setNeedsDisplay()
}
override func layoutSubviews() {
super.layoutSubviews()
layer.cornerRadius = frame.size.width / 2.0
clipsToBounds = true
}
override init(frame: CGRect) {
super.init(frame: frame)
self.isOpaque = false
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.isOpaque = false
}
static let bezierPath: UIBezierPath = {
let r = CGRect(x: 0.0, y: 0.0, width: MasterTimelineDefaultCellLayout.unreadCircleDimension, height: MasterTimelineDefaultCellLayout.unreadCircleDimension)
return UIBezierPath(ovalIn: r)
}()
override func draw(_ dirtyRect: CGRect) {
let color = isSelected ? AppAssets.vibrantTextColor : AppAssets.secondaryAccentColor
color.setFill()
MasterUnreadIndicatorView.bezierPath.fill()
}
}

View File

@ -74,6 +74,11 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
super.viewWillAppear(animated)
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
tableView.layer.speed = AppAssets.layerSpeed
}
// MARK: Actions
@IBAction func markAllAsRead(_ sender: Any) {

View File

@ -1,28 +0,0 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
},
"colors" : [
{
"idiom" : "universal",
"color" : {
"platform" : "ios",
"reference" : "systemBackgroundColor"
}
},
{
"idiom" : "universal",
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"platform" : "ios",
"reference" : "systemBackgroundColor"
}
}
]
}

View File

@ -353,7 +353,6 @@
<outlet property="groupByFeedSwitch" destination="JNi-Wz-RbU" id="TwH-Kd-o6N"/>
<outlet property="numberOfTextLinesLabel" destination="b2T-Uw-ugm" id="IUA-fR-A3U"/>
<outlet property="numberOfTextLinesSteppper" destination="sqD-br-anp" id="naH-11-E0I"/>
<outlet property="refreshIntervalLabel" destination="qIl-N6-6wQ" id="2gQ-Yn-FP8"/>
<outlet property="timelineSortOrderSwitch" destination="Keq-Np-l9O" id="Zm7-HG-r5h"/>
</connections>
</tableViewController>

View File

@ -13,25 +13,12 @@ class SettingsAccountTableViewCell: VibrantTableViewCell {
@IBOutlet weak var accountImage: UIImageView!
@IBOutlet weak var accountNameLabel: UILabel!
override func setHighlighted(_ highlighted: Bool, animated: Bool) {
super.setHighlighted(highlighted, animated: animated)
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) {
override func updateVibrancy(animated: Bool) {
super.updateVibrancy(animated: animated)
updateLabelVibrancy(accountNameLabel, animated: animated)
let tintColor = isHighlighted || isSelected ? AppAssets.vibrantTextColor : UIColor.label
let duration = animated ? 0.6 : 0.0
UIView.animate(withDuration: duration) {
UIView.animate(withDuration: duration(animated: animated)) {
self.accountImage?.tintColor = tintColor
}
}

View File

@ -8,12 +8,28 @@
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" id="JCb-QB-CrO" customClass="VibrantTableViewCell" customModule="NetNewsWire" customModuleProvider="target">
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="f73-v7-eum" detailTextLabel="Cak-zN-D7k" style="IBUITableViewCellStyleValue1" id="JCb-QB-CrO" customClass="VibrantTableViewCell" customModule="NetNewsWire" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="JCb-QB-CrO" id="FzD-t2-JGy">
<rect key="frame" x="0.0" y="0.0" width="383" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" id="f73-v7-eum">
<rect key="frame" x="20" y="12" width="33.5" height="20.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" id="Cak-zN-D7k">
<rect key="frame" x="331" y="12" width="44" height="20.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
<point key="canvasLocation" x="7" y="-9"/>
</tableViewCell>

View File

@ -17,7 +17,6 @@ class SettingsViewController: UITableViewController {
static let preferredContentSizeForFormSheetDisplay = CGSize(width: 460.0, height: 400.0)
@IBOutlet weak var refreshIntervalLabel: UILabel!
@IBOutlet weak var timelineSortOrderSwitch: UISwitch!
@IBOutlet weak var groupByFeedSwitch: UISwitch!
@IBOutlet weak var numberOfTextLinesLabel: UILabel!
@ -33,6 +32,7 @@ class SettingsViewController: UITableViewController {
NotificationCenter.default.addObserver(self, selector: #selector(accountsDidChange), name: .UserDidAddAccount, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(accountsDidChange), name: .UserDidDeleteAccount, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(displayNameDidChange), name: .DisplayNameDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(userDefaultsDidChange), name: UserDefaults.didChangeNotification, object: nil)
tableView.register(UINib(nibName: "SettingsAccountTableViewCell", bundle: nil), forCellReuseIdentifier: "SettingsAccountTableViewCell")
tableView.register(UINib(nibName: "SettingsTableViewCell", bundle: nil), forCellReuseIdentifier: "SettingsTableViewCell")
@ -54,8 +54,6 @@ class SettingsViewController: UITableViewController {
groupByFeedSwitch.isOn = false
}
refreshIntervalLabel.text = AppDefaults.refreshInterval.description()
let numberOfTextLines = AppDefaults.timelineNumberOfLines
numberOfTextLinesSteppper.value = Double(numberOfTextLines)
updateNumberOfTextLinesLabel(value: numberOfTextLines)
@ -76,6 +74,7 @@ class SettingsViewController: UITableViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
tableView.layer.speed = AppAssets.layerSpeed
self.tableView.selectRow(at: nil, animated: true, scrollPosition: .none)
}
@ -104,7 +103,6 @@ class SettingsViewController: UITableViewController {
let sortedAccounts = AccountManager.shared.sortedAccounts
if indexPath.row == sortedAccounts.count {
cell = tableView.dequeueReusableCell(withIdentifier: "SettingsTableViewCell", for: indexPath)
cell.textLabel?.adjustsFontForContentSizeCategory = true
cell.textLabel?.text = NSLocalizedString("Add Account", comment: "Accounts")
} else {
let acctCell = tableView.dequeueReusableCell(withIdentifier: "SettingsAccountTableViewCell", for: indexPath) as! SettingsAccountTableViewCell
@ -114,6 +112,16 @@ class SettingsViewController: UITableViewController {
acctCell.accountNameLabel?.text = account.nameForDisplay
cell = acctCell
}
case 2:
if indexPath.row == 0 {
cell = tableView.dequeueReusableCell(withIdentifier: "SettingsTableViewCell", for: indexPath)
cell.textLabel?.text = NSLocalizedString("Refresh Interval", comment: "Refresh Interval")
cell.detailTextLabel?.text = AppDefaults.refreshInterval.description()
} else {
cell = super.tableView(tableView, cellForRowAt: indexPath)
}
default:
@ -260,6 +268,10 @@ class SettingsViewController: UITableViewController {
tableView.reloadData()
}
@objc func userDefaultsDidChange() {
tableView.reloadData()
}
}
// MARK: OPML Document Picker

View File

@ -10,6 +10,10 @@ import UIKit
class VibrantTableViewCell: UITableViewCell {
var labelColor: UIColor {
return isHighlighted || isSelected ? AppAssets.vibrantTextColor : UIColor.label
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
commonInit()
@ -23,13 +27,39 @@ class VibrantTableViewCell: UITableViewCell {
private func commonInit() {
applyThemeProperties()
}
override func setHighlighted(_ highlighted: Bool, animated: Bool) {
super.setHighlighted(highlighted, animated: animated)
updateVibrancy(animated: animated)
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
updateVibrancy(animated: animated)
}
/// Subclass overrides should call super
func applyThemeProperties() {
let selectedBackgroundView = UIView(frame: .zero)
selectedBackgroundView.backgroundColor = AppAssets.secondaryAccentColor
self.selectedBackgroundView = selectedBackgroundView
textLabel?.highlightedTextColor = AppAssets.vibrantTextColor
}
/// Subclass overrides should call super
func updateVibrancy(animated: Bool) {
updateLabelVibrancy(textLabel, animated: animated)
updateLabelVibrancy(detailTextLabel, animated: animated)
}
func duration(animated: Bool) -> TimeInterval {
return animated ? 0.6 : 0.0
}
func updateLabelVibrancy(_ label: UILabel?, animated: Bool) {
guard let label = label else { return }
UIView.transition(with: label, duration: duration(animated: animated), options: .transitionCrossDissolve, animations: {
label.textColor = self.labelColor
}, completion: nil)
}
}