Merge branch 'swiftui' of https://github.com/Ranchero-Software/NetNewsWire into swiftui
This commit is contained in:
commit
5abf222c8a
|
@ -20,6 +20,30 @@ class SidebarModel: ObservableObject {
|
|||
|
||||
@Published var sidebarItems = [SidebarItem]()
|
||||
|
||||
#if os(macOS)
|
||||
@Published var selectedSidebarItems = Set<FeedIdentifier>() {
|
||||
didSet {
|
||||
print(selectedSidebarItems)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
private var items = Set<FeedIdentifier>()
|
||||
|
||||
@Published var selectedSidebarItem: FeedIdentifier? = .none {
|
||||
willSet {
|
||||
#if os(macOS)
|
||||
if newValue != nil {
|
||||
items.insert(newValue!)
|
||||
} else {
|
||||
selectedSidebarItems = items
|
||||
items.removeAll()
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
init() {
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidInitialize(_:)), name: .UnreadCountDidInitialize, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(containerChildrenDidChange(_:)), name: .ChildrenDidChange, object: nil)
|
||||
|
@ -62,7 +86,6 @@ class SidebarModel: ObservableObject {
|
|||
|
||||
sidebarItems = items
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: Private
|
||||
|
|
|
@ -12,12 +12,30 @@ import Account
|
|||
struct SidebarView: View {
|
||||
|
||||
// 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()
|
||||
@EnvironmentObject private var sidebarModel: SidebarModel
|
||||
|
||||
@ViewBuilder
|
||||
var body: some View {
|
||||
List() {
|
||||
#if os(macOS)
|
||||
List(selection: $sidebarModel.selectedSidebarItems) {
|
||||
containedList
|
||||
}
|
||||
#else
|
||||
List {
|
||||
containedList
|
||||
}
|
||||
#endif
|
||||
// .onAppear {
|
||||
// expandedContainers.data = expandedContainerData
|
||||
// }
|
||||
// .onReceive(expandedContainers.objectDidChange) {
|
||||
// expandedContainerData = expandedContainers.data
|
||||
// }
|
||||
}
|
||||
|
||||
var containedList: some View {
|
||||
ForEach(sidebarModel.sidebarItems) { sidebarItem in
|
||||
if let containerID = sidebarItem.containerID {
|
||||
DisclosureGroup(isExpanded: $expandedContainers[containerID]) {
|
||||
|
@ -27,7 +45,9 @@ struct SidebarView: View {
|
|||
ForEach(sidebarItem.children) { sidebarItem in
|
||||
ZStack {
|
||||
SidebarItemView(sidebarItem: sidebarItem)
|
||||
NavigationLink(destination: (TimelineContainerView(feed: sidebarItem.feed))) {
|
||||
NavigationLink(destination: (TimelineContainerView(feed: sidebarItem.feed)),
|
||||
tag: sidebarItem.feed!.feedID!,
|
||||
selection: $sidebarModel.selectedSidebarItem) {
|
||||
EmptyView()
|
||||
}.buttonStyle(PlainButtonStyle())
|
||||
}
|
||||
|
@ -35,7 +55,9 @@ struct SidebarView: View {
|
|||
} label: {
|
||||
ZStack {
|
||||
SidebarItemView(sidebarItem: sidebarItem)
|
||||
NavigationLink(destination: (TimelineContainerView(feed: sidebarItem.feed))) {
|
||||
NavigationLink(destination: (TimelineContainerView(feed: sidebarItem.feed)),
|
||||
tag: sidebarItem.feed!.feedID!,
|
||||
selection: $sidebarModel.selectedSidebarItem) {
|
||||
EmptyView()
|
||||
}.buttonStyle(PlainButtonStyle())
|
||||
}
|
||||
|
@ -43,7 +65,9 @@ struct SidebarView: View {
|
|||
} else {
|
||||
ZStack {
|
||||
SidebarItemView(sidebarItem: sidebarItem)
|
||||
NavigationLink(destination: (TimelineContainerView(feed: sidebarItem.feed))) {
|
||||
NavigationLink(destination: (TimelineContainerView(feed: sidebarItem.feed)),
|
||||
tag: sidebarItem.feed!.feedID!,
|
||||
selection: $sidebarModel.selectedSidebarItem) {
|
||||
EmptyView()
|
||||
}.buttonStyle(PlainButtonStyle())
|
||||
}
|
||||
|
@ -55,11 +79,5 @@ struct SidebarView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
// .onAppear {
|
||||
// expandedContainers.data = expandedContainerData
|
||||
// }
|
||||
// .onReceive(expandedContainers.objectDidChange) {
|
||||
// expandedContainerData = expandedContainers.data
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4135,46 +4135,46 @@
|
|||
TargetAttributes = {
|
||||
51314636235A7BBE00387FDC = {
|
||||
CreatedOnToolsVersion = 11.2;
|
||||
DevelopmentTeam = SHJK2V3AJG;
|
||||
DevelopmentTeam = FQLBNX3GP7;
|
||||
LastSwiftMigration = 1120;
|
||||
ProvisioningStyle = Automatic;
|
||||
};
|
||||
513C5CE5232571C2003D4054 = {
|
||||
CreatedOnToolsVersion = 11.0;
|
||||
DevelopmentTeam = SHJK2V3AJG;
|
||||
DevelopmentTeam = FQLBNX3GP7;
|
||||
ProvisioningStyle = Automatic;
|
||||
};
|
||||
518B2ED12351B3DD00400001 = {
|
||||
CreatedOnToolsVersion = 11.2;
|
||||
DevelopmentTeam = SHJK2V3AJG;
|
||||
DevelopmentTeam = FQLBNX3GP7;
|
||||
ProvisioningStyle = Automatic;
|
||||
TestTargetID = 840D617B2029031C009BC708;
|
||||
};
|
||||
51C0513C24A77DF800194D5E = {
|
||||
CreatedOnToolsVersion = 12.0;
|
||||
DevelopmentTeam = SHJK2V3AJG;
|
||||
DevelopmentTeam = FQLBNX3GP7;
|
||||
ProvisioningStyle = Automatic;
|
||||
};
|
||||
51C0514324A77DF800194D5E = {
|
||||
CreatedOnToolsVersion = 12.0;
|
||||
DevelopmentTeam = SHJK2V3AJG;
|
||||
DevelopmentTeam = FQLBNX3GP7;
|
||||
ProvisioningStyle = Automatic;
|
||||
};
|
||||
6581C73220CED60000F4AD34 = {
|
||||
DevelopmentTeam = SHJK2V3AJG;
|
||||
DevelopmentTeam = FQLBNX3GP7;
|
||||
ProvisioningStyle = Automatic;
|
||||
};
|
||||
65ED3FA2235DEF6C0081F399 = {
|
||||
DevelopmentTeam = SHJK2V3AJG;
|
||||
DevelopmentTeam = FQLBNX3GP7;
|
||||
ProvisioningStyle = Automatic;
|
||||
};
|
||||
65ED4090235DEF770081F399 = {
|
||||
DevelopmentTeam = SHJK2V3AJG;
|
||||
DevelopmentTeam = FQLBNX3GP7;
|
||||
ProvisioningStyle = Automatic;
|
||||
};
|
||||
840D617B2029031C009BC708 = {
|
||||
CreatedOnToolsVersion = 9.3;
|
||||
DevelopmentTeam = SHJK2V3AJG;
|
||||
DevelopmentTeam = FQLBNX3GP7;
|
||||
ProvisioningStyle = Automatic;
|
||||
SystemCapabilities = {
|
||||
com.apple.BackgroundModes = {
|
||||
|
@ -4184,7 +4184,7 @@
|
|||
};
|
||||
849C645F1ED37A5D003D8FC0 = {
|
||||
CreatedOnToolsVersion = 8.2.1;
|
||||
DevelopmentTeam = SHJK2V3AJG;
|
||||
DevelopmentTeam = FQLBNX3GP7;
|
||||
ProvisioningStyle = Automatic;
|
||||
SystemCapabilities = {
|
||||
com.apple.HardenedRuntime = {
|
||||
|
@ -4194,7 +4194,7 @@
|
|||
};
|
||||
849C64701ED37A5D003D8FC0 = {
|
||||
CreatedOnToolsVersion = 8.2.1;
|
||||
DevelopmentTeam = SHJK2V3AJG;
|
||||
DevelopmentTeam = FQLBNX3GP7;
|
||||
ProvisioningStyle = Automatic;
|
||||
TestTargetID = 849C645F1ED37A5D003D8FC0;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue