This is a content view for a test app that had the issue pre-beta 5, but works fine on my iPad with beta 5
import SwiftUI
class Item: Identifiable, Hashable {
var name: String
init(name: String) {
self.name = name
}
static func == (lhs: Item, rhs: Item) -> Bool {
lhs.name == rhs.name
}
func hash(into hasher: inout Hasher) {
hasher.combine(name)
}
}
class Model: ObservableObject {
@Published var path = [Item]()
}
struct ContentView: View {
var items = [
Item(name: "Item 1"),
Item(name: "Item 2"),
Item(name: "Item 3"),
]
@StateObject private var model = Model()
var body: some View {
TabView {
Text("Go to Tab 2")
.tabItem { Label("Tab 1", systemImage: "storefront") }
.tag("1")
tab2()
.tabItem { Label("Tab 2", systemImage: "globe") }
.tag("2")
}
}
@ViewBuilder
func tab2() -> some View {
NavigationStack(path: $model.path) {
List(items) { item in
NavigationLink(item.name, value: item)
}
.navigationDestination(for: Item.self) { item in
DetailView(item: item)
}
}
}
}
struct DetailView: View {
var item: Item
var body: some View {
Text("Details...\(item.name)")
}
}
#Preview {
ContentView()
}