2018-01-21 06:48:27 +01:00
|
|
|
//
|
|
|
|
// BuiltinSmartFeedInspectorViewController.swift
|
2018-08-29 07:18:24 +02:00
|
|
|
// NetNewsWire
|
2018-01-21 06:48:27 +01:00
|
|
|
//
|
|
|
|
// Created by Brent Simmons on 1/20/18.
|
|
|
|
// Copyright © 2018 Ranchero Software. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import AppKit
|
|
|
|
|
2018-01-21 07:36:17 +01:00
|
|
|
final class BuiltinSmartFeedInspectorViewController: NSViewController, Inspector {
|
2018-01-21 06:48:27 +01:00
|
|
|
|
2018-01-22 06:24:25 +01:00
|
|
|
@IBOutlet var nameTextField: NSTextField?
|
2020-12-10 00:24:55 +01:00
|
|
|
@IBOutlet weak var smartFeedImageView: NSImageView!
|
|
|
|
|
2018-01-22 06:24:25 +01:00
|
|
|
private var smartFeed: PseudoFeed? {
|
|
|
|
didSet {
|
|
|
|
updateUI()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: Inspector
|
|
|
|
|
2018-01-21 07:36:17 +01:00
|
|
|
let isFallbackInspector = false
|
2018-01-22 06:24:25 +01:00
|
|
|
var objects: [Any]? {
|
|
|
|
didSet {
|
|
|
|
updateSmartFeed()
|
|
|
|
}
|
|
|
|
}
|
2020-09-07 19:34:37 +02:00
|
|
|
var windowTitle: String = NSLocalizedString("Smart Feed Inspector", comment: "Smart Feed Inspector window title")
|
2018-01-21 07:36:17 +01:00
|
|
|
|
|
|
|
func canInspect(_ objects: [Any]) -> Bool {
|
|
|
|
|
2018-01-22 06:24:25 +01:00
|
|
|
guard let _ = singleSmartFeed(from: objects) else {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: NSViewController
|
|
|
|
|
|
|
|
override func viewDidLoad() {
|
|
|
|
|
|
|
|
updateUI()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private extension BuiltinSmartFeedInspectorViewController {
|
|
|
|
|
|
|
|
func singleSmartFeed(from objects: [Any]?) -> PseudoFeed? {
|
|
|
|
|
|
|
|
guard let objects = objects, objects.count == 1, let singleSmartFeed = objects.first as? PseudoFeed else {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return singleSmartFeed
|
|
|
|
}
|
|
|
|
|
|
|
|
func updateSmartFeed() {
|
|
|
|
|
|
|
|
smartFeed = singleSmartFeed(from: objects)
|
2018-01-21 07:36:17 +01:00
|
|
|
}
|
|
|
|
|
2018-01-22 06:24:25 +01:00
|
|
|
func updateUI() {
|
|
|
|
nameTextField?.stringValue = smartFeed?.nameForDisplay ?? ""
|
2020-09-07 19:59:14 +02:00
|
|
|
windowTitle = smartFeed?.nameForDisplay ?? NSLocalizedString("Smart Feed Inspector", comment: "Smart Feed Inspector window title")
|
2020-12-10 00:24:55 +01:00
|
|
|
if #available(macOS 11.0, *) {
|
|
|
|
smartFeedImageView?.image = smartFeed?.smallIcon?.image
|
|
|
|
}
|
2018-01-21 07:36:17 +01:00
|
|
|
}
|
2018-01-21 06:48:27 +01:00
|
|
|
}
|