title: How do you create a SwiftUI view that takes an optional secondary View argument?
body: <p>I am trying to create a custom SwiftUI view that acts like the default views where I can add extra content to a view with a method or optional initializer argument.</p>
  
  <pre class="lang-swift prettyprint-override"><code>SomeCustomView(title: "string argument") {
      // some view
  }
  
  SomeCustomView(title: "hello") {
      // some view
  }.sideContent {
      // another view
  }
  
  // This style is acceptable too
  SomeCustomView(title: "hello", sideContent: { /* another view */ }) {
      // some view
  }
  </code></pre>
  
  <p>How can I modify this view struct to behave like the above example?</p>
  
  <pre class="lang-swift prettyprint-override"><code>struct SomeCustomView&lt;Content&gt;: View where Content: View {
      let title: String
      let content: Content
  
      init(title: String, @ViewBuilder content: () -&gt; Content) {
          self.title = title
          self.content = content()
      }
  
      var body: some View {
          VStack {
              Text(title)
              content
          }
      }
  }
  </code></pre>
  
  <p>Ideally I'd have two different body "templates" that I could switch between depending on if the <code>sideContent</code> method was called or <code>sideContent</code> parameter was set. For example,</p>
  
  <pre class="lang-swift prettyprint-override"><code>var body: some View {
      VStack {
          Text(title)
          content
      }
  }
  
  // or
  
  var otherBody: some View {
      HStack {
          VStack {
              Text(title)
              content
          }
          sideContent
      }
  }
  </code></pre>