Skip to content

Commit

Permalink
CoreGraphics dependency removed
Browse files Browse the repository at this point in the history
  • Loading branch information
diniska committed Dec 8, 2022
1 parent 3c2e74b commit 78a0769
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
11 changes: 5 additions & 6 deletions Sources/WrappingStack/Helpers/Lines.swift
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import Foundation
import CoreGraphics

struct Lines<S: RandomAccessCollection> {
struct Lines<S: RandomAccessCollection, Weight: AdditiveArithmetic & Comparable> {
typealias Element = S.Element
typealias Index = S.Index

var elements: S
var spacing: CGFloat
var length: (Element) -> CGFloat
var spacing: Weight
var length: (Element) -> Weight

func split(lengthLimit: CGFloat) -> [Range<Index>] {
var currentLength: CGFloat = 0
func split(lengthLimit: Weight) -> [Range<Index>] {
var currentLength: Weight = .zero
var numberOfElementsInCurrentLine = 0
var result: [Range<Index>] = []
var lineStart = elements.startIndex
Expand Down
4 changes: 2 additions & 2 deletions Tests/WrappingStackTests/LinesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ final class LinesTests: XCTestCase {
}
}

private extension Lines where Element == CGFloat {
init(elements: S, spacing: CGFloat = 0) {
private extension Lines where Element == Weight {
init(elements: S, spacing: Weight = .zero) {
self.init(elements: elements, spacing: spacing, length: { $0 })
}
}

0 comments on commit 78a0769

Please sign in to comment.