Skip to content

Commit

Permalink
expose centerHorizontall and centerVertically
Browse files Browse the repository at this point in the history
  • Loading branch information
lkzhao committed Jan 29, 2023
1 parent 7e1d6ad commit 261db23
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
13 changes: 12 additions & 1 deletion Sources/UIComponent/Components/Layout/Flex/FlexLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,25 @@ extension FlexLayout {
children: content()
)
}

public init(
spacing: CGFloat = 0,
justifyContent: MainAxisAlignment = .start,
alignItems: CrossAxisAlignment = .start,
alignContent: MainAxisAlignment = .start,
children: [Component]
) {
self.init(lineSpacing: spacing, interitemSpacing: spacing, justifyContent: justifyContent, alignItems: alignItems, alignContent: alignContent, children: children)
}

public init(
spacing: CGFloat = 0,
justifyContent: MainAxisAlignment = .start,
alignItems: CrossAxisAlignment = .start,
alignContent: MainAxisAlignment = .start,
@ComponentArrayBuilder _ content: () -> [Component]
) {
self.init(lineSpacing: spacing, interitemSpacing: spacing, justifyContent: justifyContent, alignItems: alignItems, alignContent: alignContent, children: content())
self.init(spacing: spacing, justifyContent: justifyContent, alignItems: alignItems, alignContent: alignContent, children: content())
}
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/UIComponent/Core/ComponentView/ComponentEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public class ComponentEngine {
}

/// contentView layout configurations
var centerContentViewVertically = false
var centerContentViewHorizontally = true
public var centerContentViewVertically = false
public var centerContentViewHorizontally = true

/// internal helpers for updating the component view
var contentSize: CGSize = .zero {
Expand Down

0 comments on commit 261db23

Please sign in to comment.