diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue35214.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue35214.cs new file mode 100644 index 000000000000..0c46febb7811 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue35214.cs @@ -0,0 +1,62 @@ +namespace Maui.Controls.Sample.Issues; + +[Issue(IssueTracker.Github, 35214, "Dynamically changing IndicatorView IndicatorSize to default value does not work", PlatformAffected.iOS | PlatformAffected.macOS)] +public class Issue35214 : ContentPage +{ + public Issue35214() + { + var carouselItems = new List { "Item 0", "Item 1", "Item 2" }; + + var indicatorView = new IndicatorView + { + AutomationId = "TestIndicatorView", + HorizontalOptions = LayoutOptions.Center, + IndicatorColor = Colors.Orange, + SelectedIndicatorColor = Colors.Blue, + IndicatorSize = 20, + }; + + var carouselView = new CarouselView + { + ItemsSource = carouselItems, + HeightRequest = 300, + HorizontalOptions = LayoutOptions.Fill, + IndicatorView = indicatorView, + ItemTemplate = new DataTemplate(() => + { + var label = new Label + { + VerticalOptions = LayoutOptions.Center, + HorizontalOptions = LayoutOptions.Center, + FontSize = 18, + }; + label.SetBinding(Label.TextProperty, "."); + return label; + }), + }; + + var setDefaultSizeButton = new Button + { + AutomationId = "SetDefaultSizeButton", + Text = "Set IndicatorSize = 6 (Default)", + Margin = new Thickness(0, 20, 0, 0) + }; + + setDefaultSizeButton.Clicked += (s, e) => + { + indicatorView.IndicatorSize = 6; + }; + + Content = new VerticalStackLayout + { + Padding = 20, + Spacing = 10, + Children = + { + carouselView, + indicatorView, + setDefaultSizeButton, + } + }; + } +} diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue35214.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue35214.cs new file mode 100644 index 000000000000..7eae2e5404f1 --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue35214.cs @@ -0,0 +1,31 @@ +using NUnit.Framework; +using UITest.Appium; +using UITest.Core; + +namespace Microsoft.Maui.TestCases.Tests.Issues; + +public class Issue35214 : _IssuesUITest +{ + public Issue35214(TestDevice device) : base(device) + { + } + + public override string Issue => "Dynamically changing IndicatorView IndicatorSize to default value does not work"; + + [Test, Order(1)] + [Category(UITestCategories.IndicatorView)] + public void VerifyIndicatorSizeBeforeReset() + { + App.WaitForElement("TestIndicatorView"); + VerifyScreenshot("IndicatorSizeBeforeReset", retryTimeout: TimeSpan.FromSeconds(2)); + } + + [Test, Order(2)] + [Category(UITestCategories.IndicatorView)] + public void VerifyIndicatorSizeAfterReset() + { + App.WaitForElement("SetDefaultSizeButton"); + App.Tap("SetDefaultSizeButton"); + VerifyScreenshot("IndicatorSizeAfterReset", retryTimeout: TimeSpan.FromSeconds(2)); + } +} diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/IndicatorSizeAfterReset.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/IndicatorSizeAfterReset.png new file mode 100644 index 000000000000..12905a9942b3 Binary files /dev/null and b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/IndicatorSizeAfterReset.png differ diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/IndicatorSizeBeforeReset.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/IndicatorSizeBeforeReset.png new file mode 100644 index 000000000000..a696b0684df2 Binary files /dev/null and b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/IndicatorSizeBeforeReset.png differ diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/IndicatorSizeAfterReset.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/IndicatorSizeAfterReset.png new file mode 100644 index 000000000000..12905a9942b3 Binary files /dev/null and b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/IndicatorSizeAfterReset.png differ diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/IndicatorSizeBeforeReset.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/IndicatorSizeBeforeReset.png new file mode 100644 index 000000000000..a696b0684df2 Binary files /dev/null and b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/IndicatorSizeBeforeReset.png differ diff --git a/src/Core/src/Platform/iOS/MauiPageControl.cs b/src/Core/src/Platform/iOS/MauiPageControl.cs index 97ba453ebcfc..ff660f32f90e 100644 --- a/src/Core/src/Platform/iOS/MauiPageControl.cs +++ b/src/Core/src/Platform/iOS/MauiPageControl.cs @@ -13,7 +13,7 @@ public class MauiPageControl : UIPageControl, IUIViewLifeCycleEvents WeakReference? _indicatorView; bool _updatingPosition; - double _lastAppliedIndicatorSize = -1; + double _lastAppliedIndicatorSize = DefaultIndicatorSize; public MauiPageControl() { @@ -65,7 +65,7 @@ public override void LayoutSubviews() public void UpdateIndicatorSize() { - if (IndicatorSize == 0 || IndicatorSize == DefaultIndicatorSize) + if (IndicatorSize == 0 || IndicatorSize == _lastAppliedIndicatorSize) return; if (Math.Abs(IndicatorSize - _lastAppliedIndicatorSize) < IndicatorSizeTolerance)