Make Sidebar expansion state available to SidebarModel

This commit is contained in:
Maurice Parker 2020-07-26 15:31:32 -05:00
parent 539685586e
commit 2efc0a17a9
3 changed files with 5 additions and 7 deletions

View File

@ -10,10 +10,9 @@ import SwiftUI
import Combine
import Account
final class SidebarExpandedContainers: ObservableObject {
struct SidebarExpandedContainers {
@Published var expandedTable = [ContainerIdentifier: Bool]()
var objectDidChange = PassthroughSubject<Void, Never>()
var expandedTable = [ContainerIdentifier: Bool]()
var data: Data {
get {
@ -41,7 +40,6 @@ final class SidebarExpandedContainers: ObservableObject {
}
set(newValue) {
expandedTable[containerID] = newValue
objectDidChange.send()
}
}

View File

@ -21,6 +21,7 @@ class SidebarModel: ObservableObject, UndoableCommandRunner {
@Published var selectedFeedIdentifiers = Set<FeedIdentifier>()
@Published var selectedFeedIdentifier: FeedIdentifier? = .none
@Published var isReadFiltered = false
@Published var expandedContainers = SidebarExpandedContainers()
weak var delegate: SidebarModelDelegate?

View File

@ -19,7 +19,6 @@ 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()
private let threshold: CGFloat = 80
@State private var previousScrollOffset: CGFloat = 0
@ -142,10 +141,10 @@ struct SidebarView: View {
var rows: some View {
ForEach(sidebarItems) { sidebarItem in
if let containerID = sidebarItem.containerID {
DisclosureGroup(isExpanded: $expandedContainers[containerID]) {
DisclosureGroup(isExpanded: $sidebarModel.expandedContainers[containerID]) {
ForEach(sidebarItem.children) { sidebarItem in
if let containerID = sidebarItem.containerID {
DisclosureGroup(isExpanded: $expandedContainers[containerID]) {
DisclosureGroup(isExpanded: $sidebarModel.expandedContainers[containerID]) {
ForEach(sidebarItem.children) { sidebarItem in
SidebarItemNavigation(sidebarItem: sidebarItem)
}