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

Constrictor 5.0.0 #22

Merged
merged 51 commits into from
Jan 18, 2019
Merged

Constrictor 5.0.0 #22

merged 51 commits into from
Jan 18, 2019

Conversation

pedrommcarrasco
Copy link
Owner

@pedrommcarrasco pedrommcarrasco commented Jan 16, 2019

What was done?

  • Re-Developed Constrictor from the ground.
  • Re-Developed every single test and added snapshot testing

Why?

This was mainly done because its learning curve was way too high, as well as, adding the "update constraint feature" was way too hard in its previous state.

Code Sample

I strongly advise you to read the new README.md
Still here are some examples

New Features

It's now possible to easily update constraints without tricky identifiers or filters.

// Only have one constraint for an anchor?
label.constrictor.updateFirst(.top) { $0?.enable() }
// Have two constraints for an anchor but for different elements? Provide more details
label.constrictor.update(.bottom, to: imageView) { $0?.constant = 16 }
// Call UIView.animate(...) { view.layoutIfNeeded() } to animate changes

Lost Features

  • Lost safeArea's abstraction - To do? No plans
  • Lost the inParent/toParent sugar - To do? Maybe in the future

Before vs Now

Example 1

4.1.0 (Before)

guide.constrictEdges(to: contentView, with: .all(8))

5.0.0 (Now)

guide.constrictor
    .edge(to: contentView, with: 8)

Example 2

4.1.0 (Before)

logoImageView
    .constrict(to: guide, attributes: .top, .centerX, .width)
    .constrict(.height, to: guide, attribute: .width, multiplyBy: 0.5)

5.0.0 (Now)

logoImageView.constrictor
    .top(to: guide)
    .centerX(to: guide)
    .width(to: guide)
    .height(to: guide, .width, multiplyBy: 0.5)

Example 3

4.1.0 (Before)

stackView
    .constrictCenterInParent()
    .constrict(.width, with: 100)

5.0.0 (Now)

stackView.constrictor
    .center(in: self)
    .width(to: 100)

@pedrommcarrasco pedrommcarrasco added the enhancement New feature or request label Jan 16, 2019
@pedrommcarrasco pedrommcarrasco self-assigned this Jan 16, 2019
@pedrommcarrasco pedrommcarrasco changed the title Revamp Constrictor 5.0.0 Jan 16, 2019
@codecov-io
Copy link

Codecov Report

Merging #22 into master will not change coverage.
The diff coverage is 100%.

@@          Coverage Diff           @@
##           master    #22    +/-   ##
======================================
  Coverage     100%   100%            
======================================
  Files           9     22    +13     
  Lines         197    468   +271     
======================================
+ Hits          197    468   +271

anafpf
anafpf previously approved these changes Jan 18, 2019
@NSMyself
Copy link
Collaborator

Great job 👍

NSMyself
NSMyself previously approved these changes Jan 18, 2019
extension Anchor {

func constraints(for constraints: Constraints) -> [NSLayoutConstraint] {
switch self{
Copy link
Collaborator

Choose a reason for hiding this comment

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

please add a space between "self{" 😄

Copy link
Owner Author

Choose a reason for hiding this comment

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

Nice catch! 👍

}

func constraints(for constraints: Constraints) -> [NSLayoutConstraint] {
switch self{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same

@pedrommcarrasco pedrommcarrasco dismissed stale reviews from NSMyself and anafpf via 307c4b9 January 18, 2019 11:51
@pedrommcarrasco pedrommcarrasco merged commit ea0ea6b into master Jan 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants