title: How to PREVENT NavigationLink form pushing view on stack based on a boolean
body: <p>I have a user-signup NavigationView where they enter their account info in separate views in a NavigationView stack.</p>
  <p>After they enter in a email/username I check the email is available on the backend and return a boolean if it is available.</p>
  <p>I want to prevent the next view from pushing onto the stack based on this boolean and display an error message (I have the error message working) but I don't know how?</p>
  <p>Is there a NavigationLink modifier I could use for this or another way?</p>
  <p>See images for reference</p>
  <pre><code>class SignupNavigationViewModel: ObservableObject {
      @Published var signupErrorMessage = &quot;&quot;
      @Published var email = &quot;&quot;
      @Published var username = &quot;&quot;
      @Published var password = &quot;&quot;
      @Published var reconfirmPassword = &quot;&quot;
  
      func checkEmailAvailability(email: String, completion: @escaping
   (Result&lt;EmailAvailability, Error&gt;) -&gt; Void) {
          AuthService.checkEmailAvailability(email: email, completion: 
  completion)
      }
  }
      
  </code></pre>
  <pre><code>struct SignupEmailView: View {
      @ObservedObject var signupNavigationViewModel = SignupNavigationViewModel()
  
      var body: some View {
         
          NavigationView {
              VStack {
                      Text(signupNavigationViewModel.signupErrorMessage)
                      HStack {
                          TextField(&quot;enter e-mail&quot;, text: 
  $signupNavigationViewModel.email )
                      }
                  NavigationLink(&quot;continue&quot;, destination: NavigationLink(&quot;continue&quot;, destination: 
  SignupUsername(signupNavigationViewModel: signupNavigationViewModel))
                      .disabled(signupNavigationViewModel.email.isEmpty)
                      .simultaneousGesture(TapGesture().onEnded {
                          checkIfEmailIsAvailable()
             // if email is available allow next view to be pushed on stack        
                      })
              }
          }        
  </code></pre>
  <pre><code>struct SignupUsername: View {
      @ObservedObject var signupNavigationViewModel : SignupNavigationViewModel
      
      var body: some View {
              VStack {
                  Text(signupNavigationViewModel.signupErrorMessage)
                  TextField(&quot;Enter a username&quot;, text: $signupNavigationViewModel.username )
                  NavigationLink(&quot;continue&quot;, destination: 
  SignupPasswordView(signupNavigationViewModel: signupNavigationViewModel) )
                      .disabled(signupNavigationViewModel.username.isEmpty)
                      .simultaneousGesture(TapGesture().onEnded {
                           {check username formatting}
         {check if available, if avail allow password input view }
                      })
              }
   }
  
  </code></pre>
  <p>Thank you!</p>
  <p><a href="https://i.stack.imgur.com/TBQpl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TBQpl.png" alt="enter image description here" /></a>
  <a href="https://i.stack.imgur.com/Z4BBM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Z4BBM.png" alt="enter image description here" /></a></p>