mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Make Sidebar expansion state available to SidebarModel
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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?
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user