Create Smart Feeds group item in sidebar. Fix #216.
This commit is contained in:
parent
0221eda956
commit
59f06ea764
@ -99,6 +99,7 @@
|
||||
84B99C9D1FAE83C600ECDEDB /* DeleteFromSidebarCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84B99C9C1FAE83C600ECDEDB /* DeleteFromSidebarCommand.swift */; };
|
||||
84BB4B771F11753300858766 /* Data.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84BB4B681F1174D400858766 /* Data.framework */; };
|
||||
84BB4B781F11753300858766 /* Data.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 84BB4B681F1174D400858766 /* Data.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
84CC88181FE59CBF00644329 /* SmartFeedsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84CC88171FE59CBF00644329 /* SmartFeedsController.swift */; };
|
||||
84D52E951FE588BB00D14F5B /* DetailStatusBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84D52E941FE588BB00D14F5B /* DetailStatusBarView.swift */; };
|
||||
84DAEE301F86CAFE0058304B /* OPMLImporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84DAEE2F1F86CAFE0058304B /* OPMLImporter.swift */; };
|
||||
84DAEE321F870B390058304B /* DockBadge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84DAEE311F870B390058304B /* DockBadge.swift */; };
|
||||
@ -495,6 +496,7 @@
|
||||
84B99C9C1FAE83C600ECDEDB /* DeleteFromSidebarCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeleteFromSidebarCommand.swift; sourceTree = "<group>"; };
|
||||
84BB4B611F1174D400858766 /* Data.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Data.xcodeproj; path = Frameworks/Data/Data.xcodeproj; sourceTree = "<group>"; };
|
||||
84CBDDAE1FD3674C005A61AA /* Technotes */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Technotes; sourceTree = "<group>"; };
|
||||
84CC88171FE59CBF00644329 /* SmartFeedsController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SmartFeedsController.swift; sourceTree = "<group>"; };
|
||||
84D52E941FE588BB00D14F5B /* DetailStatusBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailStatusBarView.swift; sourceTree = "<group>"; };
|
||||
84DAEE2F1F86CAFE0058304B /* OPMLImporter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OPMLImporter.swift; sourceTree = "<group>"; };
|
||||
84DAEE311F870B390058304B /* DockBadge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = DockBadge.swift; path = Evergreen/DockBadge.swift; sourceTree = "<group>"; };
|
||||
@ -819,7 +821,7 @@
|
||||
849A978B1ED9EE4D007D329B /* Feed List */,
|
||||
849A97901ED9EF65007D329B /* Progress Window */,
|
||||
84DAEE201F86CAE00058304B /* Importers */,
|
||||
84F2D5341FC22FCB00998D64 /* PseudoFeeds */,
|
||||
84F2D5341FC22FCB00998D64 /* SmartFeeds */,
|
||||
849A97561ED9EB0D007D329B /* Data */,
|
||||
8426119C1FCB6ED40086A189 /* HTMLMetadata */,
|
||||
848F6AE31FC29CFA002D422E /* Favicons */,
|
||||
@ -974,17 +976,18 @@
|
||||
path = Evergreen/Resources/KeyboardShortcuts;
|
||||
sourceTree = SOURCE_ROOT;
|
||||
};
|
||||
84F2D5341FC22FCB00998D64 /* PseudoFeeds */ = {
|
||||
84F2D5341FC22FCB00998D64 /* SmartFeeds */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
84CC88171FE59CBF00644329 /* SmartFeedsController.swift */,
|
||||
84F2D5351FC22FCB00998D64 /* PseudoFeed.swift */,
|
||||
84F2D5391FC2308B00998D64 /* UnreadFeed.swift */,
|
||||
845EE7C01FC2488C00854A1F /* SmartFeed.swift */,
|
||||
84F2D5361FC22FCB00998D64 /* TodayFeedDelegate.swift */,
|
||||
845EE7B01FC2366500854A1F /* StarredFeedDelegate.swift */,
|
||||
);
|
||||
name = PseudoFeeds;
|
||||
path = Evergreen/PseudoFeeds;
|
||||
name = SmartFeeds;
|
||||
path = Evergreen/SmartFeeds;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
84FB9A2C1EDCD6A4003D53B9 /* Frameworks */ = {
|
||||
@ -1362,6 +1365,7 @@
|
||||
842E45E51ED8C6B7000A8B52 /* MainWindowSplitView.swift in Sources */,
|
||||
84F2D53A1FC2308B00998D64 /* UnreadFeed.swift in Sources */,
|
||||
845A29221FC9251E007B49E3 /* SidebarCellLayout.swift in Sources */,
|
||||
84CC88181FE59CBF00644329 /* SmartFeedsController.swift in Sources */,
|
||||
849A97661ED9EB96007D329B /* SidebarViewController.swift in Sources */,
|
||||
849A97641ED9EB96007D329B /* SidebarOutlineView.swift in Sources */,
|
||||
84F2D5371FC22FCC00998D64 /* PseudoFeed.swift in Sources */,
|
||||
|
@ -26,7 +26,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
||||
var authorAvatarDownloader: AuthorAvatarDownloader!
|
||||
var feedIconDownloader: FeedIconDownloader!
|
||||
var appName: String!
|
||||
var pseudoFeeds = [PseudoFeed]()
|
||||
|
||||
var unreadCount = 0 {
|
||||
didSet {
|
||||
@ -145,12 +144,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
||||
|
||||
authorAvatarDownloader = AuthorAvatarDownloader(imageDownloader: imageDownloader)
|
||||
feedIconDownloader = FeedIconDownloader(imageDownloader: imageDownloader)
|
||||
|
||||
let todayFeed = SmartFeed(delegate: TodayFeedDelegate())
|
||||
let unreadFeed = UnreadFeed()
|
||||
let starredFeed = SmartFeed(delegate: StarredFeedDelegate())
|
||||
pseudoFeeds = [todayFeed, unreadFeed, starredFeed]
|
||||
|
||||
|
||||
createAndShowMainWindow()
|
||||
|
||||
#if RELEASE
|
||||
|
@ -21,6 +21,9 @@ final class SidebarTreeControllerDelegate: TreeControllerDelegate {
|
||||
if node.representedObject is Container {
|
||||
return childNodesForContainerNode(node)
|
||||
}
|
||||
if node.representedObject is SmartFeedsController {
|
||||
return childNodesForSmartFeeds(node)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -30,15 +33,18 @@ private extension SidebarTreeControllerDelegate {
|
||||
|
||||
func childNodesForRootNode(_ rootNode: Node) -> [Node]? {
|
||||
|
||||
// The top-level nodes are pseudo-feeds (All Unread, Starred, etc.) and accounts.
|
||||
// The top-level nodes are Smart Feeds and accounts.
|
||||
|
||||
return pseudoFeedNodes(rootNode) + sortedAccountNodes(rootNode)
|
||||
let smartFeedsNode = rootNode.existingOrNewChildNode(with: SmartFeedsController.shared)
|
||||
smartFeedsNode.canHaveChildNodes = true
|
||||
smartFeedsNode.isGroupItem = true
|
||||
|
||||
return [smartFeedsNode] + sortedAccountNodes(rootNode)
|
||||
}
|
||||
|
||||
func pseudoFeedNodes(_ rootNode: Node) -> [Node] {
|
||||
func childNodesForSmartFeeds(_ parentNode: Node) -> [Node] {
|
||||
|
||||
// The appDelegate’s pseudoFeeds are already sorted properly.
|
||||
return appDelegate.pseudoFeeds.map { rootNode.createChildNode($0) }
|
||||
return SmartFeedsController.shared.smartFeeds.map { parentNode.existingOrNewChildNode(with: $0) }
|
||||
}
|
||||
|
||||
func childNodesForContainerNode(_ containerNode: Node) -> [Node]? {
|
||||
|
26
Evergreen/SmartFeeds/SmartFeedsController.swift
Normal file
26
Evergreen/SmartFeeds/SmartFeedsController.swift
Normal file
@ -0,0 +1,26 @@
|
||||
//
|
||||
// SmartFeedsController.swift
|
||||
// Evergreen
|
||||
//
|
||||
// Created by Brent Simmons on 12/16/17.
|
||||
// Copyright © 2017 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import RSCore
|
||||
|
||||
final class SmartFeedsController: DisplayNameProvider {
|
||||
|
||||
public static let shared = SmartFeedsController()
|
||||
let nameForDisplay = NSLocalizedString("Smart Feeds", comment: "Smart Feeds group title")
|
||||
|
||||
var smartFeeds = [AnyObject]()
|
||||
let todayFeed = SmartFeed(delegate: TodayFeedDelegate())
|
||||
let unreadFeed = UnreadFeed()
|
||||
let starredFeed = SmartFeed(delegate: StarredFeedDelegate())
|
||||
|
||||
private init() {
|
||||
|
||||
self.smartFeeds = [todayFeed, unreadFeed, starredFeed]
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user