Skip to content

Commit

Permalink
Merge pull request #6 from scottostler/main
Browse files Browse the repository at this point in the history
InternalWrappingHStack: store firstItemOfEachLane result
  • Loading branch information
dkk committed Jul 28, 2021
2 parents 78bb1e2 + 4c74430 commit 8ad45ec
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Sources/WrappingHStack/InternalWrappingHStack.swift
Expand Up @@ -6,9 +6,15 @@ struct InternalWrappingHStack: View {
let alignment: HorizontalAlignment
let spacing: WrappingHStack.Spacing
let content: [WrappingHStack.ViewType]

var firstItemOfEachLane: [Int] {
return content
let firstItemOfEachLane: [Int]

init(width: CGFloat, alignment: HorizontalAlignment, spacing: WrappingHStack.Spacing, content: [WrappingHStack.ViewType]) {
self.width = width
self.alignment = alignment
self.spacing = spacing
self.content = content

firstItemOfEachLane = content
.enumerated()
.reduce((firstItems: [], currentLineWidth: width)) { (result, contentIterator) -> (firstItemOfEachLane: [Int], currentLineWidth: CGFloat) in
var (firstItemOfEachLane, currentLineWidth) = result
Expand Down

0 comments on commit 8ad45ec

Please sign in to comment.