Skip to content
This repository has been archived by the owner on Dec 27, 2020. It is now read-only.

Commit

Permalink
track preconditions (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
ay42 authored Apr 5, 2020
1 parent af04752 commit c300abc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Sources/Grid/Styles/Layout/LayoutMath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func tracksCount(tracks: Tracks, spacing: CGFloat, availableLength: CGFloat) ->
case .count(let count):
return count
case .fixed(let length):
precondition(length > 0, "Minimum track length should be greated than 0")
let columnCount = Int(availableLength / length)

for columns in (0...columnCount).reversed() {
Expand All @@ -26,8 +27,9 @@ func tracksCount(tracks: Tracks, spacing: CGFloat, availableLength: CGFloat) ->
}
}
return 1
case .min(let minWidth):
let columnCount = Int(availableLength / minWidth)
case .min(let length):
precondition(length > 0, "Minimum track length should be greated than 0")
let columnCount = Int(availableLength / length)

for columns in (0...columnCount).reversed() {
let suggestedItemWidth = itemLength(tracksCount: columns, spacing: spacing, availableLength: availableLength)
Expand Down

0 comments on commit c300abc

Please sign in to comment.