Skip to content

Commit da05761

Browse files
committed
Add factor to chunk size calculation in Static pill view
1 parent 67f165e commit da05761

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Sources/PillPickerView.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,11 +407,13 @@ struct StaticStack<T, V>: View where T: Pill, V: View {
407407
/// Current total height calculated
408408
@State private var totalHeight = CGFloat.zero
409409

410+
/// The calculateChunkSize function determines the optimal number
411+
/// of items per chunk based on the available width of the view.
410412
private func calculateChunkSize(geometry: GeometryProxy) {
411413
let availableWidth = geometry.size.width
412414
let itemWidth: CGFloat = 100
413415

414-
chunkSize = max(Int(availableWidth / (itemWidth + options.minWidth)), 1)
416+
chunkSize = max(Int(availableWidth / (itemWidth + options.minWidth + options.horizontalSpacing)), 1)
415417
}
416418

417419
// MARK: - Height Calculation

0 commit comments

Comments
 (0)