Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 19 additions & 22 deletions src/Controls/src/Core/Handlers/Items/CarouselViewHandler.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public static void MapIsBounceEnabled(CarouselViewHandler handler, CarouselView

public static void MapPeekAreaInsets(CarouselViewHandler handler, CarouselView carouselView)
{
(handler.Controller.Layout as CarouselViewLayout)?.UpdateConstraints(handler.PlatformView.Frame.Size);
handler.Controller.Layout.InvalidateLayout();
}

Expand All @@ -72,34 +73,30 @@ public static void MapLoop(CarouselViewHandler handler, CarouselView carouselVie

public override Size GetDesiredSize(double widthConstraint, double heightConstraint)
{
// I'm not sure if this solution is fully correct or if it properly accounts
// for all the constraints checks that GetDesiredSizeFromHandler takes into account
if (Primitives.Dimension.IsExplicitSet(widthConstraint) && Primitives.Dimension.IsExplicitSet(heightConstraint))
var size = this.GetDesiredSizeFromHandler(widthConstraint, heightConstraint);

if (OperatingSystem.IsMacCatalystVersionAtLeast(11))
{
// If both width and height are explicitly set, we can use the base implementation
return base.GetDesiredSize(widthConstraint, heightConstraint);
}
// Ensure size never exceeds constraints.
// In the 22417 test sample on Mac, if widthConstraint is 1085, it becomes 1512 after the SizeThatFits call
// inside ViewHandlerExtensions.iOS. This causes the view's width to appear larger on Mac.
// On iOS, the value remains correct — for example, if widthConstraint is 375, SizeThatFits also returns 375.
// This issue happened on Main also.

var result = this.GetDesiredSizeFromHandler(widthConstraint, heightConstraint);
if (!double.IsInfinity(widthConstraint) && size.Width > widthConstraint)
{
size.Width = (float)widthConstraint;
}

if (!double.IsInfinity(heightConstraint) && size.Height > heightConstraint)
{
size.Height = (float)heightConstraint;
}

if (Primitives.Dimension.IsExplicitSet(widthConstraint))
{
// If width is explicitly set, we can use the width from the result
result = new Size(widthConstraint, result.Height);
}
else if (Primitives.Dimension.IsExplicitSet(heightConstraint))
{
// If height is explicitly set, we can use the height from the result
result = new Size(result.Width, heightConstraint);
}

return result;
}
return size;

public override void PlatformArrange(Rect rect)
{
(Controller.Layout as CarouselViewLayout)?.UpdateConstraints(rect.Size);
base.PlatformArrange(rect);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#nullable enable
override Microsoft.Maui.Controls.ContentPresenter.OnSizeAllocated(double width, double height) -> void
override Microsoft.Maui.Controls.Handlers.Items.CarouselViewHandler.PlatformArrange(Microsoft.Maui.Graphics.Rect rect) -> void
override Microsoft.Maui.Controls.ScrollView.OnSizeAllocated(double width, double height) -> void
override Microsoft.Maui.Controls.TemplatedView.OnSizeAllocated(double width, double height) -> void
virtual Microsoft.Maui.Controls.BindableProperty.CreateDefaultValueDelegate<TDeclarer, TPropertyType>.Invoke(TDeclarer bindable) -> TPropertyType
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#nullable enable
override Microsoft.Maui.Controls.ContentPresenter.OnSizeAllocated(double width, double height) -> void
override Microsoft.Maui.Controls.Handlers.Items.CarouselViewHandler.PlatformArrange(Microsoft.Maui.Graphics.Rect rect) -> void
override Microsoft.Maui.Controls.ScrollView.OnSizeAllocated(double width, double height) -> void
override Microsoft.Maui.Controls.TemplatedView.OnSizeAllocated(double width, double height) -> void
virtual Microsoft.Maui.Controls.BindableProperty.CreateDefaultValueDelegate<TDeclarer, TPropertyType>.Invoke(TDeclarer bindable) -> TPropertyType
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if TEST_FAILS_ON_WINDOWS && TEST_FAILS_ON_CATALYST //This test is failing, likely due to product issue, for more information: https://github.com/dotnet/maui/issues/27059
#if TEST_FAILS_ON_WINDOWS //This test is failing, likely due to product issue, for more information: https://github.com/dotnet/maui/issues/27059
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;
Expand Down
7 changes: 5 additions & 2 deletions src/Core/src/Platform/iOS/MauiView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public abstract class MauiView : UIView, ICrossPlatformLayoutBacking, IVisualTre
SafeAreaPadding _safeArea = SafeAreaPadding.Empty;
bool _safeAreaInvalidated = true;
bool _appliesSafeAreaAdjustments;


WeakReference<IView>? _reference;
WeakReference<ICrossPlatformLayout>? _crossPlatformLayoutReference;
Expand Down Expand Up @@ -163,6 +163,9 @@ public override void LayoutSubviews()
// to let ancestors adjust to the measured size.
if (this.IsFinalMeasureHandledBySuperView())
{
//This arrangement step is essential for communicating the correct coordinate space to native iOS views before scheduling the second layout pass.
//This ensures the native view is aware of the correct bounds and can adjust its layout accordingly.
CrossPlatformArrange(Bounds.ToRectangle());
SetNeedsLayout();
this.InvalidateAncestorsMeasures();
return;
Expand Down Expand Up @@ -215,7 +218,7 @@ bool ValidateSafeArea()

// Return whether the way safe area interacts with our view has changed
return oldApplyingSafeAreaAdjustments == _appliesSafeAreaAdjustments &&
(oldSafeArea == _safeArea || !_appliesSafeAreaAdjustments);
(oldSafeArea == _safeArea || !_appliesSafeAreaAdjustments);
}

IVisualTreeElement? IVisualTreeElementProvidable.GetElement()
Expand Down