Skip to content

Commit

Permalink
Rename pin method on Layout to constrain (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
tinder-cfuller authored Oct 13, 2023
1 parent dd6c889 commit 466b322
Show file tree
Hide file tree
Showing 32 changed files with 18 additions and 21 deletions.
12 changes: 6 additions & 6 deletions Sources/Layout/Layout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ public final class Layout { // swiftlint:disable:this type_body_length
/// - view2: subview to constrain
/// - insets: (optional) insets of `view1`
@discardableResult
public func pin(
public func constrain(
_ view1: UIView,
to view2: UIView,
insets: NSDirectionalEdgeInsets
Expand All @@ -330,7 +330,7 @@ public final class Layout { // swiftlint:disable:this type_body_length
/// - view2: subview to constrain
/// - insets: (optional) insets of `view1`
@discardableResult
public func pin(
public func constrain(
_ view1: UIView,
to view2: UIView,
insets: UIEdgeInsets = .zero
Expand All @@ -349,14 +349,14 @@ public final class Layout { // swiftlint:disable:this type_body_length
/// - view2: subview to constrain
/// - inset: inset of `view1`
@discardableResult
public func pin(
public func constrain(
_ view1: UIView,
to view2: UIView,
inset: CGFloat
) -> Layout {
pin(view1,
to: view2,
insets: UIEdgeInsets(top: inset, left: inset, bottom: inset, right: inset))
constrain(view1,
to: view2,
insets: UIEdgeInsets(top: inset, left: inset, bottom: inset, right: inset))
}

/// Constrains the corresponding `attribute` of the `views` to each other
Expand Down
27 changes: 12 additions & 15 deletions Tests/LayoutTests/LayoutTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ final class LayoutTests: XCTestCase {
}
}

func testPin_andWithDirectionalInsets() {
func testConstrain_andWithDirectionalInsets() {

// GIVEN

Expand All @@ -602,19 +602,19 @@ final class LayoutTests: XCTestCase {

// Pin to View

layout.pin(pinkView, to: view)
layout.constrain(pinkView, to: view)

// Pin to View with EdgeInsets

layout.pin(yellowView,
to: view,
insets: NSDirectionalEdgeInsets(top: 40, leading: 40, bottom: 40, trailing: 40))
layout.constrain(yellowView,
to: view,
insets: NSDirectionalEdgeInsets(top: 40, leading: 40, bottom: 40, trailing: 40))

return layout
}
}

func testPin_andWithInsets() {
func testConstrain_andWithInsets() {

// GIVEN

Expand All @@ -632,19 +632,19 @@ final class LayoutTests: XCTestCase {

// Pin to View

layout.pin(pinkView, to: view)
layout.constrain(pinkView, to: view)

// Pin to View with EdgeInsets

layout.pin(yellowView,
to: view,
insets: UIEdgeInsets(top: 40, left: 40, bottom: 40, right: 40))
layout.constrain(yellowView,
to: view,
insets: UIEdgeInsets(top: 40, left: 40, bottom: 40, right: 40))

return layout
}
}

func testPinWithInset() {
func testConstrainWithInset() {

// GIVEN

Expand All @@ -653,10 +653,7 @@ final class LayoutTests: XCTestCase {
// THEN

assertLayout { view in
view.layout {
pinkView
}
.pin(pinkView, to: view, inset: 20)
view.layout(pinkView).constrain(pinkView, to: view, inset: 20)
}
}

Expand Down

0 comments on commit 466b322

Please sign in to comment.