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

Improve EdgesConstrainableProxy API ↔️ #247

Merged
merged 1 commit into from
Oct 15, 2021

Conversation

p4checo
Copy link
Member

@p4checo p4checo commented Oct 12, 2021

Checklist

Motivation and Context

Until now, it wasn't possible to define edges constraints using a NSDirectionalEdgeInsets value, requiring one to convert them to UIEdgeInsets.

Additionally, the EdgesConstrainableProxy.edges() API only received a single relation and priority parameters for all edges, which is often not ideal in real scenarios. Some examples are:

  • allow a single edge constraint to "break"with a smaller priority and not others
  • allow edges to "shrink" towards the center, where the relation needs to be inverted between leading/trailing or top/bottom.

To address the above, a new overload was added to EdgesConstrainableProxy that takes in a NSDirectionalEdgeInsets instance, and new edge-specific relation/priority parameters were added.

Changes

Description

  • Add a new EdgesConstrainableProxy.edges overload that receives a NSDirectionalEdgeInsets instance instead of a UIEdgeInsets.

  • Allow tweaking relation and priority for each edge of a EdgesConstrainableProxy.

  • Create helpers to convert between UIEdgesInsets and NSDirectionalEdgesInsets.

@codecov
Copy link

codecov bot commented Oct 12, 2021

Codecov Report

Merging #247 (f05192b) into master (48f7c68) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #247      +/-   ##
==========================================
+ Coverage   94.94%   94.96%   +0.02%     
==========================================
  Files          97       99       +2     
  Lines        3266     3280      +14     
==========================================
+ Hits         3101     3115      +14     
  Misses        165      165              
Impacted Files Coverage Δ
Sources/AutoLayout/ConstrainableProxy.swift 98.06% <100.00%> (+0.05%) ⬆️
...ces/Extensions/UIKit/NSDirectionalEdgeInsets.swift 100.00% <100.00%> (ø)
Sources/Extensions/UIKit/UIEdgeInsets.swift 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 48f7c68...f05192b. Read the comment docs.

@p4checo p4checo force-pushed the feature/support-directional-insets-in-auto-layout branch from ebb3d3f to 408b25b Compare October 13, 2021 15:14
@p4checo p4checo changed the title Support NSDirectionalEdgeInsets in EdgesConstrainableProxy ↔️ Improve EdgesConstrainableProxy API ↔️ Oct 13, 2021
@p4checo p4checo force-pushed the feature/support-directional-insets-in-auto-layout branch 2 times, most recently from 1bea77e to 4764f26 Compare October 14, 2021 09:08
Until now, it wasn't possible to define edges constraints using a
`NSDirectionalEdgeInsets` value, requiring one to convert them to
`UIEdgeInsets`.

Additionally, the `EdgesConstrainableProxy.edges()` API only received a
single `relation` and `priority` parameters for all edges, which is
often not ideal in real scenarios. Some examples are:
 - allow a single edge constraint to "break"with a smaller `priority`
 and not others
 - allow edges to "shrink" towards the center, where the `relation`
 needs to be inverted between `leading`/`trailing` or `top`/`bottom`.

To address the above, a new overload was added to
`EdgesConstrainableProxy` that takes in a `NSDirectionalEdgeInsets`
instance, and new edge-specific relation/priority parameters were added.

## Changes

- Add a new `EdgesConstrainableProxy.edges` overload that receives a
`NSDirectionalEdgeInsets` instance instead of a `UIEdgeInsets`.

- Allow tweaking `relation` and `priority` for each edge of a
`EdgesConstrainableProxy`.

- Create helpers to convert between `UIEdgesInsets` and
`NSDirectionalEdgesInsets`.
@p4checo p4checo force-pushed the feature/support-directional-insets-in-auto-layout branch from 4764f26 to f05192b Compare October 14, 2021 09:18
@p4checo p4checo merged commit 21f56cb into master Oct 15, 2021
@p4checo p4checo deleted the feature/support-directional-insets-in-auto-layout branch October 15, 2021 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants