-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[ASLayoutSpec] Added new Relative position layout spec #1098
Conversation
cc @rcancro, @nguyenhuy |
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.
How about ASRelativePositionLayoutSpecPosition**Start**
and ASRelativePositionLayoutSpecPosition**End**
. We have been using "start" and "end" for similar purposes, for example in ASStackLayoutJustifyContent
, ASStackLayoutAlignItems
, etc.
P/S: I've just realized that we should use the same convention for ASHorizontalAlignment
and ASVerticalAlignment
. Will make an issue/PR for it.
@stowy: Awesome spec that puts center spec to shame! I'm wondering about what we should do to center spec once this one is accepted. Should we deprecate/remove it? or make it a subclass of this one? |
Regarding testing, we write snapshot test cases for layout specs. Check Thanks a lot for contributing to ASDK 👍 |
On the name of this new spec, I think |
Thanks @nguyenhuy for the comments, will revise. I will checkout the snapshot tests also. |
@nguyenhuy I've added the snapshot test cases, hopefully the build should pass and we're all set. |
When first introduce the tests, you need to enable record mode ( |
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.
Please fix indentation.
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.
Friendly reminder: please fix indentation.
@nguyenhuy, thanks for your help. In running tests in record mode, does that mean the tests need to run in record mode on every build machine? Is there more than one build machine? I ran in record mode once but I got the resource not found error after turning it off, would that be because the tests ran on a different machine? Or the record mode didn't run properly the first time? |
Sorry for the confusion. First, on your local machine, you need to run those test cases with record mode enabled. This will generate a bunch of reference images. Turn off record mode, commit those images to the repo and push it. Once available, those images will be picked up to test against by other machines. Here is an example of a PR that adds new snapshot test cases and reference images. |
Oh right yes I had run them on my machine but didn't realise I had to Easy done, thanks.
|
@nguyenhuy I've added the images to the repo but seeing the following failure:
Any idea why it is looking under 'AsyncDisplayKitTests/ReferenceImages_32' instead of 'AsyncDisplayKitTests/ReferenceImages_64'? I don't see any other snapshot images in the _32 folder. |
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.
Nit: newline at the end of file
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.
I've added the new line.
@stowy: Great. Nits aside, I think this PR is ready to land. Regarding missing reference images for 32bit, I'm not entirely sure if we can force machines to always run tests on 64bit simulators, or ask it to look for images in 64bit directory. Maybe having the same set of images for both architectures is not a bad idea at all. |
@nguyenhuy have addressed the last comments now I believe |
Great. Looks good to me! |
Thanks for your review and help @nguyenhuy, i enjoyed learning the snapshot tests process! |
@stowy @nguyenhuy thanks a lot for working together to refine this and make it production ready, especially including tests! @Adlai-Holler, @RCacheaux, @lappp9, @rcancro, @levi what do you guys think we should do with the center layout spec? Keep it as is? Make it a special case built on top of this? Delete it entirely? Is there any more descriptive name for this class than Relative, especially because there is a relative type of dimension that doesn't relate to the alignment features of this class? |
This is great! I will put it to good use for sure! Unless we can come up with a better name let's keep center layout spec and update its implementation to use this behind the scenes. My rationale is that it's a common use case and as a newcomer to the framework definitely would not think to look at ASRelativeLayoutSpec. I think the clarity is worth the slight redundancy. |
@stowy Do you have time to fix conflicts in this PR and update ASCenterLayoutSpec to use this new spec behind the scenes? I really want to see this merged soon. Thanks! |
Hey Huy, sure sorry I wasn't aware of that work. I'll get onto it in the
|
# Conflicts: # AsyncDisplayKit.xcodeproj/project.pbxproj
@nguyenhuy I've revised the Let me know if you're happy with the latest approach. |
@nguyenhuy @appleguy is there anything outstanding for this or is it good to go? |
return [_internalLayoutSpec children]; | ||
} | ||
|
||
- (ASRelativeLayoutSpecPosition)horizontalPositionFromCenteringOptions:(ASCenterLayoutSpecCenteringOptions)centeringOptions { |
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.
{ on new line for both of these methods
@stowy now that the new version of Pinterest has been branched for a little while, I am finally catching up here. Nonetheless, more conflicts had arisen, so I created a new branch to rebase and squash these commits. The resulting commit, even with my additional changes, still comes from you as the author :). Much-deserved, given the thoughtfulness and care you put it into expanding the core framework functionality for others to enjoy! |
@appleguy here is the new layout spec I wrote, based very much on the ASCenterLayoutSpec but with more versatility / functionality. Would be useful for example for my badge node in the cat sample, to position the badge in the bottom left or bottom right of the image, depending on RTL.
Haven't added any tests for it, not familiar with how they are implemented here.