I'm having problems doing navigation in a SwiftUI Apple Watch app. There's minimal resources online regarding this.
I mostly understand how to create SwiftUI views, but I'm not sure what the best way to navigate from SwiftUI view to another SwiftUI view is.
Is there a way to push a user to another SwiftUI screen when they tap a button?
To provide a very basic example how it can work on watchOS.
struct ListView: View {
var body: some View {
List{
RowView(title: "Row 1")
RowView(title: "Row 2")
RowView(title: "Row 3")
RowView(title: "Row 4")
}
.listStyle(.carousel)
}
}
struct RowView: View {
let title: String
var body: some View {
NavigationLink(destination: Text("Detail \(title)")) {
Text(title)
.frame(height: 80, alignment: .topTrailing)
.listRowBackground(
Color.blue
.cornerRadius(12)
)
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With