File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -134,10 +134,15 @@ struct FlowLayout {
134
134
var lines : Lines = [ ]
135
135
let proposedBreadth = proposedSize. replacingUnspecifiedDimensions ( ) . value ( on: axis)
136
136
for (index, subview) in subviews. enumerated ( ) {
137
- let min = subview. dimensions ( . zero) . size ( on: axis)
138
- let ideal = subview. dimensions ( . unspecified) . size ( on: axis)
139
- let max = subview. dimensions ( . infinity) . size ( on: axis)
140
- let size = min. breadth == 0 ? ideal. breadth == 0 ? max : ideal : min
137
+ var size = subview. sizeThatFits ( proposedSize) . size ( on: axis)
138
+ if case . stretchItems = justification {
139
+ let ideal = subview. dimensions ( . unspecified) . size ( on: axis) . breadth
140
+ let max = subview. dimensions ( . infinity) . size ( on: axis) . breadth
141
+ let isFlexible = max - ideal > 0
142
+ if isFlexible {
143
+ size. breadth = ideal
144
+ }
145
+ }
141
146
if let lastIndex = lines. indices. last {
142
147
let spacing = self . itemSpacing ( toPrevious: index, subviews: subviews)
143
148
let additionalBreadth = spacing + size. breadth
You can’t perform that action at this time.
0 commit comments