title: Content hugging priority behaviour in SwiftUI
body: <p>I have a <strong>List</strong> made of cells, each containing an image, and a column of text, which I wish laid out in a specific way. Image on the left, taking up a quarter of the width. The rest of the space given to the text, which is left-aligned.</p>
  <p>Here's the code I got:</p>
  <pre class="lang-swift prettyprint-override"><code>struct TestCell: View {
      let model: ModelStruct
  
      var body: some View {
          HStack {
              Image(&quot;flag&quot;)
                  .resizable()
                  .aspectRatio(contentMode: .fit)
                  .frame(width: UIScreen.main.bounds.size.width * 0.25)
              VStack(alignment: .leading, spacing: 5) {
                  Text(&quot;Country: Moldova&quot;)
                  Text(&quot;Capital: Chișinău&quot;)
                  Text(&quot;Currency: Leu&quot;)
              }
              .frame(minWidth: 0, maxWidth: .infinity, alignment: .leading)
          }
      }
  }
  
  struct TestCell_Previews: PreviewProvider {
      static var previews: some View {
          TestCell()
              .previewLayout(.sizeThatFits)
              .previewDevice(&quot;iPhone 11&quot;)
      }
  }
  </code></pre>
  <p>And here are 2 examples:</p>
  <img src="https://i.stack.imgur.com/FX8Jb.png" width="300">
  <img src="https://i.stack.imgur.com/1ZiBk.png" width="300">
  <p>As you can see, the height of the whole cell varies based on the aspect ratio of the image.</p>
  <p><strong>$1M question - How can we make the cell height hug the text (like in the second image) and not vary, but rather shrink the image in a <em>scaleAspectFit</em> manner inside the allocated rectangle</strong></p>
  <p>Note!</p>
  <ol>
  <li>The text's height can vary, so no hardcoding.</li>
  <li>Couldn't make it work with <code>PreferenceKey</code>s, as the cells will be part of a List, and there's some peculiar behaviour I'm trying to grasp around cell reusage, and <code>onPreferenceChange</code> not being called when 2 consecutive cells have the same height. To exhibit all this combined behaviour, make sure your model varies between cells when you test it.</li>
  </ol>