[ASTableNode/ASCollectionNode] Inversion#2891
[ASTableNode/ASCollectionNode] Inversion#2891Adlai-Holler merged 6 commits intofacebookarchive:masterfrom
Conversation
|
Thank you for including a sample project and documentation @aaronschubert0! |
Adlai-Holler
left a comment
There was a problem hiding this comment.
Thanks for a diff! This technique is super-powerful so it'll be great to support natively.
| - (void)setInverted:(BOOL)inverted | ||
| { | ||
| self.view.dataController.inverted = inverted; | ||
| self.transform = inverted ? CATransform3DMakeRotation(M_PI, 0, 0, 1.0) : CATransform3DIdentity; |
There was a problem hiding this comment.
Let's use CATransform3DMakeScale(1, -1, 1) instead of rotation. It's cleaner because π can't be represented perfectly.
There was a problem hiding this comment.
Awesome, will change it to that, thanks.
| } | ||
|
|
||
| if (_inverted) { | ||
| context.node.transform = CATransform3DMakeRotation(M_PI, 0, 0, 1.0); |
There was a problem hiding this comment.
It might be better to put this code in -[ASCollectionView/ASTableView dataController:nodeBlockAtIndexPath:] near the bottom along with the other customization that gets applied to the node, so that it's run exactly once per node, so the data controller doesn't have to be aware of the inversion.
There was a problem hiding this comment.
Yeah that makes sense, I had opted to avoid this initially so that I didn't have to duplicate code, but for the sake of two extra lines of code, it would feel nice not to have the ASDataController be involved.
|
Jenkins, test this please |
|
Build error: |
|
@Adlai-Holler Made those changes! |
|
+1 For this. |
1 similar comment
|
+1 For this. |
|
+1 For this. good job |
|
Jenkins, add to whitelist |
| - (void)setInverted:(BOOL)inverted | ||
| { | ||
| self.view.inverted = inverted; | ||
| self.transform = inverted ? CATransform3DMakeScale(1, -1, 1) : CATransform3DIdentity; |
There was a problem hiding this comment.
We need to implement this flag the same way we implement delegate – pass to the pending state or to the view, and that'll make the unused _inverted ivar disappear.
|
+1 |
|
@Adlai-Holler Added the logic to the pending state instead, should be good to go now. |
| ASDisplayNodeAssert([self isNodeLoaded], @"ASCollectionNode should be loaded if pendingState doesn't exist"); | ||
| self.view.inverted = inverted; | ||
| } | ||
| } |
There was a problem hiding this comment.
You'll need to override the accessor - (BOOL)inverted as well (see -delegate). The idea is to get rid of the synthesized _inverted ivar, because it's not used and that's making the compiler 💣
There was a problem hiding this comment.
Gotcha, I've added the accessor
|
Awesome, thanks! Here we go folks! |
Implements #2837 on ASTableNode and ASCollectionNode. I've tried to keep the API minimal. Also added an example app, since the user will have to adjust the contentInset of their ASTable/CollectionNode for the inversion to work properly.
Documentation: AsyncDisplayKit/Documentation#78
@appleguy