maui
maui copied to clipboard
[iOS] Fix for Single item alignment issue in CollectionView HorizontalGrid Layout
Root Cause of the issue
The CollectionView seems to centre the item if only one exists. We had already adjusted the HorizontalAlignment for the VerticalGrid layout when a single element was in view. However, we missed making the same adjustment for the HorizontalGrid layout.
Description of Change
I have applied the same adjustment to the horizontal grid layout as was done for the vertical grid layout.
Issues Fixed
Fixes #25181
Tested the behaviour in the following platforms
- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac
Screenshot
| Before Issue Fix | After Issue Fix |
|---|---|
Hey there @Tamilarasan-Paranthaman! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.
/azp run
Azure Pipelines successfully started running 3 pipeline(s).
/rebase
/rebase
SingleItemAlignmentInCollectionViewHorizontalGridLayout is failing
@PureWeen, I added this test for this issue. There seems to be a slight difference between the previously committed image and the current one generated by the CI. However, the current image is correct, so I have committed it.
/azp run
Azure Pipelines successfully started running 3 pipeline(s).
/rebase
/rebase
/azp run
Azure Pipelines successfully started running 3 pipeline(s).
The test is failing for CV1 seems the layout is expanding below the status bar and we cut that off for the test ? or do we need to regenerate images?
Original screenshot full screen
@rmarinho, Yes, it is expanding below the status bar, and it seems the CI did not account for that space. I have modified the test sample to address this by wrapping the CollectionView in a StackLayout, and it now passes both CV1 and CV2 on my end. Could you please review it and let me know if you have any concerns?
Nop wrapping a CollectionView on a StackLayout is not a good practice. Try use a Grid instead.
Nop wrapping a CollectionView on a StackLayout is not a good practice. Try use a Grid instead.
@rmarinho, thank you for pointing this out! I have replaced the StackLayout with a Grid as suggested, and it worked as expected during my testing. Could you please check and let me know if you have any further concerns?
/azp run
Azure Pipelines successfully started running 3 pipeline(s).

