Skip to content

Commit 64d216b

Browse files
committed
Re-fixed the issue7678_1 based on conflicts file
1 parent d0ba28a commit 64d216b

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
@@ -375,6 +375,11 @@ public static UICollectionViewLayout CreateCarouselLayout(
375375

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

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

0 commit comments

Comments
 (0)