Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  Simplify padding and align function

# Conflicts:
#	Example/FrameLayoutKit.xcworkspace/xcuserdata/namkennic.xcuserdatad/UserInterfaceState.xcuserstate
  • Loading branch information
kennic committed Sep 27, 2023
2 parents 9a1ec47 + 3715d11 commit 3a9b5da
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Example/FrameLayoutKit/CardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CardView: UIView {
let expandButton = UIButton()
let frameLayout = HStackLayout {
$0.spacing = 15.0
$0.padding(top: 15, left: 15, bottom: 15, right: 15)
$0.padding(15)
}
let blueView = UIView()
let redView = UIView()
Expand Down
2 changes: 1 addition & 1 deletion FrameLayoutKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'FrameLayoutKit'
s.version = '7.0.0'
s.version = '7.0.1'
s.summary = 'FrameLayoutKit is a super fast and easy to use layout kit'
s.description = <<-DESC
FrameLayoutKit is a powerful Swift library designed to streamline the process of creating user interfaces. With its intuitive operator syntax and support for nested functions, developers can effortlessly construct complex UI layouts with minimal code. By leveraging the flexibility of operators, developers can easily position and arrange views within a container view, enabling precise control over the visual hierarchy. Additionally, the library offers a range of convenient functions for configuring view properties, such as setting dimensions, margins, and alignment. Whether you're building a simple screen or a complex interface, FrameLayoutKit simplifies the UI creation process, resulting in cleaner, more maintainable code.
Expand Down
31 changes: 31 additions & 0 deletions FrameLayoutKit/Classes/Extensions/FrameLayout+Chainable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,42 @@ frameLayout

extension FrameLayout {

@discardableResult public func flexible(ratio: CGFloat = -1) -> Self {
isFlexible = true
flexibleRatio = ratio
return self
}

@discardableResult public func inflexible() -> Self {
isFlexible = false
return self
}

@discardableResult public func padding(top: CGFloat = 0, left: CGFloat = 0, bottom: CGFloat = 0, right: CGFloat = 0) -> Self {
edgeInsets = UIEdgeInsets(top: top, left: left, bottom: bottom, right: right)
return self
}

@discardableResult public func padding(_ value: CGFloat) -> Self {
edgeInsets = UIEdgeInsets(top: value, left: value, bottom: value, right: value)
return self
}

@discardableResult public func addPadding(top: CGFloat = 0, left: CGFloat = 0, bottom: CGFloat = 0, right: CGFloat = 0) -> Self {
edgeInsets = UIEdgeInsets(top: edgeInsets.top + top, left: edgeInsets.left + left, bottom: edgeInsets.bottom + bottom, right: edgeInsets.right + right)
return self
}

@discardableResult public func align(vertical: NKContentVerticalAlignment? = nil, horizontal: NKContentHorizontalAlignment? = nil) -> Self {
alignment = (vertical ?? alignment.vertical, horizontal ?? alignment.horizontal)
return self
}

@discardableResult public func aligns(_ vertical: NKContentVerticalAlignment, _ horizontal: NKContentHorizontalAlignment) -> Self {
alignment = (vertical, horizontal)
return self
}

@discardableResult public func extends(size: CGSize) -> Self {
extendSize = size
return self
Expand Down
29 changes: 1 addition & 28 deletions FrameLayoutKit/Classes/FrameLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -320,34 +320,7 @@ open class FrameLayout: UIView {
public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}

// MARK: -

@discardableResult
open func flexible(ratio: CGFloat = -1) -> Self {
isFlexible = true
flexibleRatio = ratio
return self
}

@discardableResult
open func inflexible() -> Self {
isFlexible = false
return self
}

@discardableResult
open func padding(top: CGFloat = 0, left: CGFloat = 0, bottom: CGFloat = 0, right: CGFloat = 0) -> Self {
edgeInsets = UIEdgeInsets(top: top, left: left, bottom: bottom, right: right)
return self
}

@discardableResult
open func addPadding(top: CGFloat = 0, left: CGFloat = 0, bottom: CGFloat = 0, right: CGFloat = 0) -> Self {
edgeInsets = UIEdgeInsets(top: edgeInsets.top + top, left: edgeInsets.left + left, bottom: edgeInsets.bottom + bottom, right: edgeInsets.right + right)
return self
}


#if DEBUG
override open func draw(_ rect: CGRect) {
guard debug, !isEmpty, bounds != .zero else {
Expand Down

0 comments on commit 3a9b5da

Please sign in to comment.