Skip to content

Commit 953971b

Browse files
committed
Re-fixed the issue7678_1 based on conflicts file
1 parent af51be2 commit 953971b

File tree

2 files changed

+26
-17
lines changed

2 files changed

+26
-17
lines changed

src/Controls/src/Core/Handlers/Items2/ItemsViewHandler2.iOS.cs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -161,23 +161,7 @@ NSIndexPath DetermineIndex(ScrollToRequestEventArgs args)
161161

162162
protected bool IsIndexPathValid(NSIndexPath indexPath)
163163
{
164-
if (indexPath.Item < 0 || indexPath.Section < 0)
165-
{
166-
return false;
167-
}
168-
169-
var collectionView = Controller.CollectionView;
170-
if (indexPath.Section >= collectionView.NumberOfSections())
171-
{
172-
return false;
173-
}
174-
175-
if (indexPath.Item >= collectionView.NumberOfItemsInSection(indexPath.Section))
176-
{
177-
return false;
178-
}
179-
180-
return true;
164+
return LayoutFactory2.IsIndexPathValid(indexPath, Controller.CollectionView);
181165
}
182166

183167
public override Size GetDesiredSize(double widthConstraint, double heightConstraint)

src/Controls/src/Core/Handlers/Items2/iOS/LayoutFactory2.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,11 @@ public static UICollectionViewLayout CreateCarouselLayout(
376376

377377
var goToIndexPath = cv2Controller.GetScrollToIndexPath(carouselPosition);
378378

379+
if (!IsIndexPathValid(goToIndexPath, cv2Controller.CollectionView))
380+
{
381+
return;
382+
}
383+
379384
//This will move the carousel to fake the loop
380385
cv2Controller.CollectionView.ScrollToItem(
381386
NSIndexPath.FromItemSection(pageIndex, 0),
@@ -394,6 +399,26 @@ public static UICollectionViewLayout CreateCarouselLayout(
394399
return layout;
395400
}
396401
#nullable enable
402+
403+
public static bool IsIndexPathValid(NSIndexPath indexPath, UICollectionView collectionView)
404+
{
405+
if (indexPath.Item < 0 || indexPath.Section < 0)
406+
{
407+
return false;
408+
}
409+
410+
if (indexPath.Section >= collectionView.NumberOfSections())
411+
{
412+
return false;
413+
}
414+
415+
if (indexPath.Item >= collectionView.NumberOfItemsInSection(indexPath.Section))
416+
{
417+
return false;
418+
}
419+
420+
return true;
421+
}
397422
class CustomUICollectionViewCompositionalLayout : UICollectionViewCompositionalLayout
398423
{
399424
LayoutSnapInfo _snapInfo;

0 commit comments

Comments
 (0)