mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-02-02 20:16:54 +01:00
Make Sidebar expansion state available to SidebarModel
This commit is contained in:
parent
539685586e
commit
2efc0a17a9
@ -10,10 +10,9 @@ import SwiftUI
|
|||||||
import Combine
|
import Combine
|
||||||
import Account
|
import Account
|
||||||
|
|
||||||
final class SidebarExpandedContainers: ObservableObject {
|
struct SidebarExpandedContainers {
|
||||||
|
|
||||||
@Published var expandedTable = [ContainerIdentifier: Bool]()
|
var expandedTable = [ContainerIdentifier: Bool]()
|
||||||
var objectDidChange = PassthroughSubject<Void, Never>()
|
|
||||||
|
|
||||||
var data: Data {
|
var data: Data {
|
||||||
get {
|
get {
|
||||||
@ -41,7 +40,6 @@ final class SidebarExpandedContainers: ObservableObject {
|
|||||||
}
|
}
|
||||||
set(newValue) {
|
set(newValue) {
|
||||||
expandedTable[containerID] = newValue
|
expandedTable[containerID] = newValue
|
||||||
objectDidChange.send()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ class SidebarModel: ObservableObject, UndoableCommandRunner {
|
|||||||
@Published var selectedFeedIdentifiers = Set<FeedIdentifier>()
|
@Published var selectedFeedIdentifiers = Set<FeedIdentifier>()
|
||||||
@Published var selectedFeedIdentifier: FeedIdentifier? = .none
|
@Published var selectedFeedIdentifier: FeedIdentifier? = .none
|
||||||
@Published var isReadFiltered = false
|
@Published var isReadFiltered = false
|
||||||
|
@Published var expandedContainers = SidebarExpandedContainers()
|
||||||
|
|
||||||
weak var delegate: SidebarModelDelegate?
|
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
|
// I had to comment out SceneStorage because it blows up if used on macOS
|
||||||
// @SceneStorage("expandedContainers") private var expandedContainerData = Data()
|
// @SceneStorage("expandedContainers") private var expandedContainerData = Data()
|
||||||
@StateObject private var expandedContainers = SidebarExpandedContainers()
|
|
||||||
|
|
||||||
private let threshold: CGFloat = 80
|
private let threshold: CGFloat = 80
|
||||||
@State private var previousScrollOffset: CGFloat = 0
|
@State private var previousScrollOffset: CGFloat = 0
|
||||||
@ -142,10 +141,10 @@ struct SidebarView: View {
|
|||||||
var rows: some View {
|
var rows: some View {
|
||||||
ForEach(sidebarItems) { sidebarItem in
|
ForEach(sidebarItems) { sidebarItem in
|
||||||
if let containerID = sidebarItem.containerID {
|
if let containerID = sidebarItem.containerID {
|
||||||
DisclosureGroup(isExpanded: $expandedContainers[containerID]) {
|
DisclosureGroup(isExpanded: $sidebarModel.expandedContainers[containerID]) {
|
||||||
ForEach(sidebarItem.children) { sidebarItem in
|
ForEach(sidebarItem.children) { sidebarItem in
|
||||||
if let containerID = sidebarItem.containerID {
|
if let containerID = sidebarItem.containerID {
|
||||||
DisclosureGroup(isExpanded: $expandedContainers[containerID]) {
|
DisclosureGroup(isExpanded: $sidebarModel.expandedContainers[containerID]) {
|
||||||
ForEach(sidebarItem.children) { sidebarItem in
|
ForEach(sidebarItem.children) { sidebarItem in
|
||||||
SidebarItemNavigation(sidebarItem: sidebarItem)
|
SidebarItemNavigation(sidebarItem: sidebarItem)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user