Continue progress on inspectors.
This commit is contained in:
parent
bb08cfaa5b
commit
01627e5dc8
|
@ -10,15 +10,57 @@ import AppKit
|
|||
|
||||
final class BuiltinSmartFeedInspectorViewController: NSViewController, Inspector {
|
||||
|
||||
@IBOutlet var nameTextField: NSTextField?
|
||||
|
||||
private var smartFeed: PseudoFeed? {
|
||||
didSet {
|
||||
updateUI()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Inspector
|
||||
|
||||
let isFallbackInspector = false
|
||||
var objects: [Any]?
|
||||
var objects: [Any]? {
|
||||
didSet {
|
||||
updateSmartFeed()
|
||||
}
|
||||
}
|
||||
|
||||
func canInspect(_ objects: [Any]) -> Bool {
|
||||
|
||||
return objects.count == 1 && objects.first is PseudoFeed
|
||||
guard let _ = singleSmartFeed(from: objects) else {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func willEndInspectingObjects() {
|
||||
// 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)
|
||||
}
|
||||
|
||||
func updateUI() {
|
||||
|
||||
nameTextField?.stringValue = smartFeed?.nameForDisplay ?? ""
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,9 @@ final class FeedInspectorViewController: NSViewController, Inspector {
|
|||
|
||||
private var feed: Feed? {
|
||||
didSet {
|
||||
updateUI()
|
||||
if feed != oldValue {
|
||||
updateUI()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,7 +92,7 @@ private extension FeedInspectorViewController {
|
|||
imageView?.image = feedIcon
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if let favicon = appDelegate.faviconDownloader.favicon(for: feed) {
|
||||
if favicon.size.height < 16.0 && favicon.size.width < 16.0 {
|
||||
favicon.size = NSSize(width: 16, height: 16)
|
||||
|
|
|
@ -11,15 +11,60 @@ import Account
|
|||
|
||||
final class FolderInspectorViewController: NSViewController, Inspector {
|
||||
|
||||
@IBOutlet var nameTextField: NSTextField?
|
||||
|
||||
private var folder: Folder? {
|
||||
didSet {
|
||||
if folder != oldValue {
|
||||
updateUI()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Inspector
|
||||
|
||||
let isFallbackInspector = false
|
||||
var objects: [Any]?
|
||||
var objects: [Any]? {
|
||||
didSet {
|
||||
updateFolder()
|
||||
}
|
||||
}
|
||||
|
||||
func canInspect(_ objects: [Any]) -> Bool {
|
||||
|
||||
return objects.count == 1 && objects.first is Folder
|
||||
guard let _ = singleFolder(from: objects) else {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func willEndInspectingObjects() {
|
||||
// MARK: NSViewController
|
||||
|
||||
override func viewDidLoad() {
|
||||
|
||||
updateUI()
|
||||
}
|
||||
}
|
||||
|
||||
private extension FolderInspectorViewController {
|
||||
|
||||
func singleFolder(from objects: [Any]?) -> Folder? {
|
||||
|
||||
guard let objects = objects, objects.count == 1, let singleFolder = objects.first as? Folder else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return singleFolder
|
||||
}
|
||||
|
||||
func updateFolder() {
|
||||
|
||||
folder = singleFolder(from: objects)
|
||||
}
|
||||
|
||||
func updateUI() {
|
||||
|
||||
nameTextField?.stringValue = folder?.nameForDisplay ?? ""
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ Field</string>
|
|||
</textField>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="2WO-Iu-p5e">
|
||||
<rect key="frame" x="18" y="99" width="220" height="17"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" allowsUndo="NO" sendsActionOnEndEditing="YES" title="Home Page URL" usesSingleLineMode="YES" id="Fg8-rA-G5J">
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" allowsUndo="NO" sendsActionOnEndEditing="YES" title="Home Page" usesSingleLineMode="YES" id="Fg8-rA-G5J">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
|
@ -76,7 +76,7 @@ Field</string>
|
|||
</textField>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ju6-Zo-8X4">
|
||||
<rect key="frame" x="18" y="41" width="220" height="17"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" allowsUndo="NO" sendsActionOnEndEditing="YES" title="Feed URL" usesSingleLineMode="YES" id="zzB-rX-1dK">
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" allowsUndo="NO" sendsActionOnEndEditing="YES" title="Feed" usesSingleLineMode="YES" id="zzB-rX-1dK">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
|
@ -163,6 +163,9 @@ Field</string>
|
|||
<constraint firstAttribute="bottom" secondItem="jHf-rc-GNr" secondAttribute="bottom" constant="20" symbolic="YES" id="n1f-HE-XZ9"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<connections>
|
||||
<outlet property="nameTextField" destination="jHf-rc-GNr" id="ZBT-48-bbv"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<customObject id="4SD-ni-Scy" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
|
@ -202,6 +205,9 @@ Field</string>
|
|||
<constraint firstAttribute="trailing" secondItem="4Xp-FX-kn3" secondAttribute="trailing" constant="20" symbolic="YES" id="aEl-FU-VDu"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<connections>
|
||||
<outlet property="nameTextField" destination="4Xp-FX-kn3" id="iJx-DZ-MjF"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<customObject id="3Xn-vX-2s9" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
|
|
Loading…
Reference in New Issue