I am building a simple Sign Up and Login user flow with SwiftUI in Xcode 14. I am attempting to use the NavigationStack struct, however I am receiving the error below.
I am seeking to correct this code, or to implement another non-deprecated way of using navigation in SwiftUI to control different application views. I would hope to expand on this further by creating additional views (forgot password, login with email link, etc).
import SwiftUI
enum Route : Hashable {
case login
case signup
case app
}
@main
struct MyApp: App {
var body: some Scene {
WindowGroup {
NavigationStack {
ContentView() // Type '() -> ()' cannot conform to 'View'
.navigationDestination(for: Route.self) { // Type '() -> ()' cannot conform to 'View'
route in {
switch route {
case .login:
Text("Login")
case .signup:
Text("Sign Up")
}
}
}
}
}
}
}
route in {}, I get this error:Cannot find 'route' in scope. If you want to provide a full working code solution I would accept as an answer.