In some factors of the code, I would like to make use of this:
NavigationLink(
vacation spot: LoginViewScreen(),
isActive: $navToLogin
) { EmptyView() }
… as a result of my navigation is just not utilizing a button, I take advantage of solely the property as set off to navigate.
I am receiving this warning:
use NavigationLink(worth:label:) inside a Record inside a NavigationStack or NavigationSplitView
The issue is that minimal iOS goal is 14.0 and I am not in a position to make use of NavigationStack
as a result of it’s for iOS 16.0.
I would love one thing like that, the place I can use the each methods. However I’m not having the ability, as a result of the property NavigationPath
must be a @State
, and the states should be a property of the category, and if the property is iOS > 16, all the category is > 16 and a can not instanciate it in my utility
@State var navToLogin: Bool = false
@EnvironmentObject var navigationViewModel: NavigatorViewModel
var physique: some View {
NavigationView {
VStack {
ExampleView()
.onAppear() {
Job {
strive? await Job.sleep(nanoseconds: 5000000000)
navigateToLogin()
}
}
navigationToLogin
}
}
}
var navigationToLogin: some View {
NavigationLink(
vacation spot: LoginViewScreen(),
isActive: $navToLogin
) { EmptyView() }
}
personal func navigateToLogin() {
if #obtainable(iOS 16, *) {
navigationViewModel.navigateTo(.loginScreen)
} else {
navToLogin.toggle()
}
}
Does anybody know how you can work effectively with it ?
Or is there another manner ?