title: Is there a way in SwiftUI to return a different view based on an optional binding having a value?
body: <p>I am trying to show a view after fetching some data on my view model (where the data can be optional because the view model only fetches it on request).</p>
  
  <p>Why is the following not possible / how should I go about it? </p>
  
  <pre><code>@Binding var someViewModel: SomeViewModel?
  
  var body: some View {
      if let viewModel = self.someViewModel {
          return filledView(with: viewModel)
      }
      return emptyView()
  }
  </code></pre>
  
  <p>The part not working here is an <code>if let</code> in the Swift UI view builder. </p>
  
  <p>One solution would be to have a separate Bool that fires when data is loaded, or even an enum to identify when data is in and when it's not, but then the view code is full of optional value checking which isn't ideal.</p>
  
  <p>E.g. I want to avoid doing something like:</p>
  
  <pre><code>Image(systemName: someViewModel?.icon.symbol() ?? "plus_sign")
                      .resizable()
                      .aspectRatio(contentMode: .fit)
                      .frame(width: 60, height: 60)
                      .foregroundColor(Color.red)
                      .padding()
  </code></pre>
  
  <p>Any help would be greatly appreciated.</p>