diff --git a/Evergreen.xcodeproj/project.pbxproj b/Evergreen.xcodeproj/project.pbxproj index 7671a145a..d4a9ac507 100644 --- a/Evergreen.xcodeproj/project.pbxproj +++ b/Evergreen.xcodeproj/project.pbxproj @@ -7,7 +7,6 @@ objects = { /* Begin PBXBuildFile section */ - 8403E75B201C4A79007F7246 /* FeedListKeyboardDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8403E75A201C4A79007F7246 /* FeedListKeyboardDelegate.swift */; }; 840D617F2029031C009BC708 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 840D617E2029031C009BC708 /* AppDelegate.swift */; }; 840D61812029031C009BC708 /* MasterViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 840D61802029031C009BC708 /* MasterViewController.swift */; }; 840D61832029031C009BC708 /* DetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 840D61822029031C009BC708 /* DetailViewController.swift */; }; @@ -36,7 +35,6 @@ 844B5B651FEA11F200C7C76A /* GlobalKeyboardShortcuts.plist in Resources */ = {isa = PBXBuildFile; fileRef = 844B5B641FEA11F200C7C76A /* GlobalKeyboardShortcuts.plist */; }; 844B5B671FEA18E300C7C76A /* MainWIndowKeyboardHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844B5B661FEA18E300C7C76A /* MainWIndowKeyboardHandler.swift */; }; 844B5B691FEA20DF00C7C76A /* SidebarKeyboardShortcuts.plist in Resources */ = {isa = PBXBuildFile; fileRef = 844B5B681FEA20DF00C7C76A /* SidebarKeyboardShortcuts.plist */; }; - 84513F901FAA63950023A1A9 /* FeedListControlsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84513F8F1FAA63950023A1A9 /* FeedListControlsView.swift */; }; 845213231FCA5B11003B6E93 /* ImageDownloader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 845213221FCA5B10003B6E93 /* ImageDownloader.swift */; }; 845479881FEB77C000AD8B59 /* TimelineKeyboardShortcuts.plist in Resources */ = {isa = PBXBuildFile; fileRef = 845479871FEB77C000AD8B59 /* TimelineKeyboardShortcuts.plist */; }; 845A29091FC74B8E007B49E3 /* SingleFaviconDownloader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 845A29081FC74B8E007B49E3 /* SingleFaviconDownloader.swift */; }; @@ -128,7 +126,6 @@ 84BBB12D20142A4700F054F5 /* Inspector.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 84BBB12B20142A4700F054F5 /* Inspector.storyboard */; }; 84BBB12E20142A4700F054F5 /* InspectorWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84BBB12C20142A4700F054F5 /* InspectorWindowController.swift */; }; 84C12A151FF5B0080009A267 /* FeedList.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 84C12A141FF5B0080009A267 /* FeedList.storyboard */; }; - 84CC08061FF5D2E000C0C0ED /* FeedListSplitViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84CC08051FF5D2E000C0C0ED /* FeedListSplitViewController.swift */; }; 84CC88181FE59CBF00644329 /* SmartFeedsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84CC88171FE59CBF00644329 /* SmartFeedsController.swift */; }; 84D52E951FE588BB00D14F5B /* DetailStatusBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84D52E941FE588BB00D14F5B /* DetailStatusBarView.swift */; }; 84D5BA20201E8FB6009092BD /* SidebarGearMenuDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84D5BA1F201E8FB6009092BD /* SidebarGearMenuDelegate.swift */; }; @@ -1022,14 +1019,12 @@ children = ( 84C12A141FF5B0080009A267 /* FeedList.storyboard */, 849A978C1ED9EE4D007D329B /* FeedListWindowController.swift */, - 84CC08051FF5D2E000C0C0ED /* FeedListSplitViewController.swift */, 84F204CD1FAACB660076E152 /* FeedListViewController.swift */, - 8403E75A201C4A79007F7246 /* FeedListKeyboardDelegate.swift */, - 84513F8F1FAA63950023A1A9 /* FeedListControlsView.swift */, 84B99C661FAE35E600ECDEDB /* FeedListTreeControllerDelegate.swift */, 84B99C681FAE36B800ECDEDB /* FeedListFolder.swift */, 84B99C6A1FAE370B00ECDEDB /* FeedListFeed.swift */, 84E95CF61FABB3C800552D99 /* FeedList.plist */, + 84DC413A20310AEE00198AD4 /* UnusedIn1.0 */, ); name = "Feed List"; path = Evergreen/FeedList; @@ -1267,6 +1262,16 @@ path = Importers; sourceTree = ""; }; + 84DC413A20310AEE00198AD4 /* UnusedIn1.0 */ = { + isa = PBXGroup; + children = ( + 84CC08051FF5D2E000C0C0ED /* FeedListSplitViewController.swift */, + 8403E75A201C4A79007F7246 /* FeedListKeyboardDelegate.swift */, + 84513F8F1FAA63950023A1A9 /* FeedListControlsView.swift */, + ); + path = UnusedIn1.0; + sourceTree = ""; + }; 84EB380F1FBA8B9F000D2111 /* KeyboardShortcuts */ = { isa = PBXGroup; children = ( @@ -1870,7 +1875,6 @@ files = ( 84F204E01FAACBB30076E152 /* ArticleArray.swift in Sources */, 849C64641ED37A5D003D8FC0 /* AppDelegate.swift in Sources */, - 84513F901FAA63950023A1A9 /* FeedListControlsView.swift in Sources */, 84BBB12E20142A4700F054F5 /* InspectorWindowController.swift in Sources */, 84E46C7D1F75EF7B005ECFB3 /* AppDefaults.swift in Sources */, D5907D972004B7EB005947E5 /* Account+Scriptability.swift in Sources */, @@ -1894,7 +1898,6 @@ D5A2678C20130ECF00A8D3C0 /* Author+Scriptability.swift in Sources */, 84F2D5371FC22FCC00998D64 /* PseudoFeed.swift in Sources */, D553738B20186C20006D8857 /* Article+Scriptability.swift in Sources */, - 8403E75B201C4A79007F7246 /* FeedListKeyboardDelegate.swift in Sources */, 845EE7C11FC2488C00854A1F /* SmartFeed.swift in Sources */, 84702AA41FA27AC0006B8943 /* MarkStatusCommand.swift in Sources */, D5907D7F2004AC00005947E5 /* NSApplication+Scriptability.swift in Sources */, @@ -1945,7 +1948,6 @@ 842611A01FCB72600086A189 /* FeaturedImageDownloader.swift in Sources */, 849A97781ED9EC04007D329B /* TimelineCellLayout.swift in Sources */, 84E8E0EB202F693600562D8F /* DetailWebView.swift in Sources */, - 84CC08061FF5D2E000C0C0ED /* FeedListSplitViewController.swift in Sources */, 849A976C1ED9EBC8007D329B /* TimelineTableRowView.swift in Sources */, 849A977B1ED9EC04007D329B /* UnreadIndicatorView.swift in Sources */, 84B99C9D1FAE83C600ECDEDB /* DeleteFromSidebarCommand.swift in Sources */, diff --git a/Evergreen/FeedList/FeedList.storyboard b/Evergreen/FeedList/FeedList.storyboard index f41a4293c..49f3ac362 100644 --- a/Evergreen/FeedList/FeedList.storyboard +++ b/Evergreen/FeedList/FeedList.storyboard @@ -22,92 +22,35 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + - + - + - + - + @@ -121,11 +64,11 @@ - + - + @@ -139,7 +82,7 @@ - + @@ -186,21 +129,54 @@ + + + + + + + + + + + + + + + + + - + + + + + - + diff --git a/Evergreen/FeedList/FeedListViewController.swift b/Evergreen/FeedList/FeedListViewController.swift index b885478ab..4145f94c6 100644 --- a/Evergreen/FeedList/FeedListViewController.swift +++ b/Evergreen/FeedList/FeedListViewController.swift @@ -23,12 +23,26 @@ struct FeedListUserInfoKey { final class FeedListViewController: NSViewController { @IBOutlet var outlineView: NSOutlineView! + @IBOutlet var openHomePageButton: NSButton! + @IBOutlet var addToFeedsButton: NSButton! + private var sidebarCellAppearance: SidebarCellAppearance! private let treeControllerDelegate = FeedListTreeControllerDelegate() lazy var treeController: TreeController = { TreeController(delegate: treeControllerDelegate) }() + private var selectedNodes: [Node] { + if let nodes = outlineView.selectedItems as? [Node] { + return nodes + } + return [Node]() + } + + private var selectedObjects: [AnyObject] { + return selectedNodes.representedObjects() + } + // MARK: NSViewController override func viewDidLoad() { @@ -38,6 +52,7 @@ final class FeedListViewController: NSViewController { sidebarCellAppearance = SidebarCellAppearance(theme: appDelegate.currentTheme, fontSize: AppDefaults.shared.sidebarFontSize) NotificationCenter.default.addObserver(self, selector: #selector(faviconDidBecomeAvailable(_:)), name: .FaviconDidBecomeAvailable, object: nil) outlineView.needsLayout = true + updateUI() } // MARK: - Notifications @@ -48,6 +63,19 @@ final class FeedListViewController: NSViewController { } } +// MARK: Actions + +extension FeedListViewController { + + func openHomePage(_ sender: Any?) { + + } + + func addToFeeds(_ sender: Any?) { + + } +} + // MARK: - NSOutlineViewDataSource extension FeedListViewController: NSOutlineViewDataSource { @@ -92,6 +120,8 @@ extension FeedListViewController: NSOutlineViewDelegate { func outlineViewSelectionDidChange(_ notification: Notification) { + updateUI() + let selectedRow = self.outlineView.selectedRow if selectedRow < 0 || selectedRow == NSNotFound { @@ -176,4 +206,37 @@ private extension FeedListViewController { NotificationCenter.default.post(name: .FeedListSidebarSelectionDidChange, object: self, userInfo: userInfo) } + + func updateUI() { + + updateButtons() + } + + func updateButtons() { + + let objects = selectedObjects + + if objects.isEmpty { + openHomePageButton.isEnabled = false + addToFeedsButton.isEnabled = false + return + } + + addToFeedsButton.isEnabled = true + + if let _ = singleSelectedHomePageURL() { + openHomePageButton.isEnabled = true + } + else { + openHomePageButton.isEnabled = false + } + } + + func singleSelectedHomePageURL() -> String? { + + guard selectedObjects.count == 1, let homePageURL = (selectedObjects.first! as? FeedListFeed)?.homePageURL, !homePageURL.isEmpty else { + return nil + } + return homePageURL + } } diff --git a/Evergreen/FeedList/FeedListWindowController.swift b/Evergreen/FeedList/FeedListWindowController.swift index 6298ba4b8..f8518dc34 100644 --- a/Evergreen/FeedList/FeedListWindowController.swift +++ b/Evergreen/FeedList/FeedListWindowController.swift @@ -10,19 +10,10 @@ import AppKit class FeedListWindowController : NSWindowController { - override func windowDidLoad() { window!.appearance = NSAppearance(named: .vibrantDark) } - - @IBAction func addToFeeds(_ sender: AnyObject) { - - } - - @IBAction func openHomePage(_ sender: AnyObject) { - - } } diff --git a/Evergreen/FeedList/FeedListControlsView.swift b/Evergreen/FeedList/UnusedIn1.0/FeedListControlsView.swift similarity index 71% rename from Evergreen/FeedList/FeedListControlsView.swift rename to Evergreen/FeedList/UnusedIn1.0/FeedListControlsView.swift index 0943bfe3b..dcbdf7d6d 100644 --- a/Evergreen/FeedList/FeedListControlsView.swift +++ b/Evergreen/FeedList/UnusedIn1.0/FeedListControlsView.swift @@ -8,8 +8,8 @@ import AppKit +// Unused, at least for now. + @objc final class FeedListControlsView: NSView { - @IBOutlet var addToFeedsButton: NSButton! - @IBOutlet var openHomePageButton: NSButton! } diff --git a/Evergreen/FeedList/FeedListKeyboardDelegate.swift b/Evergreen/FeedList/UnusedIn1.0/FeedListKeyboardDelegate.swift similarity index 100% rename from Evergreen/FeedList/FeedListKeyboardDelegate.swift rename to Evergreen/FeedList/UnusedIn1.0/FeedListKeyboardDelegate.swift diff --git a/Evergreen/FeedList/FeedListSplitViewController.swift b/Evergreen/FeedList/UnusedIn1.0/FeedListSplitViewController.swift similarity index 100% rename from Evergreen/FeedList/FeedListSplitViewController.swift rename to Evergreen/FeedList/UnusedIn1.0/FeedListSplitViewController.swift