diff --git a/Sources/MasonryStack/MasonryHStack.swift b/Sources/MasonryStack/MasonryHStack.swift index 1d13fbd..64d0051 100644 --- a/Sources/MasonryStack/MasonryHStack.swift +++ b/Sources/MasonryStack/MasonryHStack.swift @@ -7,12 +7,17 @@ import SwiftUI -struct MasonryHStack: Layout { +public struct MasonryHStack: Layout { - var rows: Int = 2 - var spacing: Double = 8 + private var rows: Int + private var spacing: Double - func sizeThatFits( + init(rows: Int = 2, spacing: Double = 8.0) { + self.rows = rows + self.spacing = spacing + } + + public func sizeThatFits( proposal: ProposedViewSize, subviews: Subviews, cache: inout () @@ -20,7 +25,7 @@ struct MasonryHStack: Layout { return calculateSize(for: subviews, in: proposal) } - func placeSubviews( + public func placeSubviews( in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, @@ -73,7 +78,7 @@ struct MasonryHStack: Layout { ) } - static var layoutProperties: LayoutProperties { + public static var layoutProperties: LayoutProperties { var properties = LayoutProperties() properties.stackOrientation = .horizontal return properties diff --git a/Sources/MasonryStack/MasonryVStack.swift b/Sources/MasonryStack/MasonryVStack.swift index 87e92f7..148e5a4 100644 --- a/Sources/MasonryStack/MasonryVStack.swift +++ b/Sources/MasonryStack/MasonryVStack.swift @@ -7,12 +7,17 @@ import SwiftUI -struct MasonryVStack: Layout { +public struct MasonryVStack: Layout { - var columns: Int = 2 - var spacing: Double = 8 + private var columns: Int + private var spacing: Double - func sizeThatFits( + public init(columns: Int = 2, spacing: Double = 8.0) { + self.columns = columns + self.spacing = spacing + } + + public func sizeThatFits( proposal: ProposedViewSize, subviews: Subviews, cache: inout () @@ -20,7 +25,7 @@ struct MasonryVStack: Layout { return calculateSize(for: subviews, in: proposal) } - func placeSubviews( + public func placeSubviews( in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, @@ -73,7 +78,7 @@ struct MasonryVStack: Layout { ) } - static var layoutProperties: LayoutProperties { + public static var layoutProperties: LayoutProperties { var properties = LayoutProperties() properties.stackOrientation = .vertical return properties