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]()
|
@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() {
|
init() {
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidInitialize(_:)), name: .UnreadCountDidInitialize, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidInitialize(_:)), name: .UnreadCountDidInitialize, object: nil)
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(containerChildrenDidChange(_:)), name: .ChildrenDidChange, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(containerChildrenDidChange(_:)), name: .ChildrenDidChange, object: nil)
|
||||||
|
@ -62,7 +86,6 @@ class SidebarModel: ObservableObject {
|
||||||
|
|
||||||
sidebarItems = items
|
sidebarItems = items
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Private
|
// MARK: Private
|
||||||
|
|
|
@ -12,54 +12,72 @@ import Account
|
||||||
struct SidebarView: View {
|
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()
|
@StateObject private var expandedContainers = SidebarExpandedContainers()
|
||||||
@EnvironmentObject private var sidebarModel: SidebarModel
|
@EnvironmentObject private var sidebarModel: SidebarModel
|
||||||
|
|
||||||
|
@ViewBuilder
|
||||||
var body: some View {
|
var body: some View {
|
||||||
List() {
|
#if os(macOS)
|
||||||
ForEach(sidebarModel.sidebarItems) { sidebarItem in
|
List(selection: $sidebarModel.selectedSidebarItems) {
|
||||||
if let containerID = sidebarItem.containerID {
|
containedList
|
||||||
DisclosureGroup(isExpanded: $expandedContainers[containerID]) {
|
}
|
||||||
ForEach(sidebarItem.children) { sidebarItem in
|
#else
|
||||||
if let containerID = sidebarItem.containerID {
|
List {
|
||||||
DisclosureGroup(isExpanded: $expandedContainers[containerID]) {
|
containedList
|
||||||
ForEach(sidebarItem.children) { sidebarItem in
|
}
|
||||||
ZStack {
|
#endif
|
||||||
SidebarItemView(sidebarItem: sidebarItem)
|
// .onAppear {
|
||||||
NavigationLink(destination: (TimelineContainerView(feed: sidebarItem.feed))) {
|
// expandedContainers.data = expandedContainerData
|
||||||
EmptyView()
|
// }
|
||||||
}.buttonStyle(PlainButtonStyle())
|
// .onReceive(expandedContainers.objectDidChange) {
|
||||||
}
|
// expandedContainerData = expandedContainers.data
|
||||||
}
|
// }
|
||||||
} label: {
|
}
|
||||||
|
|
||||||
|
var containedList: some View {
|
||||||
|
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
|
||||||
ZStack {
|
ZStack {
|
||||||
SidebarItemView(sidebarItem: sidebarItem)
|
SidebarItemView(sidebarItem: sidebarItem)
|
||||||
NavigationLink(destination: (TimelineContainerView(feed: sidebarItem.feed))) {
|
NavigationLink(destination: (TimelineContainerView(feed: sidebarItem.feed)),
|
||||||
|
tag: sidebarItem.feed!.feedID!,
|
||||||
|
selection: $sidebarModel.selectedSidebarItem) {
|
||||||
EmptyView()
|
EmptyView()
|
||||||
}.buttonStyle(PlainButtonStyle())
|
}.buttonStyle(PlainButtonStyle())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} label: {
|
||||||
ZStack {
|
ZStack {
|
||||||
SidebarItemView(sidebarItem: sidebarItem)
|
SidebarItemView(sidebarItem: sidebarItem)
|
||||||
NavigationLink(destination: (TimelineContainerView(feed: sidebarItem.feed))) {
|
NavigationLink(destination: (TimelineContainerView(feed: sidebarItem.feed)),
|
||||||
|
tag: sidebarItem.feed!.feedID!,
|
||||||
|
selection: $sidebarModel.selectedSidebarItem) {
|
||||||
EmptyView()
|
EmptyView()
|
||||||
}.buttonStyle(PlainButtonStyle())
|
}.buttonStyle(PlainButtonStyle())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
ZStack {
|
||||||
|
SidebarItemView(sidebarItem: sidebarItem)
|
||||||
|
NavigationLink(destination: (TimelineContainerView(feed: sidebarItem.feed)),
|
||||||
|
tag: sidebarItem.feed!.feedID!,
|
||||||
|
selection: $sidebarModel.selectedSidebarItem) {
|
||||||
|
EmptyView()
|
||||||
|
}.buttonStyle(PlainButtonStyle())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} label: {
|
|
||||||
SidebarItemView(sidebarItem: sidebarItem)
|
|
||||||
}
|
}
|
||||||
|
} label: {
|
||||||
|
SidebarItemView(sidebarItem: sidebarItem)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// .onAppear {
|
|
||||||
// expandedContainers.data = expandedContainerData
|
|
||||||
// }
|
|
||||||
// .onReceive(expandedContainers.objectDidChange) {
|
|
||||||
// expandedContainerData = expandedContainers.data
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4135,46 +4135,46 @@
|
||||||
TargetAttributes = {
|
TargetAttributes = {
|
||||||
51314636235A7BBE00387FDC = {
|
51314636235A7BBE00387FDC = {
|
||||||
CreatedOnToolsVersion = 11.2;
|
CreatedOnToolsVersion = 11.2;
|
||||||
DevelopmentTeam = SHJK2V3AJG;
|
DevelopmentTeam = FQLBNX3GP7;
|
||||||
LastSwiftMigration = 1120;
|
LastSwiftMigration = 1120;
|
||||||
ProvisioningStyle = Automatic;
|
ProvisioningStyle = Automatic;
|
||||||
};
|
};
|
||||||
513C5CE5232571C2003D4054 = {
|
513C5CE5232571C2003D4054 = {
|
||||||
CreatedOnToolsVersion = 11.0;
|
CreatedOnToolsVersion = 11.0;
|
||||||
DevelopmentTeam = SHJK2V3AJG;
|
DevelopmentTeam = FQLBNX3GP7;
|
||||||
ProvisioningStyle = Automatic;
|
ProvisioningStyle = Automatic;
|
||||||
};
|
};
|
||||||
518B2ED12351B3DD00400001 = {
|
518B2ED12351B3DD00400001 = {
|
||||||
CreatedOnToolsVersion = 11.2;
|
CreatedOnToolsVersion = 11.2;
|
||||||
DevelopmentTeam = SHJK2V3AJG;
|
DevelopmentTeam = FQLBNX3GP7;
|
||||||
ProvisioningStyle = Automatic;
|
ProvisioningStyle = Automatic;
|
||||||
TestTargetID = 840D617B2029031C009BC708;
|
TestTargetID = 840D617B2029031C009BC708;
|
||||||
};
|
};
|
||||||
51C0513C24A77DF800194D5E = {
|
51C0513C24A77DF800194D5E = {
|
||||||
CreatedOnToolsVersion = 12.0;
|
CreatedOnToolsVersion = 12.0;
|
||||||
DevelopmentTeam = SHJK2V3AJG;
|
DevelopmentTeam = FQLBNX3GP7;
|
||||||
ProvisioningStyle = Automatic;
|
ProvisioningStyle = Automatic;
|
||||||
};
|
};
|
||||||
51C0514324A77DF800194D5E = {
|
51C0514324A77DF800194D5E = {
|
||||||
CreatedOnToolsVersion = 12.0;
|
CreatedOnToolsVersion = 12.0;
|
||||||
DevelopmentTeam = SHJK2V3AJG;
|
DevelopmentTeam = FQLBNX3GP7;
|
||||||
ProvisioningStyle = Automatic;
|
ProvisioningStyle = Automatic;
|
||||||
};
|
};
|
||||||
6581C73220CED60000F4AD34 = {
|
6581C73220CED60000F4AD34 = {
|
||||||
DevelopmentTeam = SHJK2V3AJG;
|
DevelopmentTeam = FQLBNX3GP7;
|
||||||
ProvisioningStyle = Automatic;
|
ProvisioningStyle = Automatic;
|
||||||
};
|
};
|
||||||
65ED3FA2235DEF6C0081F399 = {
|
65ED3FA2235DEF6C0081F399 = {
|
||||||
DevelopmentTeam = SHJK2V3AJG;
|
DevelopmentTeam = FQLBNX3GP7;
|
||||||
ProvisioningStyle = Automatic;
|
ProvisioningStyle = Automatic;
|
||||||
};
|
};
|
||||||
65ED4090235DEF770081F399 = {
|
65ED4090235DEF770081F399 = {
|
||||||
DevelopmentTeam = SHJK2V3AJG;
|
DevelopmentTeam = FQLBNX3GP7;
|
||||||
ProvisioningStyle = Automatic;
|
ProvisioningStyle = Automatic;
|
||||||
};
|
};
|
||||||
840D617B2029031C009BC708 = {
|
840D617B2029031C009BC708 = {
|
||||||
CreatedOnToolsVersion = 9.3;
|
CreatedOnToolsVersion = 9.3;
|
||||||
DevelopmentTeam = SHJK2V3AJG;
|
DevelopmentTeam = FQLBNX3GP7;
|
||||||
ProvisioningStyle = Automatic;
|
ProvisioningStyle = Automatic;
|
||||||
SystemCapabilities = {
|
SystemCapabilities = {
|
||||||
com.apple.BackgroundModes = {
|
com.apple.BackgroundModes = {
|
||||||
|
@ -4184,7 +4184,7 @@
|
||||||
};
|
};
|
||||||
849C645F1ED37A5D003D8FC0 = {
|
849C645F1ED37A5D003D8FC0 = {
|
||||||
CreatedOnToolsVersion = 8.2.1;
|
CreatedOnToolsVersion = 8.2.1;
|
||||||
DevelopmentTeam = SHJK2V3AJG;
|
DevelopmentTeam = FQLBNX3GP7;
|
||||||
ProvisioningStyle = Automatic;
|
ProvisioningStyle = Automatic;
|
||||||
SystemCapabilities = {
|
SystemCapabilities = {
|
||||||
com.apple.HardenedRuntime = {
|
com.apple.HardenedRuntime = {
|
||||||
|
@ -4194,7 +4194,7 @@
|
||||||
};
|
};
|
||||||
849C64701ED37A5D003D8FC0 = {
|
849C64701ED37A5D003D8FC0 = {
|
||||||
CreatedOnToolsVersion = 8.2.1;
|
CreatedOnToolsVersion = 8.2.1;
|
||||||
DevelopmentTeam = SHJK2V3AJG;
|
DevelopmentTeam = FQLBNX3GP7;
|
||||||
ProvisioningStyle = Automatic;
|
ProvisioningStyle = Automatic;
|
||||||
TestTargetID = 849C645F1ED37A5D003D8FC0;
|
TestTargetID = 849C645F1ED37A5D003D8FC0;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue