@@ -136,7 +136,7 @@ public struct OBCollectionView<Content: View, DataType>: View {
136
136
gridItem: gridItem
137
137
)
138
138
modifyCellSizePreferenceForVGridItem (
139
- view: spacerView ,
139
+ view: alignedSpacer ,
140
140
contentIndex: 0
141
141
)
142
142
. frame (
@@ -178,7 +178,7 @@ public struct OBCollectionView<Content: View, DataType>: View {
178
178
gridItem: gridItem
179
179
)
180
180
modifyCellSizePreferenceForHGridItem (
181
- view: spacerView ,
181
+ view: alignedSpacer ,
182
182
contentIndex: 0
183
183
)
184
184
. frame (
@@ -224,7 +224,8 @@ public struct OBCollectionView<Content: View, DataType>: View {
224
224
}
225
225
)
226
226
. onPreferenceChange ( SizePreferenceKey . self) { value in
227
- nonLazyOrthogonalSizes [ contentIndex] = value
227
+ let current = nonLazyOrthogonalSizes [ contentIndex]
228
+ nonLazyOrthogonalSizes [ contentIndex] = max ( current, value)
228
229
}
229
230
}
230
231
@@ -243,7 +244,8 @@ public struct OBCollectionView<Content: View, DataType>: View {
243
244
}
244
245
)
245
246
. onPreferenceChange ( SizePreferenceKey . self) { value in
246
- nonLazyOrthogonalSizes [ contentIndex] = value
247
+ let current = nonLazyOrthogonalSizes [ contentIndex]
248
+ nonLazyOrthogonalSizes [ contentIndex] = max ( current, value)
247
249
}
248
250
}
249
251
}
@@ -294,11 +296,12 @@ public struct OBCollectionView<Content: View, DataType>: View {
294
296
gridItems: [ . init( ) , . init( ) , . init( ) ] ,
295
297
gridSpacing: 8
296
298
) { item, index, scrollProxy in
297
- let text : String = index == 0
298
- ? " hello world "
299
+ let text : String = index == 1
300
+ ? " hello world hello world hello world hello world "
299
301
: " hello "
300
302
301
303
Text ( text)
304
+ . fixedSize ( horizontal: false , vertical: true )
302
305
. background ( Color . red)
303
306
}
304
307
. background ( Color . yellow)
@@ -324,14 +327,11 @@ public struct OBCollectionView<Content: View, DataType>: View {
324
327
325
328
#Preview( " Vertical non-lazy less item " ) {
326
329
OBCollectionView (
327
- data: Array ( 1 ... 100 )
330
+ data: Array ( 1 ... 2 ) ,
331
+ gridItems: Array ( repeating: . init( ) , count: 3 )
328
332
) { data, index, scrollProxy in
329
- Text ( " \( data) " )
330
- . id ( data)
331
- . onTapGesture {
332
- withAnimation {
333
- scrollProxy? . scrollTo ( 1 )
334
- }
335
- }
333
+ Text ( " Lorem ipsum dolor sit amet. " )
334
+ . background ( Color . red)
335
+ . fixedSize ( horizontal: false , vertical: true )
336
336
}
337
337
}
0 commit comments