-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[iOS] Figure a better EstimatedItemSize for HorizontalList #20022
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
Conversation
yes @tj-devel709 that's it, when we have just a couple of items, the estimated size (1st item) is smaller than other cells that will be visible it will take that space. |
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.
Looking OK. I have some questions because my iOS CollectionView knowledge is weak. Also, I am wondering if the test really does catch this type of case.
/rebase |
c410e5b
to
927129c
Compare
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 have to cover aspects such as grouping, etc. but I see that we have another open issue for this.
* [Samples] Add repro case for issue #15815 * [iOS] Remove dead code * [iOS] Try find a better EstimatedItemSize for horizontal list * [uitest] Add Uitest for CollectionView * Fix test * Pink color
* [Samples] Add repro case for issue #15815 * [iOS] Remove dead code * [iOS] Try find a better EstimatedItemSize for horizontal list * [uitest] Add Uitest for CollectionView * Fix test * Pink color
Description of Change
When we have Items with different width or height users should use
MeasureAllItems
for that we rely on AutoLayout of CollectionView . This works by setting the EstimatedItemSize to some value other then empty.We use the 1st cell as the prototype to be measured and use as
EstimatedItemSize
, but the problem that we see here, is that cell size is the smalles compared with the other cells that haver a wider width. When CollectionView is calculating the ContentSize, it use the EstimatedItemSize and multiplies by the number of items of the section. IF the EstimatedItemSize is very small the ContentSize can hide items in the end of the collection. This is special an issue if we have a couple of items on the List.I can't reproduce this on VerticalList so I m not sure if this is or not a issue with how UICollectionView and EstimatedItemSize. Because the idea is even if we give it a "estimated size" if should call each item to get the real value (and it does) but to does not update the initial calculate ContentSize We have seen other issues with horizontal scroll on UICollectionView so im not sure if this is also a bug related with that or not.
The fix here is simple, try to find the wider cell from the ones that are going to maybe be visible on the screen. That way the EstimatedItemSize will return a value that will fit all the cells.
Still need to write a test.
Issues Fixed
Fixes #15815