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

Add support for CALayer layout #151

Merged
merged 7 commits into from
Jun 26, 2018
Merged

Conversation

antoinelamy
Copy link
Contributor

Since every UIView has a backing layer and it's that layer's responsibility alone to manage coordinates and drawing, I added Layoutable conformance to CALayer and delegated UIView's getRect/setRect to it's backing layer. NSView is a slightly different animal and it's not all NSView that has a backing layer so we leave it's current layout system unchanged.

@@ -415,8 +408,8 @@ class PinSafeAreaMoreTestsSpec: QuickSpec {
setupWindow(with: navigationController)

// MATCH safeAreaInsets!
expect(mainView.safeAreaInsetsDidChangeCalledCount).to(equal(expectedSafeAreaInsetsDidChangeCalledCount))
expect(mainView.subView.safeAreaInsetsDidChangeCalledCount).to(equal(expectedSubViewSafeAreaInsetsDidChangeCalledCount))
expect(mainView.safeAreaInsetsDidChangeCalledCount) > 0
Copy link
Member

Choose a reason for hiding this comment

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

We could also update all other similar cases in safeArea unit tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do :)

aLayer.pin.top(10).left(10).width(20%).height(80%).layout()
bLayer.pin.size(CGSize(width: 20, height: 20)).right(of: aLayer, aligned: .center).layout()
expect(aLayer.frame).to(equal(CGRect(x: 10, y: 10, width: 80, height: 320)))
}
Copy link
Member

Choose a reason for hiding this comment

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

maybe add unit tests that:

  • use pinFrame
  • use edge property
  • use anchor property

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will also do :)

//
describe("test CALayer interface") {
it("basic pinlayout calls") {
aLayer.pin.top(10).left(10).width(20%).height(80%).layout()
Copy link
Member

Choose a reason for hiding this comment

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

Is it required to call layout()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure, I took example on the ObjectiveCSpec that also manually call layout() but it is most likely not needed.

Copy link
Member

@lucdion lucdion left a comment

Choose a reason for hiding this comment

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

Good job 🎉

* [`aspectRatio()`](#aspect_ratio) with no parameters (Coming soon)

* Support for [`sizeToFit(:FitType)`](#sizeToFit) can be added to your custom NSView subclasses. Just make those views conform to the `SizeCalculable` protocol and implement the two required functions.
Copy link
Member

Choose a reason for hiding this comment

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

Nice 👍

@lucdion lucdion merged commit 191a818 into layoutBox:master Jun 26, 2018
@antoinelamy antoinelamy deleted the feature/CALayer branch June 27, 2018 13:08
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.

2 participants