Skip to content

Conversation

@gsbernstein
Copy link
Owner

Anchor versions: constraining one view's dimension to another view's dimension
Constant version: constrain a view's dimension to a constant

  • reverts 9c055fb: inferring superview on the anchor versions was a huge mistake because it allows the anchor version of width/height to overload the constant version of width/height. First noticed when Vir was onboarding and it was calling the wrong one unexpectedly.
  • de-anonymizes constant versions' Float input params for clarity
  • remove default values from constant versions' Float input params (why would zero be the default??)

These are breaking changes, but worth it.

@gsbernstein gsbernstein requested a review from ericgroom August 19, 2020 18:29
@ericgroom
Copy link
Collaborator

reverts 9c055fb: inferring superview on the anchor versions was a huge mistake because it allows the anchor version of width/height to overload the constant version of width/height. First noticed when Vir was onboarding and it was calling the wrong one unexpectedly.

I'm a bit confused on the implications of this, does this mean that there are height/width constraints that weren't working [as intended]?

@gsbernstein
Copy link
Owner Author

gsbernstein commented Aug 22, 2020 via email

Copy link
Collaborator

@ericgroom ericgroom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm all for removing optionals where unnecessary, and default arguments (as those have bitten us more than once) but I think we need to find out how much of a breaking change this is. If I'm reading this correctly pretty much every height/width/size usage would have to be edited?

// Can't have the constant param be anonymous or have a default or it would overload the anchor equivalent
@discardableResult
func height(_ constant: CGFloat = 0.0, by relationship: Relationship = .equal, priority: UILayoutPriority = .required) -> Constraints {
func height(to constant: CGFloat, by relationship: Relationship = .equal, priority: UILayoutPriority = .required) -> Constraints {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to omit the argument label, I think the bigger issue was that the anchor version had a default value of nil right?

@gsbernstein
Copy link
Owner Author

gsbernstein commented Aug 26, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants