title: SwiftUI: close modal
body: <p>I know this question has been asked and answered before. Not sure if this changed/broke in Beta 4 for SwiftUI, but I can't seem to get the <code>isPresented</code> solution to work to dismiss a modal shown with <code>sheet</code>.</p>
  
  <p>Here is a simple example of what I tried, I thought this would work, but clicking "Close" does nothing and when I inspect <code>self.isPresented?.value</code> it's <code>nil</code>.</p>
  
  <pre><code>struct DetailView: View {
      @Environment(\.isPresented) var isPresented: Binding&lt;Bool&gt;?
      var body: some View {
          Button(action: {
              self.isPresented?.value = false
          }) {
              Text("Close")
          }
      }
  }
  
  struct ContentView: View {
      @State private var showingModal = false
      var body: some View {
          Button(action: {
              self.showingModal = true
          }) {
              Text("Show detail")
          }.sheet(isPresented: $showingModal) {
              DetailView()
          }
      }
  }
  </code></pre>
  
  <p>Update based on suggestion, this works. Seems like too much book keeping to me, hope this gets updated.</p>
  
  <pre><code>struct DetailView: View {
      @Binding var showingModal: Bool
      var body: some View {
          Button(action: {
              self.showingModal = false
          }) {
              Text("Close")
          }
      }
  }
  
  struct ContentView: View {
      @State private var showingModal = false
      var body: some View {
          Button(action: {
              self.showingModal = true
          }) {
              Text("Show detail")
          }.sheet(isPresented: $showingModal) {
              DetailView(showingModal: self.$showingModal)
          }
      }
  }
  </code></pre>