diff --git a/Sources/Layout/Layout.swift b/Sources/Layout/Layout.swift index e73ff051..4739eace 100644 --- a/Sources/Layout/Layout.swift +++ b/Sources/Layout/Layout.swift @@ -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 @@ -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 @@ -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 diff --git a/Tests/LayoutTests/LayoutTests.swift b/Tests/LayoutTests/LayoutTests.swift index 46d72169..b4d3d428 100644 --- a/Tests/LayoutTests/LayoutTests.swift +++ b/Tests/LayoutTests/LayoutTests.swift @@ -584,7 +584,7 @@ final class LayoutTests: XCTestCase { } } - func testPin_andWithDirectionalInsets() { + func testConstrain_andWithDirectionalInsets() { // GIVEN @@ -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 @@ -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 @@ -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) } } diff --git a/Tests/LayoutTests/__Snapshots__/LayoutTests/testPinWithInset.iPhone-13-mini-portrait.png b/Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrainWithInset.iPhone-13-mini-portrait.png similarity index 100% rename from Tests/LayoutTests/__Snapshots__/LayoutTests/testPinWithInset.iPhone-13-mini-portrait.png rename to Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrainWithInset.iPhone-13-mini-portrait.png diff --git a/Tests/LayoutTests/__Snapshots__/LayoutTests/testPinWithInset.iPhone-13-mini-portrait.txt b/Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrainWithInset.iPhone-13-mini-portrait.txt similarity index 100% rename from Tests/LayoutTests/__Snapshots__/LayoutTests/testPinWithInset.iPhone-13-mini-portrait.txt rename to Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrainWithInset.iPhone-13-mini-portrait.txt diff --git a/Tests/LayoutTests/__Snapshots__/LayoutTests/testPinWithInset.iPhone-13-portrait.png b/Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrainWithInset.iPhone-13-portrait.png similarity index 100% rename from Tests/LayoutTests/__Snapshots__/LayoutTests/testPinWithInset.iPhone-13-portrait.png rename to Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrainWithInset.iPhone-13-portrait.png diff --git a/Tests/LayoutTests/__Snapshots__/LayoutTests/testPinWithInset.iPhone-13-portrait.txt b/Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrainWithInset.iPhone-13-portrait.txt similarity index 100% rename from Tests/LayoutTests/__Snapshots__/LayoutTests/testPinWithInset.iPhone-13-portrait.txt rename to Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrainWithInset.iPhone-13-portrait.txt diff --git a/Tests/LayoutTests/__Snapshots__/LayoutTests/testPinWithInset.iPhone-8-portrait.png b/Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrainWithInset.iPhone-8-portrait.png similarity index 100% rename from Tests/LayoutTests/__Snapshots__/LayoutTests/testPinWithInset.iPhone-8-portrait.png rename to Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrainWithInset.iPhone-8-portrait.png diff --git a/Tests/LayoutTests/__Snapshots__/LayoutTests/testPinWithInset.iPhone-8-portrait.txt b/Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrainWithInset.iPhone-8-portrait.txt similarity index 100% rename from Tests/LayoutTests/__Snapshots__/LayoutTests/testPinWithInset.iPhone-8-portrait.txt rename to Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrainWithInset.iPhone-8-portrait.txt diff --git a/Tests/LayoutTests/__Snapshots__/LayoutTests/testPinWithInset.iPhone-SE-portrait.png b/Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrainWithInset.iPhone-SE-portrait.png similarity index 100% rename from Tests/LayoutTests/__Snapshots__/LayoutTests/testPinWithInset.iPhone-SE-portrait.png rename to Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrainWithInset.iPhone-SE-portrait.png diff --git a/Tests/LayoutTests/__Snapshots__/LayoutTests/testPinWithInset.iPhone-SE-portrait.txt b/Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrainWithInset.iPhone-SE-portrait.txt similarity index 100% rename from Tests/LayoutTests/__Snapshots__/LayoutTests/testPinWithInset.iPhone-SE-portrait.txt rename to Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrainWithInset.iPhone-SE-portrait.txt diff --git a/Tests/LayoutTests/__Snapshots__/LayoutTests/testPinWithInset.iPhone-X-portrait.png b/Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrainWithInset.iPhone-X-portrait.png similarity index 100% rename from Tests/LayoutTests/__Snapshots__/LayoutTests/testPinWithInset.iPhone-X-portrait.png rename to Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrainWithInset.iPhone-X-portrait.png diff --git a/Tests/LayoutTests/__Snapshots__/LayoutTests/testPinWithInset.iPhone-X-portrait.txt b/Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrainWithInset.iPhone-X-portrait.txt similarity index 100% rename from Tests/LayoutTests/__Snapshots__/LayoutTests/testPinWithInset.iPhone-X-portrait.txt rename to Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrainWithInset.iPhone-X-portrait.txt diff --git a/Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithDirectionalInsets.iPhone-13-mini-portrait.png b/Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithDirectionalInsets.iPhone-13-mini-portrait.png similarity index 100% rename from Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithDirectionalInsets.iPhone-13-mini-portrait.png rename to Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithDirectionalInsets.iPhone-13-mini-portrait.png diff --git a/Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithDirectionalInsets.iPhone-13-mini-portrait.txt b/Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithDirectionalInsets.iPhone-13-mini-portrait.txt similarity index 100% rename from Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithDirectionalInsets.iPhone-13-mini-portrait.txt rename to Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithDirectionalInsets.iPhone-13-mini-portrait.txt diff --git a/Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithDirectionalInsets.iPhone-13-portrait.png b/Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithDirectionalInsets.iPhone-13-portrait.png similarity index 100% rename from Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithDirectionalInsets.iPhone-13-portrait.png rename to Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithDirectionalInsets.iPhone-13-portrait.png diff --git a/Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithDirectionalInsets.iPhone-13-portrait.txt b/Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithDirectionalInsets.iPhone-13-portrait.txt similarity index 100% rename from Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithDirectionalInsets.iPhone-13-portrait.txt rename to Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithDirectionalInsets.iPhone-13-portrait.txt diff --git a/Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithDirectionalInsets.iPhone-8-portrait.png b/Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithDirectionalInsets.iPhone-8-portrait.png similarity index 100% rename from Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithDirectionalInsets.iPhone-8-portrait.png rename to Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithDirectionalInsets.iPhone-8-portrait.png diff --git a/Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithDirectionalInsets.iPhone-8-portrait.txt b/Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithDirectionalInsets.iPhone-8-portrait.txt similarity index 100% rename from Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithDirectionalInsets.iPhone-8-portrait.txt rename to Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithDirectionalInsets.iPhone-8-portrait.txt diff --git a/Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithDirectionalInsets.iPhone-SE-portrait.png b/Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithDirectionalInsets.iPhone-SE-portrait.png similarity index 100% rename from Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithDirectionalInsets.iPhone-SE-portrait.png rename to Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithDirectionalInsets.iPhone-SE-portrait.png diff --git a/Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithDirectionalInsets.iPhone-SE-portrait.txt b/Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithDirectionalInsets.iPhone-SE-portrait.txt similarity index 100% rename from Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithDirectionalInsets.iPhone-SE-portrait.txt rename to Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithDirectionalInsets.iPhone-SE-portrait.txt diff --git a/Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithDirectionalInsets.iPhone-X-portrait.png b/Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithDirectionalInsets.iPhone-X-portrait.png similarity index 100% rename from Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithDirectionalInsets.iPhone-X-portrait.png rename to Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithDirectionalInsets.iPhone-X-portrait.png diff --git a/Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithDirectionalInsets.iPhone-X-portrait.txt b/Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithDirectionalInsets.iPhone-X-portrait.txt similarity index 100% rename from Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithDirectionalInsets.iPhone-X-portrait.txt rename to Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithDirectionalInsets.iPhone-X-portrait.txt diff --git a/Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithInsets.iPhone-13-mini-portrait.png b/Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithInsets.iPhone-13-mini-portrait.png similarity index 100% rename from Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithInsets.iPhone-13-mini-portrait.png rename to Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithInsets.iPhone-13-mini-portrait.png diff --git a/Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithInsets.iPhone-13-mini-portrait.txt b/Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithInsets.iPhone-13-mini-portrait.txt similarity index 100% rename from Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithInsets.iPhone-13-mini-portrait.txt rename to Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithInsets.iPhone-13-mini-portrait.txt diff --git a/Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithInsets.iPhone-13-portrait.png b/Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithInsets.iPhone-13-portrait.png similarity index 100% rename from Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithInsets.iPhone-13-portrait.png rename to Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithInsets.iPhone-13-portrait.png diff --git a/Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithInsets.iPhone-13-portrait.txt b/Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithInsets.iPhone-13-portrait.txt similarity index 100% rename from Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithInsets.iPhone-13-portrait.txt rename to Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithInsets.iPhone-13-portrait.txt diff --git a/Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithInsets.iPhone-8-portrait.png b/Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithInsets.iPhone-8-portrait.png similarity index 100% rename from Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithInsets.iPhone-8-portrait.png rename to Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithInsets.iPhone-8-portrait.png diff --git a/Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithInsets.iPhone-8-portrait.txt b/Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithInsets.iPhone-8-portrait.txt similarity index 100% rename from Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithInsets.iPhone-8-portrait.txt rename to Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithInsets.iPhone-8-portrait.txt diff --git a/Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithInsets.iPhone-SE-portrait.png b/Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithInsets.iPhone-SE-portrait.png similarity index 100% rename from Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithInsets.iPhone-SE-portrait.png rename to Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithInsets.iPhone-SE-portrait.png diff --git a/Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithInsets.iPhone-SE-portrait.txt b/Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithInsets.iPhone-SE-portrait.txt similarity index 100% rename from Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithInsets.iPhone-SE-portrait.txt rename to Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithInsets.iPhone-SE-portrait.txt diff --git a/Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithInsets.iPhone-X-portrait.png b/Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithInsets.iPhone-X-portrait.png similarity index 100% rename from Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithInsets.iPhone-X-portrait.png rename to Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithInsets.iPhone-X-portrait.png diff --git a/Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithInsets.iPhone-X-portrait.txt b/Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithInsets.iPhone-X-portrait.txt similarity index 100% rename from Tests/LayoutTests/__Snapshots__/LayoutTests/testPin_andWithInsets.iPhone-X-portrait.txt rename to Tests/LayoutTests/__Snapshots__/LayoutTests/testConstrain_andWithInsets.iPhone-X-portrait.txt