mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-12-23 07:36:48 +00:00
Separate tab and sidebar selection
This commit is contained in:
parent
73f3fef738
commit
1baa02948b
1 changed files with 5 additions and 6 deletions
|
@ -17,7 +17,8 @@ struct IceCubesApp: App {
|
||||||
@StateObject private var quickLook = QuickLook()
|
@StateObject private var quickLook = QuickLook()
|
||||||
@StateObject private var theme = Theme()
|
@StateObject private var theme = Theme()
|
||||||
|
|
||||||
@State private var selectedTab: Tab? = .timeline
|
@State private var selectedTab: Tab = .timeline
|
||||||
|
@State private var selectSidebarItem: Tab? = .timeline
|
||||||
@State private var popToRootTab: Tab = .other
|
@State private var popToRootTab: Tab = .other
|
||||||
|
|
||||||
private var availableTabs: [Tab] {
|
private var availableTabs: [Tab] {
|
||||||
|
@ -73,11 +74,9 @@ struct IceCubesApp: App {
|
||||||
/// Stupid hack to trigger onChange binding in tab views.
|
/// Stupid hack to trigger onChange binding in tab views.
|
||||||
popToRootTab = .other
|
popToRootTab = .other
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) {
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) {
|
||||||
if let selectedTab {
|
|
||||||
popToRootTab = selectedTab
|
popToRootTab = selectedTab
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
selectedTab = newTab
|
selectedTab = newTab
|
||||||
})) {
|
})) {
|
||||||
ForEach(availableTabs) { tab in
|
ForEach(availableTabs) { tab in
|
||||||
|
@ -94,7 +93,7 @@ struct IceCubesApp: App {
|
||||||
|
|
||||||
private var splitView: some View {
|
private var splitView: some View {
|
||||||
NavigationSplitView {
|
NavigationSplitView {
|
||||||
List(availableTabs, selection: $selectedTab) { tab in
|
List(availableTabs, selection: $selectSidebarItem) { tab in
|
||||||
NavigationLink(value: tab) {
|
NavigationLink(value: tab) {
|
||||||
tab.label
|
tab.label
|
||||||
}
|
}
|
||||||
|
@ -102,7 +101,7 @@ struct IceCubesApp: App {
|
||||||
.scrollContentBackground(.hidden)
|
.scrollContentBackground(.hidden)
|
||||||
.background(theme.secondaryBackgroundColor)
|
.background(theme.secondaryBackgroundColor)
|
||||||
} detail: {
|
} detail: {
|
||||||
selectedTab?.makeContentView(popToRootTab: $popToRootTab)
|
selectSidebarItem?.makeContentView(popToRootTab: $popToRootTab)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue