mirror of
https://github.com/yattee/yattee.git
synced 2024-12-13 22:00:31 +05:30
59 lines
1.8 KiB
Swift
59 lines
1.8 KiB
Swift
import SwiftUI
|
|
#if os(iOS)
|
|
import Introspect
|
|
#endif
|
|
|
|
struct AppSidebarNavigation: View {
|
|
@EnvironmentObject<NavigationState> private var navigationState
|
|
|
|
@State private var didApplyPrimaryViewWorkAround = false
|
|
|
|
var body: some View {
|
|
#if os(iOS)
|
|
content.introspectViewController { viewController in
|
|
// workaround for an empty supplementary view on launch
|
|
// the supplementary view is determined by the default selection inside the
|
|
// primary view, but the primary view is not loaded so its selection is not read
|
|
// We work around that by briefly showing the primary view.
|
|
if !didApplyPrimaryViewWorkAround, let splitVC = viewController.children.first as? UISplitViewController {
|
|
UIView.performWithoutAnimation {
|
|
splitVC.show(.primary)
|
|
splitVC.hide(.primary)
|
|
}
|
|
didApplyPrimaryViewWorkAround = true
|
|
}
|
|
}
|
|
#else
|
|
content
|
|
#endif
|
|
}
|
|
|
|
var content: some View {
|
|
NavigationView {
|
|
sidebar
|
|
|
|
Text("Select section")
|
|
.frame(maxWidth: 600)
|
|
Text("Select video")
|
|
}
|
|
}
|
|
|
|
var sidebar: some View {
|
|
List {
|
|
NavigationLink(tag: TabSelection.subscriptions, selection: navigationState.tabSelectionOptionalBinding) {
|
|
SubscriptionsView()
|
|
}
|
|
label: {
|
|
Label("Subscriptions", systemImage: "star")
|
|
}
|
|
|
|
NavigationLink(tag: TabSelection.popular, selection: navigationState.tabSelectionOptionalBinding) {
|
|
PopularVideosView()
|
|
}
|
|
label: {
|
|
Label("Popular", systemImage: "chart.bar")
|
|
}
|
|
}
|
|
}
|
|
}
|