title: How to dynamically hide navigation back button in SwiftUI
body: <p>I need to <strong>temporarily</strong> hide the Back Button in a view during an asynchronous operation.
  I want to prevent user from leaving the view before the operation completes.</p>
  
  <p>It's possible to hide it <strong>permanently</strong> using .navigationBarBackButtonHidden(true). 
  But, then obviously user can't go back in this case, so they are stuck.
  What am I missing?</p>
  
  <p>Here is a contrived example to demonstrate: </p>
  
  <pre><code>struct TimerTest: View {
      @State var isTimerRunning = false
  
      var body: some View {
          Button(action:self.startTimer) {
              Text("Start Timer")
          }
          .navigationBarBackButtonHidden(isTimerRunning)
          //.navigationBarBackButtonHidden(true) // This does hide it, but then it can't be unhidden.
      }
  
      func startTimer()
      {
          self.isTimerRunning = true
  
          _ = Timer.scheduledTimer(withTimeInterval: 5.0, repeats: false) { timer in
              print("Timer fired!")
              self.isTimerRunning = false
          }
      }
  }
  </code></pre>