mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Add IconImage to encapsulate our icon processing logic
This commit is contained in:
@@ -31,9 +31,9 @@ class MasterFeedTableViewCell : VibrantTableViewCell {
|
||||
}
|
||||
}
|
||||
|
||||
var avatarImage: UIImage? {
|
||||
var iconImage: IconImage? {
|
||||
didSet {
|
||||
avatarView.image = avatarImage
|
||||
iconView.iconImage = iconImage
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ class MasterFeedTableViewCell : VibrantTableViewCell {
|
||||
return label
|
||||
}()
|
||||
|
||||
private let avatarView = AvatarView()
|
||||
private let iconView = IconView()
|
||||
|
||||
private let bottomSeparatorView: UIView = {
|
||||
let view = UIView()
|
||||
@@ -154,9 +154,9 @@ class MasterFeedTableViewCell : VibrantTableViewCell {
|
||||
|
||||
override func updateVibrancy(animated: Bool) {
|
||||
super.updateVibrancy(animated: animated)
|
||||
let avatarTintColor = isHighlighted || isSelected ? AppAssets.vibrantTextColor : AppAssets.secondaryAccentColor
|
||||
let iconTintColor = isHighlighted || isSelected ? AppAssets.vibrantTextColor : AppAssets.secondaryAccentColor
|
||||
UIView.animate(withDuration: duration(animated: animated)) {
|
||||
self.avatarView.tintColor = avatarTintColor
|
||||
self.iconView.tintColor = iconTintColor
|
||||
}
|
||||
updateLabelVibrancy(titleView, color: labelColor, animated: animated)
|
||||
}
|
||||
@@ -167,7 +167,7 @@ private extension MasterFeedTableViewCell {
|
||||
|
||||
func commonInit() {
|
||||
addSubviewAtInit(unreadCountView)
|
||||
addSubviewAtInit(avatarView)
|
||||
addSubviewAtInit(iconView)
|
||||
addSubviewAtInit(titleView)
|
||||
addDisclosureView()
|
||||
addSubviewAtInit(bottomSeparatorView)
|
||||
@@ -189,7 +189,7 @@ private extension MasterFeedTableViewCell {
|
||||
}
|
||||
|
||||
func layoutWith(_ layout: MasterFeedTableViewCellLayout) {
|
||||
avatarView.setFrameIfNotEqual(layout.faviconRect)
|
||||
iconView.setFrameIfNotEqual(layout.faviconRect)
|
||||
titleView.setFrameIfNotEqual(layout.titleRect)
|
||||
unreadCountView.setFrameIfNotEqual(layout.unreadCountRect)
|
||||
disclosureButton?.setFrameIfNotEqual(layout.disclosureButtonRect)
|
||||
|
||||
@@ -105,11 +105,11 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
|
||||
}
|
||||
|
||||
@objc func faviconDidBecomeAvailable(_ note: Notification) {
|
||||
applyToAvailableCells(configureAvatar)
|
||||
applyToAvailableCells(configureIcon)
|
||||
}
|
||||
|
||||
@objc func feedIconDidBecomeAvailable(_ note: Notification) {
|
||||
applyToAvailableCells(configureAvatar)
|
||||
applyToAvailableCells(configureIcon)
|
||||
}
|
||||
|
||||
@objc func feedSettingDidChange(_ note: Notification) {
|
||||
@@ -640,7 +640,7 @@ private extension MasterFeedViewController {
|
||||
|
||||
cell.name = nameFor(node)
|
||||
cell.unreadCount = coordinator.unreadCountFor(node)
|
||||
configureAvatar(cell, node)
|
||||
configureIcon(cell, node)
|
||||
|
||||
guard let indexPath = dataSource.indexPath(for: node) else { return }
|
||||
let rowsInSection = tableView.numberOfRows(inSection: indexPath.section)
|
||||
@@ -652,11 +652,11 @@ private extension MasterFeedViewController {
|
||||
|
||||
}
|
||||
|
||||
func configureAvatar(_ cell: MasterFeedTableViewCell, _ node: Node) {
|
||||
cell.avatarImage = imageFor(node)
|
||||
func configureIcon(_ cell: MasterFeedTableViewCell, _ node: Node) {
|
||||
cell.iconImage = imageFor(node)
|
||||
}
|
||||
|
||||
func imageFor(_ node: Node) -> UIImage? {
|
||||
func imageFor(_ node: Node) -> IconImage? {
|
||||
if let feed = node.representedObject as? Feed {
|
||||
|
||||
let feedIconImage = appDelegate.feedIconDownloader.icon(for: feed)
|
||||
|
||||
Reference in New Issue
Block a user