Skip to content

Commit

Permalink
make stacks public
Browse files Browse the repository at this point in the history
  • Loading branch information
lukepistrol committed Aug 25, 2023
1 parent 2279dae commit d090171
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
17 changes: 11 additions & 6 deletions Sources/MasonryStack/MasonryHStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,25 @@

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 ()
) -> CGSize {
return calculateSize(for: subviews, in: proposal)
}

func placeSubviews(
public func placeSubviews(
in bounds: CGRect,
proposal: ProposedViewSize,
subviews: Subviews,
Expand Down Expand Up @@ -73,7 +78,7 @@ struct MasonryHStack: Layout {
)
}

static var layoutProperties: LayoutProperties {
public static var layoutProperties: LayoutProperties {
var properties = LayoutProperties()
properties.stackOrientation = .horizontal
return properties
Expand Down
17 changes: 11 additions & 6 deletions Sources/MasonryStack/MasonryVStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,25 @@

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 ()
) -> CGSize {
return calculateSize(for: subviews, in: proposal)
}

func placeSubviews(
public func placeSubviews(
in bounds: CGRect,
proposal: ProposedViewSize,
subviews: Subviews,
Expand Down Expand Up @@ -73,7 +78,7 @@ struct MasonryVStack: Layout {
)
}

static var layoutProperties: LayoutProperties {
public static var layoutProperties: LayoutProperties {
var properties = LayoutProperties()
properties.stackOrientation = .vertical
return properties
Expand Down

0 comments on commit d090171

Please sign in to comment.