diff --git a/src/Controls/src/Core/Handlers/Items/iOS/CarouselViewController.cs b/src/Controls/src/Core/Handlers/Items/iOS/CarouselViewController.cs index efdeffbb634a..ba38514d11fc 100644 --- a/src/Controls/src/Core/Handlers/Items/iOS/CarouselViewController.cs +++ b/src/Controls/src/Core/Handlers/Items/iOS/CarouselViewController.cs @@ -32,6 +32,20 @@ public class CarouselViewController : ItemsViewController bool _isRotating; + public override void TraitCollectionDidChange(UITraitCollection previousTraitCollection) + { + if (previousTraitCollection.VerticalSizeClass == TraitCollection.VerticalSizeClass) + { + return; + } + + if (ItemsView?.Loop == false || _carouselViewLoopManager is null) + { + CollectionView.ReloadData(); + InitialPositionSet = false; + } + } + public CarouselViewController(CarouselView itemsView, ItemsViewLayout layout) : base(itemsView, layout) { CollectionView.AllowsSelection = false; diff --git a/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt index 8fd546ccbe70..055f1a71c005 100644 --- a/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt +++ b/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt @@ -68,6 +68,7 @@ Microsoft.Maui.Controls.HybridWebView.SetInvokeJavaScriptTarget(T! target) -> ~Microsoft.Maui.Controls.Xaml.IXamlTypeResolver.Resolve(string qualifiedTypeName, System.IServiceProvider serviceProvider = null, bool expandToExtension = true) -> System.Type ~Microsoft.Maui.Controls.Xaml.RequireServiceAttribute.RequireServiceAttribute(System.Type[] serviceTypes) -> void ~Microsoft.Maui.Controls.Xaml.RequireServiceAttribute.ServiceTypes.get -> System.Type[] +~override Microsoft.Maui.Controls.Handlers.Items.CarouselViewController.TraitCollectionDidChange(UIKit.UITraitCollection previousTraitCollection) -> void ~override Microsoft.Maui.Controls.Handlers.Items2.CarouselViewController2.CreateDelegator() -> UIKit.UICollectionViewDelegateFlowLayout ~override Microsoft.Maui.Controls.Handlers.Items2.CarouselViewController2.CreateItemsViewSource() -> Microsoft.Maui.Controls.Handlers.Items.IItemsViewSource ~override Microsoft.Maui.Controls.Handlers.Items2.CarouselViewController2.DetermineCellReuseId(Foundation.NSIndexPath indexPath) -> string diff --git a/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt index 6f7e75373a53..d4bc6e15e2d2 100644 --- a/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt +++ b/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt @@ -68,6 +68,7 @@ Microsoft.Maui.Controls.HybridWebView.SetInvokeJavaScriptTarget(T! target) -> ~Microsoft.Maui.Controls.Xaml.IXamlTypeResolver.Resolve(string qualifiedTypeName, System.IServiceProvider serviceProvider = null, bool expandToExtension = true) -> System.Type ~Microsoft.Maui.Controls.WebViewProcessTerminatedEventArgs.PlatformArgs.get -> Microsoft.Maui.Controls.PlatformWebViewProcessTerminatedEventArgs ~Microsoft.Maui.Controls.Xaml.RequireServiceAttribute.RequireServiceAttribute(System.Type[] serviceTypes) -> void +~override Microsoft.Maui.Controls.Handlers.Items.CarouselViewController.TraitCollectionDidChange(UIKit.UITraitCollection previousTraitCollection) -> void ~Microsoft.Maui.Controls.Xaml.RequireServiceAttribute.ServiceTypes.get -> System.Type[] ~override Microsoft.Maui.Controls.Handlers.Items2.CarouselViewController2.CreateDelegator() -> UIKit.UICollectionViewDelegateFlowLayout ~override Microsoft.Maui.Controls.Handlers.Items2.CarouselViewController2.CreateItemsViewSource() -> Microsoft.Maui.Controls.Handlers.Items.IItemsViewSource diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/CarouselViewItemShouldScaleProperly.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/CarouselViewItemShouldScaleProperly.png new file mode 100644 index 000000000000..daf55575bde6 Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/CarouselViewItemShouldScaleProperly.png differ diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue28523.xaml b/src/Controls/tests/TestCases.HostApp/Issues/Issue28523.xaml new file mode 100644 index 000000000000..fbb9db0a0240 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue28523.xaml @@ -0,0 +1,28 @@ + + + + + + + + + + + + Baboon + Capuchin Monkey + Blue Monkey + Squirrel Monkey + Golden Lion Tamarin + Howler Monkey + + + + \ No newline at end of file diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue28523.xaml.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue28523.xaml.cs new file mode 100644 index 000000000000..0836b66b0283 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue28523.xaml.cs @@ -0,0 +1,11 @@ +namespace Maui.Controls.Sample.Issues +{ + [Issue(IssueTracker.Github, 28523, "Different behavior on iOS and Android when Loop = False", PlatformAffected.iOS)] + public partial class Issue28523 : ContentPage + { + public Issue28523() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue28523.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue28523.cs new file mode 100644 index 000000000000..0af63c3a42af --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue28523.cs @@ -0,0 +1,25 @@ +#if ANDROID || IOS +using NUnit.Framework; +using UITest.Appium; +using UITest.Core; + +namespace Microsoft.Maui.TestCases.Tests.Issues; +public class Issue28523 : _IssuesUITest +{ + public Issue28523(TestDevice testDevice) : base(testDevice) + { + } + + public override string Issue => "Different behavior on iOS and Android when Loop = False"; + + [Test] + [Category(UITestCategories.CarouselView)] + public void CarouselViewItemShouldScaleProperly() + { + App.WaitForElement("Baboon"); + App.SetOrientationLandscape(); + App.WaitForElement("Baboon"); + VerifyScreenshot(); + } +} +#endif \ No newline at end of file diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/CarouselViewItemShouldScaleProperly.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/CarouselViewItemShouldScaleProperly.png new file mode 100644 index 000000000000..6f97047fc856 Binary files /dev/null and b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/CarouselViewItemShouldScaleProperly.png differ