2020-06-28 21:21:43 +02:00
|
|
|
//
|
|
|
|
// SidebarView.swift
|
|
|
|
// NetNewsWire
|
|
|
|
//
|
2020-06-29 20:14:03 +02:00
|
|
|
// 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
|
2020-07-01 03:23:22 +02:00
|
|
|
import Account
|
2020-06-28 21:21:43 +02:00
|
|
|
|
|
|
|
struct SidebarView: View {
|
2020-06-29 00:43:20 +02:00
|
|
|
|
2020-07-01 03:38:55 +02:00
|
|
|
// I had to comment out SceneStorage because it blows up if used on macOS
|
|
|
|
// @SceneStorage("expandedContainers") private var expandedContainerData = Data()
|
2020-07-01 03:23:22 +02:00
|
|
|
@StateObject private var expandedContainers = SidebarExpandedContainers()
|
2020-06-29 20:14:03 +02:00
|
|
|
@EnvironmentObject private var sidebarModel: SidebarModel
|
2020-06-29 00:43:20 +02:00
|
|
|
|
2020-06-29 20:14:03 +02:00
|
|
|
var body: some View {
|
2020-07-01 03:23:22 +02:00
|
|
|
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)
|
|
|
|
}
|
2020-07-01 03:23:22 +02:00
|
|
|
}
|
|
|
|
} label: {
|
2020-07-01 18:13:11 +02:00
|
|
|
NavigationLink(destination: (TimelineContainerView(feed: sidebarItem.feed))) {
|
|
|
|
SidebarItemView(sidebarItem: sidebarItem)
|
|
|
|
}
|
2020-07-01 03:23:22 +02:00
|
|
|
}
|
|
|
|
} else {
|
2020-07-01 18:13:11 +02:00
|
|
|
NavigationLink(destination: (TimelineContainerView(feed: sidebarItem.feed))) {
|
|
|
|
SidebarItemView(sidebarItem: sidebarItem)
|
|
|
|
}
|
2020-07-01 03:23:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} label: {
|
|
|
|
SidebarItemView(sidebarItem: sidebarItem)
|
|
|
|
}
|
|
|
|
}
|
2020-06-29 00:43:20 +02:00
|
|
|
}
|
2020-06-29 13:16:48 +02:00
|
|
|
}
|
2020-07-01 03:38:55 +02:00
|
|
|
// .onAppear {
|
|
|
|
// expandedContainers.data = expandedContainerData
|
|
|
|
// }
|
|
|
|
// .onReceive(expandedContainers.objectDidChange) {
|
|
|
|
// expandedContainerData = expandedContainers.data
|
|
|
|
// }
|
2020-06-29 00:43:20 +02:00
|
|
|
}
|
2020-06-28 21:21:43 +02:00
|
|
|
}
|