title: passing a view to a custom swiftui container view
body: <p>I'm creating a custom container view in swiftui - and I want it to scale the views you put into it - but it doesn't seem to work as I'm expecting, just wondering what I'm doing wrong.</p>
  <p>The code:</p>
  <pre class="lang-swift prettyprint-override"><code>struct SplitView&lt;Left:View, Right:View&gt;: View
  {
      
      @State var left : () -&gt; Left
      @State var right : () -&gt; Right
      @State var splitterWidth = 10
      @State var splitterLocation = 120
      
      var body: some View
      {
          GeometryReader()
          {
              geometry in
              HStack( spacing:0)
              {
                  left().frame( width:CGFloat(splitterLocation), height: geometry.size.height)
                  Text(&quot; &quot;).frame( width : CGFloat( splitterWidth), height : CGFloat( geometry.size.height))
                      .background(Color.yellow)
                  right().frame(width: geometry.size.width - CGFloat( self.splitterWidth + self.splitterLocation), height: geometry.size.height)
                      .background(Color.red)
              }
          }
      }
  }
  
  struct SplitView_Previews: PreviewProvider
  {
      static var previews: some View
      {
          SplitView( left: {Text(&quot;green&quot;).background(Color.green)},
                     right: {Text(&quot;red&quot;)})
                    .frame(width:300, height:300)
      }
  }
  
  </code></pre>
  <p>which produces:</p>
  <p><a href="https://i.stack.imgur.com/iSyZO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iSyZO.png" alt="enter image description here" /></a></p>
  <p>I want it to scale the internal views correctly to the space allotted to them (and resize them as you drag the splitter) - but the problem is demonstrated by the background colours - the green is clearly not what is desired.   How do I a pass a view in such that I'll get the desired result (ie whatever I pass in is resized to fill the container)</p>