Add sidebar navigation
This commit is contained in:
parent
e7a04804b4
commit
c1eb9ab927
|
@ -16,8 +16,6 @@ struct SidebarView: View {
|
|||
@StateObject private var expandedContainers = SidebarExpandedContainers()
|
||||
@EnvironmentObject private var sidebarModel: SidebarModel
|
||||
|
||||
// @State private var selected = Set<FeedIdentifier>()
|
||||
|
||||
var body: some View {
|
||||
List() {
|
||||
ForEach(sidebarModel.sidebarItems) { sidebarItem in
|
||||
|
@ -27,13 +25,19 @@ struct SidebarView: View {
|
|||
if let containerID = sidebarItem.containerID {
|
||||
DisclosureGroup(isExpanded: $expandedContainers[containerID]) {
|
||||
ForEach(sidebarItem.children) { sidebarItem in
|
||||
SidebarItemView(sidebarItem: sidebarItem)
|
||||
NavigationLink(destination: (TimelineContainerView(feed: sidebarItem.feed))) {
|
||||
SidebarItemView(sidebarItem: sidebarItem)
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
SidebarItemView(sidebarItem: sidebarItem)
|
||||
NavigationLink(destination: (TimelineContainerView(feed: sidebarItem.feed))) {
|
||||
SidebarItemView(sidebarItem: sidebarItem)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
SidebarItemView(sidebarItem: sidebarItem)
|
||||
NavigationLink(destination: (TimelineContainerView(feed: sidebarItem.feed))) {
|
||||
SidebarItemView(sidebarItem: sidebarItem)
|
||||
}
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
|
|
|
@ -7,21 +7,26 @@
|
|||
//
|
||||
|
||||
import SwiftUI
|
||||
import Account
|
||||
|
||||
struct TimelineContainerView: View {
|
||||
|
||||
@EnvironmentObject private var sceneModel: SceneModel
|
||||
@StateObject private var timelineModel = TimelineModel()
|
||||
var feed: Feed? = nil
|
||||
|
||||
@ViewBuilder var body: some View {
|
||||
TimelineView()
|
||||
.environmentObject(timelineModel)
|
||||
.listStyle(SidebarListStyle())
|
||||
.onAppear {
|
||||
sceneModel.timelineModel = timelineModel
|
||||
timelineModel.delegate = sceneModel
|
||||
timelineModel.rebuildTimelineItems()
|
||||
}
|
||||
if let feed = feed {
|
||||
TimelineView()
|
||||
.environmentObject(timelineModel)
|
||||
.onAppear {
|
||||
sceneModel.timelineModel = timelineModel
|
||||
timelineModel.delegate = sceneModel
|
||||
timelineModel.rebuildTimelineItems(feed)
|
||||
}
|
||||
} else {
|
||||
EmptyView()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,7 +11,10 @@ import Articles
|
|||
|
||||
struct TimelineItem: Identifiable {
|
||||
|
||||
var id: String
|
||||
var article: Article
|
||||
|
||||
var id: String {
|
||||
return article.articleID
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
//
|
||||
// TimelineItemView.swift
|
||||
// NetNewsWire
|
||||
//
|
||||
// Created by Maurice Parker on 7/1/20.
|
||||
// Copyright © 2020 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct TimelineItemView: View {
|
||||
|
||||
var timelineItem: TimelineItem
|
||||
|
||||
var body: some View {
|
||||
Text(verbatim: timelineItem.article.title ?? "N/A")
|
||||
}
|
||||
}
|
||||
|
||||
//struct TimelineItemView_Previews: PreviewProvider {
|
||||
// static var previews: some View {
|
||||
// TimelineItemView()
|
||||
// }
|
||||
//}
|
|
@ -20,13 +20,15 @@ class TimelineModel: ObservableObject {
|
|||
|
||||
@Published var timelineItems = [TimelineItem]()
|
||||
|
||||
private var feeds = [Feed]()
|
||||
|
||||
init() {
|
||||
}
|
||||
|
||||
// MARK: API
|
||||
|
||||
func rebuildTimelineItems() {
|
||||
|
||||
func rebuildTimelineItems(_ feed: Feed) {
|
||||
feeds = [feed]
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,7 +9,10 @@
|
|||
import SwiftUI
|
||||
|
||||
struct TimelineView: View {
|
||||
var body: some View {
|
||||
|
||||
@EnvironmentObject private var timelineModel: TimelineModel
|
||||
|
||||
var body: some View {
|
||||
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,6 +145,8 @@
|
|||
514A89A6244FD6640085E65D /* AddTwitterFeedWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 514A89A4244FD6640085E65D /* AddTwitterFeedWindowController.swift */; };
|
||||
514B7C8323205EFB00BAC947 /* RootSplitViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 514B7C8223205EFB00BAC947 /* RootSplitViewController.swift */; };
|
||||
514B7D1F23219F3C00BAC947 /* AddControllerType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 514B7D1E23219F3C00BAC947 /* AddControllerType.swift */; };
|
||||
514E6BDA24ACEA0400AC6F6E /* TimelineItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 514E6BD924ACEA0400AC6F6E /* TimelineItemView.swift */; };
|
||||
514E6BDB24ACEA0400AC6F6E /* TimelineItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 514E6BD924ACEA0400AC6F6E /* TimelineItemView.swift */; };
|
||||
5154368B229404D1005E1CDF /* FaviconGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51EF0F76227716200050506E /* FaviconGenerator.swift */; };
|
||||
51554C24228B71910055115A /* SyncDatabase.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 51554C01228B6EB50055115A /* SyncDatabase.framework */; };
|
||||
51554C25228B71910055115A /* SyncDatabase.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 51554C01228B6EB50055115A /* SyncDatabase.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
|
@ -1780,6 +1782,7 @@
|
|||
514A89A4244FD6640085E65D /* AddTwitterFeedWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AddTwitterFeedWindowController.swift; path = AddFeed/AddTwitterFeedWindowController.swift; sourceTree = "<group>"; };
|
||||
514B7C8223205EFB00BAC947 /* RootSplitViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootSplitViewController.swift; sourceTree = "<group>"; };
|
||||
514B7D1E23219F3C00BAC947 /* AddControllerType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddControllerType.swift; sourceTree = "<group>"; };
|
||||
514E6BD924ACEA0400AC6F6E /* TimelineItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineItemView.swift; sourceTree = "<group>"; };
|
||||
51554BFC228B6EB50055115A /* SyncDatabase.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = SyncDatabase.xcodeproj; path = Frameworks/SyncDatabase/SyncDatabase.xcodeproj; sourceTree = SOURCE_ROOT; };
|
||||
515A50E5243D07A90089E588 /* ExtensionPointManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExtensionPointManager.swift; sourceTree = "<group>"; };
|
||||
515A5106243D0CCD0089E588 /* TwitterFeedProvider-Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TwitterFeedProvider-Extensions.swift"; sourceTree = "<group>"; };
|
||||
|
@ -2622,6 +2625,7 @@
|
|||
children = (
|
||||
51919FED24AB85E400541E64 /* TimelineContainerView.swift */,
|
||||
51919FF324AB869C00541E64 /* TimelineItem.swift */,
|
||||
514E6BD924ACEA0400AC6F6E /* TimelineItemView.swift */,
|
||||
51919FF024AB864A00541E64 /* TimelineModel.swift */,
|
||||
51919FF624AB8B7700541E64 /* TimelineView.swift */,
|
||||
);
|
||||
|
@ -4725,6 +4729,7 @@
|
|||
51E498FF24A808BB00B667CB /* SingleFaviconDownloader.swift in Sources */,
|
||||
51E4997224A8784300B667CB /* DefaultFeedsImporter.swift in Sources */,
|
||||
51919FAF24AA8EFA00541E64 /* SidebarItemView.swift in Sources */,
|
||||
514E6BDA24ACEA0400AC6F6E /* TimelineItemView.swift in Sources */,
|
||||
51E4990D24A808C500B667CB /* RSHTMLMetadata+Extension.swift in Sources */,
|
||||
51919FF424AB869C00541E64 /* TimelineItem.swift in Sources */,
|
||||
51E49A0024A91FC100B667CB /* RegularSidebarContainerView.swift in Sources */,
|
||||
|
@ -4855,6 +4860,7 @@
|
|||
51E4996724A8760B00B667CB /* ArticleStylesManager.swift in Sources */,
|
||||
1729529B24AA1FD200D65E66 /* MacSearchField.swift in Sources */,
|
||||
51408B7F24A9EC6F0073CF4E /* SidebarItem.swift in Sources */,
|
||||
514E6BDB24ACEA0400AC6F6E /* TimelineItemView.swift in Sources */,
|
||||
51E4996E24A8764C00B667CB /* ActivityManager.swift in Sources */,
|
||||
51E4995A24A873F900B667CB /* ErrorHandler.swift in Sources */,
|
||||
51E4991F24A8094300B667CB /* RSImage-AppIcons.swift in Sources */,
|
||||
|
|
Loading…
Reference in New Issue