Skip to content

Commit

Permalink
Remove LayoutRelationer
Browse files Browse the repository at this point in the history
  • Loading branch information
OrkhanAlikhanov committed May 29, 2021
1 parent b99a7e2 commit 2c56fcc
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 201 deletions.
60 changes: 30 additions & 30 deletions Sources/LayoutSwift/Layout+Anchors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,96 +12,96 @@ public extension Layout {
Constraints top of the view to the given anchor.
- Parameter _ anchor: A LayoutAnchorable.
- Parameter _ offset: A CGFloat offset.
- Parameter _ relationer: A LayoutRelationer.
- Parameter _ relation: A LayoutRelation.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func top(_ anchor: LayoutAnchorable, _ offset: CGFloat = 0, _ relationer: LayoutRelationer = LayoutRelationers.equal) -> Layout {
constraint(.top, to: anchor, relationer: relationer, constant: offset)
func top(_ anchor: LayoutAnchorable, _ offset: CGFloat = 0, _ relation: LayoutRelation = .equal) -> Layout {
constraint(.top, to: anchor, relation: relation, constant: offset)
}

/**
Constraints left of the view to the given anchor.
- Parameter _ anchor: A LayoutAnchorable.
- Parameter _ offset: A CGFloat offset.
- Parameter _ relationer: A LayoutRelationer.
- Parameter _ relation: A LayoutRelation.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func left(_ anchor: LayoutAnchorable, _ offset: CGFloat = 0, _ relationer: LayoutRelationer = LayoutRelationers.equal) -> Layout {
constraint(.left, to: anchor, relationer: relationer, constant: offset)
func left(_ anchor: LayoutAnchorable, _ offset: CGFloat = 0, _ relation: LayoutRelation = .equal) -> Layout {
constraint(.left, to: anchor, relation: relation, constant: offset)
}

/**
Constraints right of the view to the given anchor.
- Parameter _ anchor: A LayoutAnchorable.
- Parameter _ offset: A CGFloat offset.
- Parameter _ relationer: A LayoutRelationer.
- Parameter _ relation: A LayoutRelation.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func right(_ anchor: LayoutAnchorable, _ offset: CGFloat = 0, _ relationer: LayoutRelationer = LayoutRelationers.equal) -> Layout {
constraint(.right, to: anchor, relationer: relationer, constant: -offset)
func right(_ anchor: LayoutAnchorable, _ offset: CGFloat = 0, _ relation: LayoutRelation = .equal) -> Layout {
constraint(.right, to: anchor, relation: relation, constant: -offset)
}

/**
Constraints leading of the view to the given anchor.
- Parameter _ anchor: A LayoutAnchorable.
- Parameter _ offset: A CGFloat offset.
- Parameter _ relationer: A LayoutRelationer.
- Parameter _ relation: A LayoutRelation.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func leading(_ anchor: LayoutAnchorable, _ offset: CGFloat = 0, _ relationer: LayoutRelationer = LayoutRelationers.equal) -> Layout {
constraint(.leading, to: anchor, relationer: relationer, constant: offset)
func leading(_ anchor: LayoutAnchorable, _ offset: CGFloat = 0, _ relation: LayoutRelation = .equal) -> Layout {
constraint(.leading, to: anchor, relation: relation, constant: offset)
}

/**
Constraints trailing of the view to the given anchor.
- Parameter _ anchor: A LayoutAnchorable.
- Parameter _ offset: A CGFloat offset.
- Parameter _ relationer: A LayoutRelationer.
- Parameter _ relation: A LayoutRelation.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func trailing(_ anchor: LayoutAnchorable, _ offset: CGFloat = 0, _ relationer: LayoutRelationer = LayoutRelationers.equal) -> Layout {
constraint(.trailing, to: anchor, relationer: relationer, constant: -offset)
func trailing(_ anchor: LayoutAnchorable, _ offset: CGFloat = 0, _ relation: LayoutRelation = .equal) -> Layout {
constraint(.trailing, to: anchor, relation: relation, constant: -offset)
}

/**
Constraints bottom of the view to the given anchor.
- Parameter _ anchor: A LayoutAnchorable.
- Parameter _ offset: A CGFloat offset.
- Parameter _ relationer: A LayoutRelationer.
- Parameter _ relation: A LayoutRelation.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func bottom(_ anchor: LayoutAnchorable, _ offset: CGFloat = 0, _ relationer: LayoutRelationer = LayoutRelationers.equal) -> Layout {
constraint(.bottom, to: anchor, relationer: relationer, constant: -offset)
func bottom(_ anchor: LayoutAnchorable, _ offset: CGFloat = 0, _ relation: LayoutRelation = .equal) -> Layout {
constraint(.bottom, to: anchor, relation: relation, constant: -offset)
}

/**
Constraints horizontal center of the view to the given anchor.
- Parameter _ anchor: A LayoutAnchorable.
- Parameter _ offset: A CGFloat offset.
- Parameter _ relationer: A LayoutRelationer.
- Parameter _ relation: A LayoutRelation.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func centerX(_ anchor: LayoutAnchorable, _ offset: CGFloat = 0, _ relationer: LayoutRelationer = LayoutRelationers.equal) -> Layout {
constraint(.centerX, to: anchor, relationer: relationer, constant: offset)
func centerX(_ anchor: LayoutAnchorable, _ offset: CGFloat = 0, _ relation: LayoutRelation = .equal) -> Layout {
constraint(.centerX, to: anchor, relation: relation, constant: offset)
}

/**
Constraints vertical center of the view to the given anchor.
- Parameter _ anchor: A LayoutAnchorable.
- Parameter _ offset: A CGFloat offset.
- Parameter _ relationer: A LayoutRelationer.
- Parameter _ relation: A LayoutRelation.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func centerY(_ anchor: LayoutAnchorable, _ offset: CGFloat = 0, _ relationer: LayoutRelationer = LayoutRelationers.equal) -> Layout {
constraint(.centerY, to: anchor, relationer: relationer, constant: offset)
func centerY(_ anchor: LayoutAnchorable, _ offset: CGFloat = 0, _ relation: LayoutRelation = .equal) -> Layout {
constraint(.centerY, to: anchor, relation: relation, constant: offset)
}
}

Expand Down Expand Up @@ -274,23 +274,23 @@ public extension Layout {
Constraints width of the view to the given anchor.
- Parameter _ anchor: A LayoutAnchorable.
- Parameter _ offset: A CGFloat offset.
- Parameter _ relationer: A LayoutRelationer.
- Parameter _ relation: A LayoutRelation.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func width(_ anchor: LayoutAnchorable, offset: CGFloat = 0, _ relationer: LayoutRelationer = LayoutRelationers.equal) -> Layout {
constraint(.width, to: anchor, relationer: relationer, constant: offset)
func width(_ anchor: LayoutAnchorable, offset: CGFloat = 0, _ relation: LayoutRelation = .equal) -> Layout {
constraint(.width, to: anchor, relation: relation, constant: offset)
}

/**
Constraints height of the view to the given anchor.
- Parameter _ anchor: A LayoutAnchorable.
- Parameter _ offset: A CGFloat offset.
- Parameter _ relationer: A LayoutRelationer.
- Parameter _ relation: A LayoutRelation.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func height(_ anchor: LayoutAnchorable, offset: CGFloat = 0, _ relationer: LayoutRelationer = LayoutRelationers.equal) -> Layout {
constraint(.height, to: anchor, relationer: relationer, constant: offset)
func height(_ anchor: LayoutAnchorable, offset: CGFloat = 0, _ relation: LayoutRelation = .equal) -> Layout {
constraint(.height, to: anchor, relation: relation, constant: offset)
}
}
60 changes: 30 additions & 30 deletions Sources/LayoutSwift/Layout+Margin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,89 +11,89 @@ public extension Layout {
/**
Constraints top of the view to the parent's marginAnchor.
- Parameter _ offset: A CGFloat offset.
- Parameter _ relationer: A LayoutRelationer.
- Parameter _ relation: A LayoutRelation.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func topMargin(_ offset: CGFloat = 0, _ relationer: LayoutRelationer = LayoutRelationers.equal) -> Layout {
top(ensuredParent.marginAnchor, offset, relationer)
func topMargin(_ offset: CGFloat = 0, _ relation: LayoutRelation = .equal) -> Layout {
top(ensuredParent.marginAnchor, offset, relation)
}

/**
Constraints left of the view to the parent's marginAnchor.
- Parameter _ offset: A CGFloat offset.
- Parameter _ relationer: A LayoutRelationer.
- Parameter _ relation: A LayoutRelation.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func leftMargin(_ offset: CGFloat = 0, _ relationer: LayoutRelationer = LayoutRelationers.equal) -> Layout {
left(ensuredParent.marginAnchor, offset, relationer)
func leftMargin(_ offset: CGFloat = 0, _ relation: LayoutRelation = .equal) -> Layout {
left(ensuredParent.marginAnchor, offset, relation)
}

/**
Constraints right of the view to the parent's marginAnchor.
- Parameter _ offset: A CGFloat offset.
- Parameter _ relationer: A LayoutRelationer.
- Parameter _ relation: A LayoutRelation.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func rightMargin(_ offset: CGFloat = 0, _ relationer: LayoutRelationer = LayoutRelationers.equal) -> Layout {
right(ensuredParent.marginAnchor, offset, relationer)
func rightMargin(_ offset: CGFloat = 0, _ relation: LayoutRelation = .equal) -> Layout {
right(ensuredParent.marginAnchor, offset, relation)
}

/**
Constraints leading of the view to the parent's marginAnchor.
- Parameter _ offset: A CGFloat offset.
- Parameter _ relationer: A LayoutRelationer.
- Parameter _ relation: A LayoutRelation.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func leadingMargin(_ offset: CGFloat = 0, _ relationer: LayoutRelationer = LayoutRelationers.equal) -> Layout {
leading(ensuredParent.marginAnchor, offset, relationer)
func leadingMargin(_ offset: CGFloat = 0, _ relation: LayoutRelation = .equal) -> Layout {
leading(ensuredParent.marginAnchor, offset, relation)
}

/**
Constraints trailing of the view to the parent's marginAnchor.
- Parameter _ offset: A CGFloat offset.
- Parameter _ relationer: A LayoutRelationer.
- Parameter _ relation: A LayoutRelation.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func trailingMargin(_ offset: CGFloat = 0, _ relationer: LayoutRelationer = LayoutRelationers.equal) -> Layout {
trailing(ensuredParent.marginAnchor, offset, relationer)
func trailingMargin(_ offset: CGFloat = 0, _ relation: LayoutRelation = .equal) -> Layout {
trailing(ensuredParent.marginAnchor, offset, relation)
}

/**
Constraints bottom of the view to the parent's marginAnchor.
- Parameter _ offset: A CGFloat offset.
- Parameter _ relationer: A LayoutRelationer.
- Parameter _ relation: A LayoutRelation.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func bottomMargin(_ offset: CGFloat = 0, _ relationer: LayoutRelationer = LayoutRelationers.equal) -> Layout {
bottom(ensuredParent.marginAnchor, offset, relationer)
func bottomMargin(_ offset: CGFloat = 0, _ relation: LayoutRelation = .equal) -> Layout {
bottom(ensuredParent.marginAnchor, offset, relation)
}

/**
Constraints horizontal center of the view to the parent's marginAnchor.
- Parameter _ offset: A CGFloat offset.
- Parameter _ relationer: A LayoutRelationer.
- Parameter _ relation: A LayoutRelation.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func centerXMargin(_ offset: CGFloat = 0, _ relationer: LayoutRelationer = LayoutRelationers.equal) -> Layout {
centerX(ensuredParent.marginAnchor, offset, relationer)
func centerXMargin(_ offset: CGFloat = 0, _ relation: LayoutRelation = .equal) -> Layout {
centerX(ensuredParent.marginAnchor, offset, relation)
}

/**
Constraints vertical center of the view to the parent's marginAnchor.
- Parameter _ offset: A CGFloat offset.
- Parameter _ relationer: A LayoutRelationer.
- Parameter _ relation: A LayoutRelation.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func centerYMargin(_ offset: CGFloat = 0, _ relationer: LayoutRelationer = LayoutRelationers.equal) -> Layout {
centerY(ensuredParent.marginAnchor, offset, relationer)
func centerYMargin(_ offset: CGFloat = 0, _ relation: LayoutRelation = .equal) -> Layout {
centerY(ensuredParent.marginAnchor, offset, relation)
}
}

Expand Down Expand Up @@ -252,22 +252,22 @@ public extension Layout {
/**
Constraints width of the view to the parent's marginAnchor.
- Parameter _ offset: A CGFloat offset.
- Parameter _ relationer: A LayoutRelationer.
- Parameter _ relation: A LayoutRelation.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func widthMargin(offset: CGFloat = 0, _ relationer: LayoutRelationer = LayoutRelationers.equal) -> Layout {
width(ensuredParent.marginAnchor, offset: offset, relationer)
func widthMargin(offset: CGFloat = 0, _ relation: LayoutRelation = .equal) -> Layout {
width(ensuredParent.marginAnchor, offset: offset, relation)
}

/**
Constraints height of the view to the parent's marginAnchor.
- Parameter _ offset: A CGFloat offset.
- Parameter _ relationer: A LayoutRelationer.
- Parameter _ relation: A LayoutRelation.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func heightMargin(offset: CGFloat = 0, _ relationer: LayoutRelationer = LayoutRelationers.equal) -> Layout {
height(ensuredParent.marginAnchor, offset: offset, relationer)
func heightMargin(offset: CGFloat = 0, _ relation: LayoutRelation = .equal) -> Layout {
height(ensuredParent.marginAnchor, offset: offset, relation)
}
}
Loading

0 comments on commit 2c56fcc

Please sign in to comment.