Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
SwiftLint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: GitHub Action for SwiftLint
uses: norio-nomura/action-swiftlint@3.2.1
with:
Expand All @@ -43,7 +43,7 @@ jobs:
xcode: "Xcode_16.0"
runsOn: macOS-14
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: ${{ matrix.name }}
run: xcodebuild test -scheme "flex-ui" -destination "${{ matrix.destination }}" clean -enableCodeCoverage YES -resultBundlePath "test_output/${{ matrix.name }}.xcresult" || exit 1
- uses: actions/upload-artifact@v4
Expand All @@ -57,7 +57,7 @@ jobs:
env:
DEVELOPER_DIR: /Applications/Xcode_14.1.app/Contents/Developer
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Discover typos
run: |
export PATH="$PATH:/Library/Frameworks/Python.framework/Versions/3.11/bin"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/danger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
ruby-version: 3.1.4
bundler-cache: true
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Setup gems
run: |
gem install bundler
Expand Down
82 changes: 82 additions & 0 deletions Sources/FlexUI/Classes/Extensions/FlexUI+StackView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//
// flex-ui
// Copyright © 2024 Space Code. All rights reserved.
//

import UIKit

/// An extension to `FlexUI` that adds helper methods for configuring `UIStackView` properties.
/// These methods enable easy configuration of common `UIStackView` properties using a fluent interface.
extension FlexUI where Component: UIStackView {
/// Sets the axis along which the arranged views in the stack are laid out.
///
/// - Parameter axis: The axis for layout (either `.horizontal` or `.vertical`).
/// - Returns: The current instance of `FlexUI` for further configuration.
@discardableResult
@MainActor
func axis(_ axis: NSLayoutConstraint.Axis) -> Self {
component.axis = axis
return self
}

/// Sets the distribution method for the arranged views in the stack.
///
/// - Parameter distribution: The distribution method (e.g., `.fill`, `.equalSpacing`, etc.).
///
/// - Returns: The current instance of `FlexUI` for further configuration.
@discardableResult
@MainActor
func distribution(_ distribution: UIStackView.Distribution) -> Self {
component.distribution = distribution
return self
}

/// Sets the spacing between the arranged views in the stack.
///
/// - Parameter space: The spacing value (in points) between the arranged views.
///
/// - Returns: The current instance of `FlexUI` for further configuration.
@discardableResult
@MainActor
func spacing(_ space: CGFloat) -> Self {
component.spacing = space
return self
}

/// Sets the alignment of the arranged views along the stack's axis.
///
/// - Parameter alignment: The alignment option (e.g., `.fill`, `.leading`, `.center`, etc.).
///
/// - Returns: The current instance of `FlexUI` for further configuration.
@discardableResult
@MainActor
func alignment(_ alignment: UIStackView.Alignment) -> Self {
component.alignment = alignment
return self
}

/// Adds an array of subviews to the stack view's arranged subviews.
///
/// - Parameter subviews: The array of `UIView` instances to be added to the stack view.
///
/// - Returns: The current instance of `FlexUI` for further configuration.
@discardableResult
@MainActor
func addArrangeSubviews(_ subviews: [UIView]) -> Self {
subviews.forEach { component.addArrangedSubview($0) }
return self
}

/// Sets the layout margins for the stack view and enables layout margins relative arrangement.
///
/// - Parameter value: The directional layout margins (insets) to apply to the stack view.
///
/// - Returns: The current instance of `FlexUI` for further configuration.
@discardableResult
@MainActor
func layoutMargins(_ value: NSDirectionalEdgeInsets) -> Self {
component.isLayoutMarginsRelativeArrangement = true
component.directionalLayoutMargins = value
return self
}
}