Add SmartFeeds to outline
This commit is contained in:
parent
72ef643a5f
commit
86b929743b
@ -23,4 +23,9 @@ extension SceneModel: SidebarModelDelegate {
|
|||||||
print("**** sidebar selection changed ***")
|
print("**** sidebar selection changed ***")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func unreadCount(for feed: Feed) -> Int {
|
||||||
|
// TODO: Get the count from the timeline if Feed is the current timeline
|
||||||
|
return feed.unreadCount
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
56
Multiplatform/Shared/Sidebar/SidebarItem.swift
Normal file
56
Multiplatform/Shared/Sidebar/SidebarItem.swift
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
//
|
||||||
|
// SidebarItem.swift
|
||||||
|
// NetNewsWire
|
||||||
|
//
|
||||||
|
// Created by Maurice Parker on 6/29/20.
|
||||||
|
// Copyright © 2020 Ranchero Software. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import RSCore
|
||||||
|
import Account
|
||||||
|
|
||||||
|
public enum SidebarItemIdentifier: Hashable, Equatable {
|
||||||
|
case smartFeedController
|
||||||
|
case account(String)
|
||||||
|
case feed(FeedIdentifier)
|
||||||
|
}
|
||||||
|
|
||||||
|
struct SidebarItem: Identifiable {
|
||||||
|
|
||||||
|
var id: SidebarItemIdentifier
|
||||||
|
var represented: Any
|
||||||
|
var children: [SidebarItem]?
|
||||||
|
|
||||||
|
var unreadCount: Int
|
||||||
|
|
||||||
|
var nameForDisplay: String {
|
||||||
|
guard let displayNameProvider = represented as? DisplayNameProvider else { return "" }
|
||||||
|
return displayNameProvider.nameForDisplay
|
||||||
|
}
|
||||||
|
|
||||||
|
init(_ smartFeedsController: SmartFeedsController) {
|
||||||
|
self.id = .smartFeedController
|
||||||
|
self.represented = smartFeedsController
|
||||||
|
self.children = [SidebarItem]()
|
||||||
|
self.unreadCount = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
init(_ account: Account) {
|
||||||
|
self.id = .account(account.accountID)
|
||||||
|
self.represented = account
|
||||||
|
self.children = [SidebarItem]()
|
||||||
|
self.unreadCount = account.unreadCount
|
||||||
|
}
|
||||||
|
|
||||||
|
init(_ feed: Feed, unreadCount: Int) {
|
||||||
|
self.id = .feed(feed.feedID!)
|
||||||
|
self.represented = feed
|
||||||
|
self.unreadCount = unreadCount
|
||||||
|
}
|
||||||
|
|
||||||
|
mutating func addChild(_ sidebarItem: SidebarItem) {
|
||||||
|
children?.append(sidebarItem)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -11,10 +11,26 @@ import Account
|
|||||||
|
|
||||||
protocol SidebarModelDelegate: class {
|
protocol SidebarModelDelegate: class {
|
||||||
func sidebarSelectionDidChange(_: SidebarModel, feeds: [Feed]?)
|
func sidebarSelectionDidChange(_: SidebarModel, feeds: [Feed]?)
|
||||||
|
func unreadCount(for: Feed) -> Int
|
||||||
}
|
}
|
||||||
|
|
||||||
class SidebarModel: ObservableObject {
|
class SidebarModel: ObservableObject {
|
||||||
|
|
||||||
weak var delegate: SidebarModelDelegate?
|
weak var delegate: SidebarModelDelegate?
|
||||||
|
|
||||||
|
@Published var sidebarItems = [SidebarItem]()
|
||||||
|
|
||||||
|
func rebuildSidebarItems() {
|
||||||
|
guard let delegate = delegate else { return }
|
||||||
|
var items = [SidebarItem]()
|
||||||
|
|
||||||
|
var smartFeedControllerItem = SidebarItem(SmartFeedsController.shared)
|
||||||
|
for feed in SmartFeedsController.shared.smartFeeds {
|
||||||
|
smartFeedControllerItem.addChild(SidebarItem(feed, unreadCount: delegate.unreadCount(for: feed)))
|
||||||
|
}
|
||||||
|
items.append(smartFeedControllerItem)
|
||||||
|
|
||||||
|
sidebarItems = items
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,22 +14,23 @@ struct SidebarView: View {
|
|||||||
@StateObject private var sidebarModel = SidebarModel()
|
@StateObject private var sidebarModel = SidebarModel()
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Text("Sidebar")
|
List {
|
||||||
.onAppear {
|
ForEach(sidebarModel.sidebarItems) { section in
|
||||||
sceneModel.sidebarModel = sidebarModel
|
Section(header: Text(section.nameForDisplay)) {
|
||||||
sidebarModel.delegate = sceneModel
|
ForEach(section.children ?? [SidebarItem]()) { topItem in
|
||||||
|
OutlineGroup(topItem, children: \.children) { sidebarItem in
|
||||||
|
Text(sidebarItem.nameForDisplay)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// List {
|
.navigationTitle(Text("Feeds"))
|
||||||
// ForEach(canvases) { canvas in
|
.onAppear {
|
||||||
// Section(header: Text(canvas.name)) {
|
sceneModel.sidebarModel = sidebarModel
|
||||||
// OutlineGroup(canvas.graphics, children: \.children)
|
sidebarModel.delegate = sceneModel
|
||||||
// { graphic in
|
sidebarModel.rebuildSidebarItems()
|
||||||
// GraphicRow(graphic)
|
}
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,6 +110,8 @@
|
|||||||
513C5D0C232574DA003D4054 /* RSTree.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84C37F9520DD8CFE00CA8CF5 /* RSTree.framework */; };
|
513C5D0C232574DA003D4054 /* RSTree.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84C37F9520DD8CFE00CA8CF5 /* RSTree.framework */; };
|
||||||
513C5D0E232574E4003D4054 /* SyncDatabase.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 51554C01228B6EB50055115A /* SyncDatabase.framework */; };
|
513C5D0E232574E4003D4054 /* SyncDatabase.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 51554C01228B6EB50055115A /* SyncDatabase.framework */; };
|
||||||
513CCF2524880C1500C55709 /* MasterFeedTableViewIdentifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 513CCF08248808BA00C55709 /* MasterFeedTableViewIdentifier.swift */; };
|
513CCF2524880C1500C55709 /* MasterFeedTableViewIdentifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 513CCF08248808BA00C55709 /* MasterFeedTableViewIdentifier.swift */; };
|
||||||
|
51408B7E24A9EC6F0073CF4E /* SidebarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51408B7D24A9EC6F0073CF4E /* SidebarItem.swift */; };
|
||||||
|
51408B7F24A9EC6F0073CF4E /* SidebarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51408B7D24A9EC6F0073CF4E /* SidebarItem.swift */; };
|
||||||
5141E7392373C18B0013FF27 /* WebFeedInspectorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5141E7382373C18B0013FF27 /* WebFeedInspectorViewController.swift */; };
|
5141E7392373C18B0013FF27 /* WebFeedInspectorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5141E7382373C18B0013FF27 /* WebFeedInspectorViewController.swift */; };
|
||||||
5142192A23522B5500E07E2C /* ImageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5142192923522B5500E07E2C /* ImageViewController.swift */; };
|
5142192A23522B5500E07E2C /* ImageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5142192923522B5500E07E2C /* ImageViewController.swift */; };
|
||||||
514219372352510100E07E2C /* ImageScrollView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 514219362352510100E07E2C /* ImageScrollView.swift */; };
|
514219372352510100E07E2C /* ImageScrollView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 514219362352510100E07E2C /* ImageScrollView.swift */; };
|
||||||
@ -1715,6 +1717,7 @@
|
|||||||
513C5CEB232571C2003D4054 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = "<group>"; };
|
513C5CEB232571C2003D4054 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = "<group>"; };
|
||||||
513C5CED232571C2003D4054 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
513C5CED232571C2003D4054 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
513CCF08248808BA00C55709 /* MasterFeedTableViewIdentifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MasterFeedTableViewIdentifier.swift; sourceTree = "<group>"; };
|
513CCF08248808BA00C55709 /* MasterFeedTableViewIdentifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MasterFeedTableViewIdentifier.swift; sourceTree = "<group>"; };
|
||||||
|
51408B7D24A9EC6F0073CF4E /* SidebarItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SidebarItem.swift; sourceTree = "<group>"; };
|
||||||
5141E7382373C18B0013FF27 /* WebFeedInspectorViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebFeedInspectorViewController.swift; sourceTree = "<group>"; };
|
5141E7382373C18B0013FF27 /* WebFeedInspectorViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebFeedInspectorViewController.swift; sourceTree = "<group>"; };
|
||||||
5141E7552374A2890013FF27 /* DetailIconSchemeHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailIconSchemeHandler.swift; sourceTree = "<group>"; };
|
5141E7552374A2890013FF27 /* DetailIconSchemeHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailIconSchemeHandler.swift; sourceTree = "<group>"; };
|
||||||
5142192923522B5500E07E2C /* ImageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageViewController.swift; sourceTree = "<group>"; };
|
5142192923522B5500E07E2C /* ImageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageViewController.swift; sourceTree = "<group>"; };
|
||||||
@ -2757,6 +2760,7 @@
|
|||||||
children = (
|
children = (
|
||||||
51E499FC24A9137600B667CB /* SidebarModel.swift */,
|
51E499FC24A9137600B667CB /* SidebarModel.swift */,
|
||||||
51E499FF24A91FC100B667CB /* SidebarView.swift */,
|
51E499FF24A91FC100B667CB /* SidebarView.swift */,
|
||||||
|
51408B7D24A9EC6F0073CF4E /* SidebarItem.swift */,
|
||||||
);
|
);
|
||||||
path = Sidebar;
|
path = Sidebar;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -4607,6 +4611,7 @@
|
|||||||
51E4990B24A808C500B667CB /* ImageDownloader.swift in Sources */,
|
51E4990B24A808C500B667CB /* ImageDownloader.swift in Sources */,
|
||||||
51E498F424A8085D00B667CB /* SmartFeedDelegate.swift in Sources */,
|
51E498F424A8085D00B667CB /* SmartFeedDelegate.swift in Sources */,
|
||||||
51E4993024A8676400B667CB /* ArticleSorter.swift in Sources */,
|
51E4993024A8676400B667CB /* ArticleSorter.swift in Sources */,
|
||||||
|
51408B7E24A9EC6F0073CF4E /* SidebarItem.swift in Sources */,
|
||||||
51E4990A24A808C500B667CB /* FeaturedImageDownloader.swift in Sources */,
|
51E4990A24A808C500B667CB /* FeaturedImageDownloader.swift in Sources */,
|
||||||
51E4993824A8680E00B667CB /* Reachability.swift in Sources */,
|
51E4993824A8680E00B667CB /* Reachability.swift in Sources */,
|
||||||
51E4993224A8676400B667CB /* FetchRequestQueue.swift in Sources */,
|
51E4993224A8676400B667CB /* FetchRequestQueue.swift in Sources */,
|
||||||
@ -4703,6 +4708,7 @@
|
|||||||
51E4990E24A808CC00B667CB /* HTMLMetadataDownloader.swift in Sources */,
|
51E4990E24A808CC00B667CB /* HTMLMetadataDownloader.swift in Sources */,
|
||||||
51E498FB24A808BA00B667CB /* FaviconGenerator.swift in Sources */,
|
51E498FB24A808BA00B667CB /* FaviconGenerator.swift in Sources */,
|
||||||
51E4996724A8760B00B667CB /* ArticleStylesManager.swift in Sources */,
|
51E4996724A8760B00B667CB /* ArticleStylesManager.swift in Sources */,
|
||||||
|
51408B7F24A9EC6F0073CF4E /* SidebarItem.swift in Sources */,
|
||||||
51E4996E24A8764C00B667CB /* ActivityManager.swift in Sources */,
|
51E4996E24A8764C00B667CB /* ActivityManager.swift in Sources */,
|
||||||
51E4995A24A873F900B667CB /* ErrorHandler.swift in Sources */,
|
51E4995A24A873F900B667CB /* ErrorHandler.swift in Sources */,
|
||||||
51E4991F24A8094300B667CB /* RSImage-AppIcons.swift in Sources */,
|
51E4991F24A8094300B667CB /* RSImage-AppIcons.swift in Sources */,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user