Skip to content

Commit

Permalink
rename topLeft(pin: Pin, of view: UIView) to pinTopLeft(pin: Pin, of …
Browse files Browse the repository at this point in the history
…view:UIView)
  • Loading branch information
Luc Dion authored and Luc Dion committed Mar 12, 2017
1 parent 90872ad commit 831fe10
Show file tree
Hide file tree
Showing 10 changed files with 451 additions and 163 deletions.
12 changes: 8 additions & 4 deletions MCSwiftLayout.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

/* Begin PBXBuildFile section */
2439CC311E6659FA003326FB /* Layout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2439CC301E6659FA003326FB /* Layout.swift */; };
246D36481E6C46F50050F202 /* BasicTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 246D36471E6C46F50050F202 /* BasicTests.swift */; };
2469C4FC1E74855D00073BEE /* PinEdgeCoordinateSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2469C4FB1E74855D00073BEE /* PinEdgeCoordinateSpec.swift */; };
246D36481E6C46F50050F202 /* PinPointCoordinatesSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 246D36471E6C46F50050F202 /* PinPointCoordinatesSpec.swift */; };
249EFE841E64FB4C00165E39 /* MCSwiftLayout.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 249EFE7A1E64FB4C00165E39 /* MCSwiftLayout.framework */; };
249EFE891E64FB4C00165E39 /* MCSwiftLayoutTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 249EFE881E64FB4C00165E39 /* MCSwiftLayoutTests.swift */; };
249EFE8B1E64FB4C00165E39 /* MCSwiftLayout.h in Headers */ = {isa = PBXBuildFile; fileRef = 249EFE7D1E64FB4C00165E39 /* MCSwiftLayout.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand All @@ -27,7 +28,8 @@

/* Begin PBXFileReference section */
2439CC301E6659FA003326FB /* Layout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Layout.swift; sourceTree = "<group>"; };
246D36471E6C46F50050F202 /* BasicTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BasicTests.swift; sourceTree = "<group>"; };
2469C4FB1E74855D00073BEE /* PinEdgeCoordinateSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PinEdgeCoordinateSpec.swift; sourceTree = "<group>"; };
246D36471E6C46F50050F202 /* PinPointCoordinatesSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PinPointCoordinatesSpec.swift; sourceTree = "<group>"; };
249EFE7A1E64FB4C00165E39 /* MCSwiftLayout.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MCSwiftLayout.framework; sourceTree = BUILT_PRODUCTS_DIR; };
249EFE7D1E64FB4C00165E39 /* MCSwiftLayout.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MCSwiftLayout.h; sourceTree = "<group>"; };
249EFE7E1E64FB4C00165E39 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -101,7 +103,8 @@
isa = PBXGroup;
children = (
249EFE881E64FB4C00165E39 /* MCSwiftLayoutTests.swift */,
246D36471E6C46F50050F202 /* BasicTests.swift */,
246D36471E6C46F50050F202 /* PinPointCoordinatesSpec.swift */,
2469C4FB1E74855D00073BEE /* PinEdgeCoordinateSpec.swift */,
249EFE8A1E64FB4C00165E39 /* Info.plist */,
);
path = MCSwiftLayoutTests;
Expand Down Expand Up @@ -288,7 +291,8 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
246D36481E6C46F50050F202 /* BasicTests.swift in Sources */,
2469C4FC1E74855D00073BEE /* PinEdgeCoordinateSpec.swift in Sources */,
246D36481E6C46F50050F202 /* PinPointCoordinatesSpec.swift in Sources */,
249EFE891E64FB4C00165E39 /* MCSwiftLayoutTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
258 changes: 169 additions & 89 deletions MCSwiftLayout/Layout.swift

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions MCSwiftLayoutSample/MCSwiftLayoutSample/ChainedLayoutView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ class ChainedLayoutView: UIView {
// topRightView.bottomRight = centerView.topRight

//bottomLeftView.layout2.topLeft(centerView.bottomLeft).margins(10)
bottomLeftView.layout.topLeft(centerView.bottomLeft).height(50).topMargin(10).bottomMargin(10)
bottomCenterView.layout.topCenter(centerView.bottomCenter).height(50).topMargin(10).bottomMargin(10)
bottomRightView.layout.topRight(centerView.bottomRight).height(50).topMargin(10).bottomMargin(10)
bottomLeftView.layout.pinTopLeft(to: centerView.bottomLeft).height(50).topMargin(10).bottomMargin(10)
bottomCenterView.layout.pinCenter(to: centerView.bottomCenter).height(50).topMargin(10).bottomMargin(10)
bottomRightView.layout.pinTopRight(to: centerView.bottomRight).height(50).topMargin(10).bottomMargin(10)

rightTopView.layout.topLeft(centerView.topRight).width(50).leftMargin(10).rightMargin(10)
rightCenterView.layout.leftCenter(centerView.rightCenter).height(50).leftMargin(10).rightMargin(10)
rightBottomView.layout.bottomLeft(centerView.bottomRight).height(50).leftMargin(10).rightMargin(10)
rightTopView.layout.pinTopLeft(to: centerView.topRight).width(50).leftMargin(10).rightMargin(10)
rightCenterView.layout.pinLeftCenter(to: centerView.rightCenter).height(50).leftMargin(10).rightMargin(10)
rightBottomView.layout.pinBottomLeft(to: centerView.bottomRight).height(50).leftMargin(10).rightMargin(10)

//
// leftTopView.topRight = centerView.topLeft
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ class MarginsAndPaddingsLeftRightView: UIView {

let leftPosition: CGFloat = 0

contentScrollView.layout.topLeft(CGPoint(x: 0, y: 0)).width(width).height(height).topInset(64)
contentScrollView.layout.pinTopLeft().width(width).height(height).topInset(64)

descriptionLabel.size = descriptionLabel.sizeThatFits(CGSize(width: width, height: .greatestFiniteMagnitude))
descriptionLabel.layout.topLeft(CGPoint(x: leftPosition, y: 10))
descriptionLabel.layout.pinTopLeft(to: CGPoint(x: leftPosition, y: 10))

// No margins
let rightPosition: CGFloat = 70
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ class MarginsAndPaddingsLeftWidthView: UIView {

let leftPosition: CGFloat = 0

contentScrollView.layout.topLeft(CGPoint(x: 0, y: 0)).width(width).height(height).topInset(64)
contentScrollView.layout.pinTopLeft().width(width).height(height).topInset(64)

descriptionLabel.size = descriptionLabel.sizeThatFits(CGSize(width: width, height: .greatestFiniteMagnitude))
descriptionLabel.layout.topLeft(CGPoint(x: leftPosition, y: 10))
descriptionLabel.layout.pinTopLeft(to: CGPoint(x: leftPosition, y: 10))

// No margins
noMarginsNoPaddings.layout.topLeft(descriptionLabel.bottomLeft).topMargin(5)
noMarginsNoPaddings.layout.pinTopLeft(to: descriptionLabel.bottomLeft).topMargin(5)
noMarginsLeftInsetView.layout.top(noMarginsNoPaddings.bottom).left(leftPosition).width(70).leftInset(10)
noMarginsRightInsetView.layout.top(noMarginsLeftInsetView.bottom).left(leftPosition).width(70).rightInset(10)
noMarginsLeftRightInsetView.layout.top(noMarginsRightInsetView.bottom).left(leftPosition).width(70).leftInset(10).rightInset(10)
Expand Down
2 changes: 1 addition & 1 deletion MCSwiftLayoutSample/MCSwiftLayoutSample/RelativeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class RelativeView: UIView {
override func layoutSubviews() {
super.layoutSubviews()

belowNavBarView.layout.topLeft(.zero).size(size).topInset(64)
belowNavBarView.layout.pinTopLeft().size(size).topInset(64)

centerView.width = 200
centerView.height = 200
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,21 +122,64 @@ class BothEdgesSnappedView: UIView {
bView.frame = CGRect(x: 160, y: 200, width: 110, height: 80)
bViewChild.frame = CGRect(x: 40, y: 10, width: 60, height: 20)

//
// pin coordinate
//
// aViewChild.layout.pinTop(.top, of: aView) //CGRect(x: 10.0, y: 0.0, width: 50.0, height: 30.0)
// aViewChild.layout.pinTop(.top, of: bView) // CGRect(x: 10.0, y: 100.0, width: 50.0, height: 30.0)
// bViewChild.layout.pinTop(.top, of: aViewChild) //CGRect(x: 40.0, y: -80.0, width: 60.0, height: 20.0)

// aViewChild.layout.pinTop(.bottom, of: aView) //CGRect(x: 10.0, y: 60.0, width: 50.0, height: 30.0)
// aViewChild.layout.pinTop(.bottom, of: bView) //CGRect(x: 10.0, y: 180.0, width: 50.0, height: 30.0)
// bViewChild.layout.pinTop(.bottom, of: aViewChild) //CGRect(x: 40.0, y: -50.0, width: 60.0, height: 20.0)

// aViewChild.layout.pinBottom(.top, of: aView) //CGRect(x: 140.0, y: 100.0, width: 100.0, height: 60.0)
// aViewChild.layout.pinBottom(.top, of: bView) //CGRect(x: 10.0, y: 70.0, width: 50.0, height: 30.0)
// bViewChild.layout.pinBottom(.top, of: aViewChild) //CGRect(x: 40.0, y: -100.0, width: 60.0, height: 20.0)
//
// aViewChild.layout.pinBottom(.bottom, of: aView) //CGRect(x: 140.0, y: 100.0, width: 100.0, height: 60.0)
// aViewChild.layout.pinBottom(.bottom, of: bView) //CGRect(x: 10.0, y: 150.0, width: 50.0, height: 30.0)
// bViewChild.layout.pinBottom(.bottom, of: aViewChild) //CGRect(x: 40.0, y: -70.0, width: 60.0, height: 20.0)

// aViewChild.layout.pinLeft(.left, of: aView) //CGRect(x: 0.0, y: 20.0, width: 50.0, height: 30.0)
// aViewChild.layout.pinLeft(.left, of: bView) //CGRect(x: 20.0, y: 20.0, width: 50.0, height: 30.0)
// bViewChild.layout.pinLeft(.left, of: aViewChild) //CGRect(x: -10.0, y: 10.0, width: 60.0, height: 20.0)
//
// aViewChild.layout.pinLeft(.right, of: aView) //CGRect(x: 100.0, y: 20.0, width: 50.0, height: 30.0)
// aViewChild.layout.pinLeft(.right, of: bView) //CGRect(x: 130.0, y: 20.0, width: 50.0, height: 30.0)
// bViewChild.layout.pinLeft(.right, of: aViewChild) //CGRect(x: 40.0, y: 10.0, width: 60.0, height: 20.0)

// aViewChild.layout.pinRight(.left, of: aView) //CGRect(x: 140.0, y: 100.0, width: 100.0, height: 60.0)
// aViewChild.layout.pinRight(.left, of: bView) //CGRect(x: -30.0, y: 20.0, width: 50.0, height: 30.0)
// bViewChild.layout.pinRight(.left, of: aViewChild) //CGRect(x: -70.0, y: 10.0, width: 60.0, height: 20.0)
//
// aViewChild.layout.pinRight(.right, of: aView) //CGRect(x: 140.0, y: 100.0, width: 100.0, height: 60.0)
// aViewChild.layout.pinRight(.right, of: bView) //CGRect(x: 80.0, y: 20.0, width: 50.0, height: 30.0)
// bViewChild.layout.pinRight(.right, of: aViewChild) //CGRect(x: -20.0, y: 10.0, width: 60.0, height: 20.0)

//
// pin point
//

// topLeft
// aView.layout.topLeft() // CGRect(x: 0.0, y: 0.0, width: 100.0, height: 60.0)
aViewChild.layout.topLeft(.topLeft, of: aView) //(of: aView) // CGRect(x: 0.0, y: 0.0, width: 50.0, height: 30.0)
aViewChild.layout.topLeft(of: aView) // CGRect(x: 0.0, y: 0.0, width: 50.0, height: 30.0)
// aView.layout.topLe
// aViewChild.layout.pinTopLeft(.topLeft, of: aView) //(of: aView) // CGRect(x: 0.0, y: 0.0, width: 50.0, height: 30.0)
// aViewChild.layout.pinTopLeft(of: aView) // CGRect(x: 0.0, y: 0.0, width: 50.0, height: 30.0)
// aViewChild.layout.pinTopLeft(of: aView).pinBottomRight()
// aViewChild.layout.topLeft(of: bView) // CGRect(x: 20.0, y: 100.0, width: 50.0, height: 30.0)
// bView.layout.topLeft(of: aViewChild) // CGRect(x: 150.0, y: 120.0, width: 110.0, height: 80.0)
// bViewChild.layout.topLeft(of: aViewChild) // CGRect(x: -10.0, y: -80.0, width: 60.0, height: 20.0)

// topCenter
// aView.layout.topCenter() // CGRect(x: 150.0, y: 0.0, width: 100.0, height: 60.0)
// aViewChild.layout.topCenter(of: aView) //CGRect(x: 25.0, y: 0.0, width: 50.0, height: 30.0)
// aViewChild.layout.topCenter(of: bView) //CGRect(x: 50.0, y: 100.0, width: 50.0, height: 30.0)
// bView.layout.topCenter(of: aViewChild) //CGRect(x: 120.0, y: 120.0, width: 110.0, height: 80.0)
// bViewChild.layout.topCenter(of: aViewChild) //CGRect(x: -15.0, y: -80.0, width: 60.0, height: 20.0)
// bViewChild.layout.pinTopLeft(to: aViewChild)< // CGRect(x: -10.0, y: -80.0, width: 60.0, height: 20.0)


// bView.layout.pinBottomRight().pinTopLeft(to: .zero).below(of: bViewChild)


// pinTopCenter
// aView.layout.pinTopCenter() // CGRect(x: 150.0, y: 0.0, width: 100.0, height: 60.0)
// aViewChild.layout.pinTopCenter(of: aView) //CGRect(x: 25.0, y: 0.0, width: 50.0, height: 30.0)
// aViewChild.layout.pinTopCenter(of: bView) //CGRect(x: 50.0, y: 100.0, width: 50.0, height: 30.0)
// bView.layout.pinTopCenter(of: aViewChild) //CGRect(x: 120.0, y: 120.0, width: 110.0, height: 80.0)
// bViewChild.layout.pinTopCenter(of: aViewChild) //CGRect(x: -15.0, y: -80.0, width: 60.0, height: 20.0)

// topRight
// aView.layout.topRight() //CGRect(x: 300.0, y: 0.0, width: 100.0, height: 60.0)
Expand Down
4 changes: 2 additions & 2 deletions MCSwiftLayoutTests/MCSwiftLayoutTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class MCSwiftLayoutTests: XCTestCase {
let child1 = UIView()
rootView.addSubview(child1)

child1.layout.center(of: rootView)
print("child1.frame: \(child1.frame)")
// child1.layout.pinCenter(of: rootView)
// print("child1.frame: \(child1.frame)")
}

func testPerformanceExample() {
Expand Down
Loading

0 comments on commit 831fe10

Please sign in to comment.