title: Displaying multiple overlays with SwiftUI
body: <p>I'm trying to show multiple sheets with SwiftUI.</p>
  <p><em><strong>Overlay.swift</strong></em></p>
  <pre><code>import SwiftUI
  
  struct OverlayWith&lt;Content: View&gt;: View {
      let content: () -&gt; Content
      @Environment(\.presentationMode) private var presentationMode
      
      var body: some View {
          VStack{
              Button(action: {
                 self.presentationMode.wrappedValue.dismiss()
              }) {
                  Image(systemName: &quot;chevron.compact.down&quot;)
                      .resizable()
                      .frame(width: 40, height: 15)
                      .accentColor(Color.gray)
                      .padding()
              }
              
              content()
              Spacer()
          }
      }
  }
  
  struct OverlayView_Button1: View {
      var body: some View{
          Text(&quot;Button 1 triggered this overlay&quot;)
      }
  }
  
  struct OverlayView_Button2: View {
      var body: some View{
          Text(&quot;Button 2 triggered this overlay&quot;)
      }
  }
  </code></pre>
  <p><em><strong>ContentView.swift</strong></em></p>
  <pre><code>import SwiftUI
  
  struct ContentView: View {
      @State var overlayVisible: Bool = false
      // Button States
      @State var view1_visible: Bool = false
      @State var view2_visible: Bool = false
      
      var body: some View {
          VStack() {
              Button(action: {
                  self.showSheet1()
              }, label: {
                  Text(&quot;Button 1&quot;)
              })
              Button(action: {
                  self.showSheet2()
              }, label: {
                  Text(&quot;Button 2&quot;)
              })
          }
          .sheet(isPresented: $overlayVisible, content:{
              if self.view1_visible {
                  OverlayWith(content: {
                      OverlayView_Button1()
                  })
              } else if self.view2_visible {
                  OverlayWith(content: {
                      OverlayView_Button2()
                  })
              }
          })
      }
      
      func showSheet1(){
          self.resetButtonStates()
          self.view1_visible = true
          self.overlayVisible = true
      }
      
      func showSheet2(){
          self.resetButtonStates()
          self.view2_visible = true
          self.overlayVisible = true
      }
      
      func resetButtonStates(){
          self.view1_visible = false
          self.view2_visible = false
      }
      
  }
  </code></pre>
  <p>Compiling this code for iOS 13 works as expected. For iOS 14 on the other hand showSheetX() opens a sheet with an empty view. Dismissing the sheet and opening it again shows OverlayView_ButtonX. Debugging shows that viewX_visible is false when showSheetX() was called for the first time.
  Is this a bug with iOS itself or am I missing something here?</p>
  <p>Thank you in advance!</p>