Skip to content

Commit

Permalink
Adjust index path for cell reuseid in carouselview (#15140)
Browse files Browse the repository at this point in the history
* Adjust index path for cell reuseid in carouselview

Since CarouselView uses a fake number of items for looping effect like android does, we also need to correct the index used in the base items controller to be the actual item index, not the looped one.

* Fix return

* Remove ifdef for net8, we are net8

This was also masking the public api txt warnings, but have added the unshipped api's as well.
  • Loading branch information
Redth authored and rmarinho committed May 30, 2023
1 parent b8641b6 commit d415381
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,7 @@ public override void UpdateItemsSource()

protected override UICollectionViewDelegateFlowLayout CreateDelegator() => new CarouselViewDelegator(ItemsViewLayout, this);

#if NET8_0_OR_GREATER
[Obsolete("Use DetermineCellReuseId(NSIndexPath indexPath) instead.")]
#endif
protected override string DetermineCellReuseId()
{
if (Carousel.ItemTemplate != null)
Expand All @@ -146,6 +144,12 @@ protected override string DetermineCellReuseId()
return base.DetermineCellReuseId();
}

protected override string DetermineCellReuseId(NSIndexPath indexPath)
{
var itemIndex = GetIndexFromIndexPath(indexPath);
return base.DetermineCellReuseId(NSIndexPath.FromItemSection(itemIndex, 0));
}

protected override void RegisterViewTypes()
{
CollectionView.RegisterClassForCell(typeof(CarouselTemplatedCell), CarouselTemplatedCell.ReuseId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,7 @@ protected virtual void CacheCellAttributes(NSIndexPath indexPath, CGSize size)
}
}

#if NET8_0_OR_GREATER
protected
#else
internal
#endif
virtual string DetermineCellReuseId(NSIndexPath indexPath)
protected virtual string DetermineCellReuseId(NSIndexPath indexPath)
{
if (ItemsView.ItemTemplate != null)
{
Expand All @@ -373,9 +368,7 @@ virtual string DetermineCellReuseId(NSIndexPath indexPath)
: VerticalDefaultCell.ReuseId;
}

#if NET8_0_OR_GREATER
[Obsolete("Use DetermineCellReuseId(NSIndexPath indexPath) instead.")]
#endif
protected virtual string DetermineCellReuseId()
{
if (ItemsView.ItemTemplate != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ static Microsoft.Maui.Controls.Shapes.Matrix.operator ==(Microsoft.Maui.Controls
override Microsoft.Maui.Controls.View.ChangeVisualState() -> void
Microsoft.Maui.Controls.Handlers.BoxViewHandler
Microsoft.Maui.Controls.Handlers.BoxViewHandler.BoxViewHandler() -> void
~override Microsoft.Maui.Controls.Handlers.Items.CarouselViewController.DetermineCellReuseId(Foundation.NSIndexPath indexPath) -> string
~override Microsoft.Maui.Controls.ImageButton.OnPropertyChanged(string propertyName = null) -> void
~override Microsoft.Maui.Controls.Handlers.Compatibility.PhoneFlyoutPageRenderer.ViewWillTransitionToSize(CoreGraphics.CGSize toSize, UIKit.IUIViewControllerTransitionCoordinator coordinator) -> void
~override Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRootRenderer.TraitCollectionDidChange(UIKit.UITraitCollection previousTraitCollection) -> void
Expand Down Expand Up @@ -90,4 +91,5 @@ Microsoft.Maui.Controls.IValueConverter.Convert(object? value, System.Type! targ
Microsoft.Maui.Controls.IValueConverter.ConvertBack(object? value, System.Type! targetType, object? parameter, System.Globalization.CultureInfo! culture) -> object?
~static Microsoft.Maui.Controls.GridExtensions.Add(this Microsoft.Maui.Controls.Grid grid, Microsoft.Maui.IView view, int left, int right, int top, int bottom) -> void
~static Microsoft.Maui.Controls.GridExtensions.AddWithSpan(this Microsoft.Maui.Controls.Grid grid, Microsoft.Maui.IView view, int row = 0, int column = 0, int rowSpan = 1, int columnSpan = 1) -> void
*REMOVED*override Microsoft.Maui.Controls.Handlers.Compatibility.PhoneFlyoutPageRenderer.WillRotate(UIKit.UIInterfaceOrientation toInterfaceOrientation, double duration) -> void
*REMOVED*override Microsoft.Maui.Controls.Handlers.Compatibility.PhoneFlyoutPageRenderer.WillRotate(UIKit.UIInterfaceOrientation toInterfaceOrientation, double duration) -> void
~virtual Microsoft.Maui.Controls.Handlers.Items.ItemsViewController<TItemsView>.DetermineCellReuseId(Foundation.NSIndexPath indexPath) -> string
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ static Microsoft.Maui.Controls.Shapes.Matrix.operator ==(Microsoft.Maui.Controls
override Microsoft.Maui.Controls.View.ChangeVisualState() -> void
Microsoft.Maui.Controls.Handlers.BoxViewHandler
Microsoft.Maui.Controls.Handlers.BoxViewHandler.BoxViewHandler() -> void
~override Microsoft.Maui.Controls.Handlers.Items.CarouselViewController.DetermineCellReuseId(Foundation.NSIndexPath indexPath) -> string
~override Microsoft.Maui.Controls.ImageButton.OnPropertyChanged(string propertyName = null) -> void
~override Microsoft.Maui.Controls.Handlers.Compatibility.PhoneFlyoutPageRenderer.ViewWillTransitionToSize(CoreGraphics.CGSize toSize, UIKit.IUIViewControllerTransitionCoordinator coordinator) -> void
~override Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRootRenderer.TraitCollectionDidChange(UIKit.UITraitCollection previousTraitCollection) -> void
Expand Down Expand Up @@ -90,4 +91,5 @@ Microsoft.Maui.Controls.IValueConverter.Convert(object? value, System.Type! targ
Microsoft.Maui.Controls.IValueConverter.ConvertBack(object? value, System.Type! targetType, object? parameter, System.Globalization.CultureInfo! culture) -> object?
~static Microsoft.Maui.Controls.GridExtensions.Add(this Microsoft.Maui.Controls.Grid grid, Microsoft.Maui.IView view, int left, int right, int top, int bottom) -> void
~static Microsoft.Maui.Controls.GridExtensions.AddWithSpan(this Microsoft.Maui.Controls.Grid grid, Microsoft.Maui.IView view, int row = 0, int column = 0, int rowSpan = 1, int columnSpan = 1) -> void
*REMOVED*override Microsoft.Maui.Controls.Handlers.Compatibility.PhoneFlyoutPageRenderer.WillRotate(UIKit.UIInterfaceOrientation toInterfaceOrientation, double duration) -> void
*REMOVED*override Microsoft.Maui.Controls.Handlers.Compatibility.PhoneFlyoutPageRenderer.WillRotate(UIKit.UIInterfaceOrientation toInterfaceOrientation, double duration) -> void
~virtual Microsoft.Maui.Controls.Handlers.Items.ItemsViewController<TItemsView>.DetermineCellReuseId(Foundation.NSIndexPath indexPath) -> string

0 comments on commit d415381

Please sign in to comment.