Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #4 #5

Closed
wants to merge 3 commits into from
Closed

Closes #4 #5

wants to merge 3 commits into from

Conversation

o-nnerb
Copy link

@o-nnerb o-nnerb commented Mar 26, 2020

So I change the find method to search for all constraints that fit on anchor attributes. The quantity of parameters matters so the find method can find the specific constraint that you want to find. Because constraints are infinity and it is so difficult to find only one, so now find method returns an array of constraints. I tested a lot on my project because I can create and update the same constraint in the same method so I really need this working.

My idea is if there is an array of constraints that can be equal to anchor attributes view.anchor.top.find(), I will not call the 'activate(...)' method and I will only update the NSLayoutConstraint properties.

@onmyway133
Copy link
Owner

Hi, really appreciate your PR. I read it few times but somehow I found it to be a bit more complicated than needed. If there are potentially lots of contraints on a view, then I think we can just access its constraints property and filter from there. EasyAnchor is just builder so it should not hold state, the constraints property should be the source of truth

@o-nnerb
Copy link
Author

o-nnerb commented Apr 7, 2020

You're right. In real situations using UIKit I have never wanted some feature like that. Since I have started other project, the find function in EasyAnchor appears to be a good feature.

My idea was in a case that you have a lot of constraints on some view, to different views and you want to find the specific one using the same notation that you use to create the constraints using EasyAnchor.

As I develop in one library that I'm working one, I could remove the activate method and I just implement the ”orCreate” on Anchor. In this case, I could create constraints like that:

view.anchor
.top
.graterThanOrEqual
.orCreate // This returns a declarative struct that handles updates on nslayoutcontraints or continues the anchor builder
.constant(150)
.priority(750)

With this, there was no more overlap between two one more constraints that are equally. If you type next other constraint related to top and that needs to be grater that or equal to 100, it won't be ambiguous for UIKit, because it will update the previous constraint to be equal to the next request.

But, I don't see other developers using this feature to do something like that. Can I close this PR?

@o-nnerb o-nnerb closed this Apr 7, 2020
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.

None yet

2 participants