I am new to learning in swiftUI, I have to manage following requirement in SwiftUI,
I have to manage my navigation stack in swiftUI can you please suggest me
Here is my first entry of the app :-
import SwiftUI
@main
struct MyApp: App {
var body: some Scene {
WindowGroup {
Landing()
}
}
}
here is the Landing Page :-
struct Landing: View {
var body: some View {
NavigationStack {
HStack(spacing: 13) {
NavigationLink {
Login()
} label: {
DetezoMainNavigationBtn(title: LandingScreenTexts.logIn)
}
NavigationLink {
SignUp()
} label: {
DetezoMainNavigationBtn(title: LandingScreenTexts.signUp)
}
}
}
}
here is my Login Page :-
struct Login: View {
var body: some View {
NavigationStack {
UnderlineButton(text: LoginScreenTexts.forgotPassword) {
isFogotClickClicked = true
}
DetezoMainButton(title: LoginScreenTexts.logIn, acttion: {
isSignInClicked = true
})
PlainButton(text: LandingScreenTexts.signUp) {
isSignUpClicked = true
}
}
.navigationDestination(isPresented: $isSignInClicked, destination: {
MyZone()
})
.navigationDestination(isPresented: $isSignUpClicked, destination: {
SignUp()
})
.navigationDestination(isPresented: $isFogotClickClicked, destination: {
ForgotPassword()
})
}
Okay now my requirement is when I click login from Landing Page then swipe to back gesture and navigation back should work.
And then if I click Forgot button or SignUp button on the Login Page then also swipe to back gesture and navigation back should work.
But when I click on Login button on login page then swipe to back gesture and navigation back should not work. And navigation Stack reset and MyZone page should be the new parent of navigation stack




