From ec2b23c9f05230364f66b7aa174a0148fc6b1c3d Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Tue, 12 Nov 2019 15:52:07 -0600 Subject: [PATCH] Change Feed Inspector to use same IconView class as other places in code displaying feed icons. --- .../FeedInspectorViewController.swift | 20 ++++-------- Mac/Inspector/Inspector.storyboard | 31 +++++++++---------- Mac/MainWindow/IconView.swift | 1 + 3 files changed, 21 insertions(+), 31 deletions(-) diff --git a/Mac/Inspector/FeedInspectorViewController.swift b/Mac/Inspector/FeedInspectorViewController.swift index 18ac3e770..964668798 100644 --- a/Mac/Inspector/FeedInspectorViewController.swift +++ b/Mac/Inspector/FeedInspectorViewController.swift @@ -12,7 +12,7 @@ import Account final class FeedInspectorViewController: NSViewController, Inspector { - @IBOutlet weak var imageView: NSImageView? + @IBOutlet weak var iconView: IconView! @IBOutlet weak var nameTextField: NSTextField? @IBOutlet weak var homePageURLTextField: NSTextField? @IBOutlet weak var urlTextField: NSTextField? @@ -43,11 +43,7 @@ final class FeedInspectorViewController: NSViewController, Inspector { // MARK: NSViewController override func viewDidLoad() { - imageView!.wantsLayer = true - imageView!.layer?.cornerRadius = 4.0 - updateUI() - NotificationCenter.default.addObserver(self, selector: #selector(imageDidBecomeAvailable(_:)), name: .ImageDidBecomeAvailable, object: nil) } @@ -101,25 +97,21 @@ private extension FeedInspectorViewController { } func updateImage() { - guard let feed = feed else { - imageView?.image = nil + guard let feed = feed, let iconView = iconView else { return } if let feedIcon = appDelegate.feedIconDownloader.icon(for: feed) { - imageView?.image = feedIcon.image + iconView.iconImage = feedIcon return } - if let favicon = appDelegate.faviconDownloader.favicon(for: feed)?.image { - if favicon.size.height < 16.0 && favicon.size.width < 16.0 { - favicon.size = NSSize(width: 16, height: 16) - } - imageView?.image = favicon + if let favicon = appDelegate.faviconDownloader.favicon(for: feed) { + iconView.iconImage = favicon return } - imageView?.image = feed.smallIcon?.image + iconView.iconImage = feed.smallIcon } func updateName() { diff --git a/Mac/Inspector/Inspector.storyboard b/Mac/Inspector/Inspector.storyboard index eb460de87..b35d220cf 100644 --- a/Mac/Inspector/Inspector.storyboard +++ b/Mac/Inspector/Inspector.storyboard @@ -1,8 +1,7 @@ - + - - + @@ -37,14 +36,6 @@ - - - - - - - - @@ -114,13 +105,19 @@ Field + + + + + + + - - + @@ -128,11 +125,12 @@ Field + - + @@ -142,7 +140,7 @@ Field - + @@ -151,7 +149,7 @@ Field - + @@ -294,7 +292,6 @@ Field - diff --git a/Mac/MainWindow/IconView.swift b/Mac/MainWindow/IconView.swift index 92d9f30dd..e03ea6be4 100644 --- a/Mac/MainWindow/IconView.swift +++ b/Mac/MainWindow/IconView.swift @@ -82,6 +82,7 @@ private extension IconView { func commonInit() { addSubview(imageView) wantsLayer = true + layer?.cornerRadius = 4.0 } func rectForImageView() -> NSRect {