-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[ASCollectionView] Fix index space translation of Flow Layout Delegate methods. #467
Conversation
…e methods. This includes a few other cleanups, including overflow of signed integer indices.
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 love it. Couple notes and then it'll be landing time.
Source/ASCollectionView.mm
Outdated
|
||
for (ASCollectionElement *element in self.dataController.pendingMap.itemElements) { | ||
ASCellNode *node = element.node; | ||
if (node.shouldUseUIKitCell) { |
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.
-
It's probably inconsequential, but maybe we should just ignore calls where the layout isn't a flow layout, rather than using size 0?
-
Instead of building a giant array – I don't really like the
itemElements
property and may propose removing it – it's better to enumerate the map directly andif (element.supplementaryElementKind) { continue; }
Note to self: add aUICollectionElementCategory elementCategory
property to ASCollectionElement to simplify this distinction. -
Shouldn't we also refetch header/footer reference sizes here? Meshes well with 2
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.
@Adlai-Holler some merge conflicts have arisen, and I'm afraid my time availability is nearing a local minimum. :( Do you think this PR is acceptable to land as-is if the conflicts are fixed?
- I think it's better to have the 0 default, but indeed maybe no one will ever know :)
- The iteration suggestion sounds like an improvement for sure. I'm not sure I can commit to doing it only because I would have to get some test cases running to exercise the change.
- This seems potentially important, and indeed might motivate me to do Test PR #2.
Could you give me an Accept if you are comfortable with this, and then if I do 2 or 3, I can land without waiting?
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.
@Adlai-Holler It took me a while, but I finally got around to implementing your advice — and went quite a bit further. Thanks for suggesting these things, as they are improvements.
In particular, I was intentionally skipping over handling the update of supplementary element sizes, which is not great. That's now fixed and the code is better factored.
If you or @nguyenhuy can give me a sanity check review soon, I'd appreciate that - would like to merge this in pretty soon.
} | ||
return ASFlowLayoutDefault(l, minimumInteritemSpacing, 10.0); // Default is documented as 10.0 | ||
} | ||
|
||
- (CGFloat)collectionView:(UICollectionView *)cv layout:(UICollectionViewLayout *)l | ||
minimumLineSpacingForSectionAtIndex:(NSInteger)section | ||
minimumLineSpacingForSectionAtIndex:(NSInteger)section |
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.
🙂
#define ASDisplayNodeCAssertPositiveReal(description, num) ASDisplayNodeCAssert(num >= 0 && num <= CGFLOAT_MAX, @"%@ must be a real positive integer.", description) | ||
#define ASDisplayNodeCAssertInfOrPositiveReal(description, num) ASDisplayNodeCAssert(isinf(num) || (num >= 0 && num <= CGFLOAT_MAX), @"%@ must be infinite or a real positive integer.", description) | ||
#define ASDisplayNodeCAssertPositiveReal(description, num) ASDisplayNodeCAssert(num >= 0 && num <= CGFLOAT_MAX, @"%@ must be a real positive integer: %f.", description, (CGFloat)num) | ||
#define ASDisplayNodeCAssertInfOrPositiveReal(description, num) ASDisplayNodeCAssert(isinf(num) || (num >= 0 && num <= CGFLOAT_MAX), @"%@ must be infinite or a real positive integer: %f.", description, (CGFloat)num) |
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.
🙌
🚫 CI failed with log |
…nsure delegate invalidation re-fetches supplementary sizes too.
3e4da91
to
e2a9ffb
Compare
…eForUIKitCellWithKind:atIndexPath: method.
Hmm, this erroneous test failure is striking again. ASCollectionViewTests
|
Thanks for reviewing and merging! |
…e methods. (TextureGroup#467) * [ASCollectionView] Fix index space translation of Flow Layout Delegate methods. This includes a few other cleanups, including overflow of signed integer indices. * [ASCollectionView] Improve code sharing of UIKit size method calls; ensure delegate invalidation re-fetches supplementary sizes too. * [ASCollectionView] Final method ordering and doc-comment for new _sizeForUIKitCellWithKind:atIndexPath: method.
This includes a few other cleanups, including overflow of signed integer indices.
It will take a couple PRs to fully sync both upstream and downstream in this case, but I am happy to integrate feedback along the way. Just a heads up that it may be easier to do in subsequent PRs, depending on the importance of changes (stylistic vs functional).