Change to use a view instead of a function for the navigation wrapper

This commit is contained in:
Maurice Parker 2020-07-15 15:25:41 -05:00
parent 367bd90ec9
commit f32b0bfdc3
1 changed files with 23 additions and 16 deletions

View File

@ -71,13 +71,13 @@ struct SidebarView: View {
if let containerID = sidebarItem.containerID {
DisclosureGroup(isExpanded: $expandedContainers[containerID]) {
ForEach(sidebarItem.children) { sidebarItem in
buildSidebarItemNavigation(sidebarItem)
SidebarItemNavigation(sidebarItem: sidebarItem)
}
} label: {
buildSidebarItemNavigation(sidebarItem)
SidebarItemNavigation(sidebarItem: sidebarItem)
}
} else {
buildSidebarItemNavigation(sidebarItem)
SidebarItemNavigation(sidebarItem: sidebarItem)
}
}
} label: {
@ -91,11 +91,16 @@ struct SidebarView: View {
}
}
func buildSidebarItemNavigation(_ sidebarItem: SidebarItem) -> some View {
struct SidebarItemNavigation: View {
@EnvironmentObject private var sidebarModel: SidebarModel
var sidebarItem: SidebarItem
@ViewBuilder var body: some View {
#if os(macOS)
return SidebarItemView(sidebarItem: sidebarItem).tag(sidebarItem.feed!.feedID!)
SidebarItemView(sidebarItem: sidebarItem).tag(sidebarItem.feed!.feedID!)
#else
return ZStack {
ZStack {
SidebarItemView(sidebarItem: sidebarItem)
NavigationLink(destination: TimelineContainerView(feeds: sidebarModel.selectedFeeds),
tag: sidebarItem.feed!.feedID!,
@ -106,4 +111,6 @@ struct SidebarView: View {
#endif
}
}
}