NetNewsWire/Multiplatform/Shared/Sidebar/SidebarView.swift

57 lines
1.7 KiB
Swift
Raw Normal View History

2020-06-28 21:21:43 +02:00
//
// SidebarView.swift
// NetNewsWire
//
// Created by Maurice Parker on 6/29/20.
2020-06-28 21:21:43 +02:00
// Copyright © 2020 Ranchero Software. All rights reserved.
//
import SwiftUI
import Account
2020-06-28 21:21:43 +02:00
struct SidebarView: View {
// I had to comment out SceneStorage because it blows up if used on macOS
// @SceneStorage("expandedContainers") private var expandedContainerData = Data()
@StateObject private var expandedContainers = SidebarExpandedContainers()
@EnvironmentObject private var sidebarModel: SidebarModel
var body: some View {
List() {
ForEach(sidebarModel.sidebarItems) { sidebarItem in
if let containerID = sidebarItem.containerID {
DisclosureGroup(isExpanded: $expandedContainers[containerID]) {
ForEach(sidebarItem.children) { sidebarItem in
if let containerID = sidebarItem.containerID {
DisclosureGroup(isExpanded: $expandedContainers[containerID]) {
ForEach(sidebarItem.children) { sidebarItem in
2020-07-01 18:13:11 +02:00
NavigationLink(destination: (TimelineContainerView(feed: sidebarItem.feed))) {
SidebarItemView(sidebarItem: sidebarItem)
}
}
} label: {
2020-07-01 18:13:11 +02:00
NavigationLink(destination: (TimelineContainerView(feed: sidebarItem.feed))) {
SidebarItemView(sidebarItem: sidebarItem)
}
}
} else {
2020-07-01 18:13:11 +02:00
NavigationLink(destination: (TimelineContainerView(feed: sidebarItem.feed))) {
SidebarItemView(sidebarItem: sidebarItem)
}
}
}
} label: {
SidebarItemView(sidebarItem: sidebarItem)
}
}
}
2020-06-29 13:16:48 +02:00
}
// .onAppear {
// expandedContainers.data = expandedContainerData
// }
// .onReceive(expandedContainers.objectDidChange) {
// expandedContainerData = expandedContainers.data
// }
}
2020-06-28 21:21:43 +02:00
}