@@ -80,20 +80,18 @@ struct CardLayout: Layout {
8080 func sizeThatFits( proposal: ProposedViewSize , subviews: Subviews , cache: inout CacheData ) -> CGSize {
8181 self . calculateLayout ( proposal: proposal, subviews: subviews, cache: & cache)
8282 let finalWidth = max ( proposal. width ?? 0 , cache. maxWidth)
83-
8483 return CGSize ( width: finalWidth, height: cache. height)
8584 }
8685
8786 func placeSubviews( in bounds: CGRect , proposal: ProposedViewSize , subviews: Subviews , cache: inout CacheData ) {
8887 self . calculateLayout ( proposal: proposal, subviews: subviews, cache: & cache)
89-
9088 for (i, subview) in subviews. enumerated ( ) {
9189 let item = cache. rows [ i]
9290
9391 var pt = CGPoint ( x: item. origin. x + bounds. origin. x, y: item. origin. y + bounds. origin. y)
9492 /// If it is the footer and there is exessive height for the card then the footer is moved to the bottom
95- if self . useProposedHeight , subview. priority == 3 , item. origin. y + item. size. height < cache . height {
96- pt. y = cache . height - item. size. height + bounds. origin. y
93+ if subview. priority == 3 , item. origin. y + item. size. height < bounds . size . height {
94+ pt. y = bounds . size . height - item. size. height + bounds. origin. y
9795 }
9896 subview. place ( at: pt, proposal: ProposedViewSize ( width: item. size. width, height: nil ) )
9997 }
@@ -105,11 +103,9 @@ struct CardLayout: Layout {
105103
106104 func calculateLayout( proposal: ProposedViewSize , subviews: Subviews , cache: inout CacheData ) {
107105 let containerWidth = proposal. width
108-
109106 let height : CGFloat
110-
111- if self . useProposedHeight {
112- height = proposal. height ?? ( cache. rows. last? . maxY ?? 0 )
107+ if self . useProposedHeight, let value = proposal. height, value > 0 , value < CGFloat . greatestFiniteMagnitude {
108+ height = max ( value, cache. height)
113109 } else {
114110 height = cache. rows. last? . maxY ?? 0
115111 }
@@ -141,8 +137,8 @@ struct CardLayout: Layout {
141137 }
142138
143139 cache. height = cache. rows. last? . maxY ?? 0
144- if self . useProposedHeight, let value = proposal. height {
145- cache. height = value
140+ if self . useProposedHeight, let value = proposal. height, value > 0 , value < CGFloat . greatestFiniteMagnitude {
141+ cache. height = max ( value, cache . height )
146142 }
147143 }
148144}
@@ -584,7 +580,9 @@ public enum CardTests {
584580 }
585581 } cardBody: {
586582 HStack ( alignment: . center, spacing: 4 ) {
587- ChartView ( CardTests . chartModel) . frame ( height: 168 )
583+ ChartView ( CardTests . chartModel)
584+ . frame ( minWidth: 128 )
585+ . frame ( height: 168 )
588586
589587 VStack ( alignment: . leading, spacing: 8 ) {
590588 HStack {
0 commit comments