-
Notifications
You must be signed in to change notification settings - Fork 144
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
Conversation
@@ -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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do :)
Tests/Common/CALayerSpec.swift
Outdated
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))) | ||
} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will also do :)
Tests/Common/CALayerSpec.swift
Outdated
// | ||
describe("test CALayer interface") { | ||
it("basic pinlayout calls") { | ||
aLayer.pin.top(10).left(10).width(20%).height(80%).layout() |
There was a problem hiding this comment.
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()
?
There was a problem hiding this comment.
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.
…ll instead of an exact number of calls
There was a problem hiding this 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍
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.