Post not yet marked as solved
Post marked as unsolved with 0 replies, 565 views
I do have an app with a sidebar where I place my main navigation. When I navigate from the sidebar my DetailView is shown next to the sidebar as it should. But when I want to navigate from my MainView to a DetailView it's not working. The view is only shown as an overlay.
Is there any way I can navigate around my main window from the sidebar and from the main view itself?
import SwiftUI
@main
struct NavigationTestApp: App {
var body: some Scene {
WindowGroup {
NavigationView {
ContentView()
MainView()
}
}
}
}
struct ContentView: View {
var body: some View {
List {
NavigationLink(
destination: DetailView(),
label: {
Text("DetailView")
})
}
.listStyle(SidebarListStyle())
}
}
struct MainView: View {
var body: some View {
NavigationLink(
destination: DetailView(),
label: {
Text("Navigate") /* Navigation does not work properly here*/
})
.frame(width: 1280, height: 720)
}
}
struct DetailView: View {
var body: some View {
Text("DetailView")
.frame(width: 1280, height: 720)
}
}