NetNewsWire/Evergreen/Inspector/BuiltinSmartFeedInspectorVi...

67 lines
1.1 KiB
Swift
Raw Normal View History

2018-01-21 06:48:27 +01:00
//
// BuiltinSmartFeedInspectorViewController.swift
// Evergreen
//
// 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?
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()
}
}
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() {
2018-01-21 07:36:17 +01:00
2018-01-22 06:24:25 +01:00
nameTextField?.stringValue = smartFeed?.nameForDisplay ?? ""
2018-01-21 07:36:17 +01:00
}
2018-01-21 06:48:27 +01:00
}