iOS Development
ios – How one can navigate from a navigation view to a different navigation view with button click on in Swift

I’m making an attempt to navigate from one navigation view to a different with button click on. The circulate must be Content material View -> Login View -> Password View. I efficiently navigated from Content material to Login by appending to navigation path, however once I tried to do the identical inside Login View to go to Password, it would not work. Is that this the correct method to navigate between views? I’m not certain why the next would not work for Login -> Password.
... Content material View
@State personal var path = NavigationPath()
var physique: some View {
NavigationStack(path: $path) {
ZStack {
...some view
Button(motion: {path.append("LoginView")}) {
Picture(systemName: "arrow.proper")
.body(width:30, peak: 30)
.background(.white.opacity(0.5))
.foregroundColor(.white)
.clipShape(Circle()).padding(.prime, 580)
}.navigationDestination(for: String.self) { view in
if view == "LoginView" {
LoginView()
}
else {
PasswordView()
}
}
}
}
}
// login web page
struct LoginView: View {
@State personal var username: String = ""
@State personal var path = NavigationPath()
var physique: some View {
NavigationView {
NavigationStack {
ZStack {
VStack {
Button(motion: {path.append("PasswordView")}) {
Textual content("Proceed")
.padding(.horizontal, 125)
.padding(.vertical, 10)
.font(.system(dimension: 16, weight: .medium))
.foregroundColor(Coloration("DarkGreen"))
.background(Coloration("PrimaryGreen"))
.cornerRadius(25)
}.navigationDestination(for: String.self) { view in
if view == "PasswordView" {
PasswordView()
}
}
}
}
}
}
}
// password web page
struct PasswordView: View {
@State personal var password: String = ""
var physique: some View {
NavigationView {
ZStack {
...password view
}
}
}
}
Credit: www.ismmailgsm.com