Skip to content

Commit 5e4a5b7

Browse files
committed
- add interface to WrapperView and move to ext method
1 parent 899cf74 commit 5e4a5b7

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

src/Core/src/Platform/iOS/MauiScrollView.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public override void LayoutSubviews()
4444
// imposed by the parent (i.e. scroll view) with the current bounds.
4545
// But we _do_ need LayoutSubviews to make a measurement pass if the parent is something else (for example,
4646
// the window); there's no guarantee that SizeThatFits has been called in that case.
47-
if (!IsMeasureValid(widthConstraint, heightConstraint) && Superview is not ICrossPlatformLayoutBacking)
47+
if (!IsMeasureValid(widthConstraint, heightConstraint) && !this.IsFinalMeasureHandledBySuperView())
4848
{
4949
crossPlatformLayout.CrossPlatformMeasure(widthConstraint, heightConstraint);
5050
CacheMeasureConstraints(widthConstraint, heightConstraint);

src/Core/src/Platform/iOS/MauiView.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public override void LayoutSubviews()
131131
// imposed by the parent (i.e. scroll view) with the current bounds.
132132
// But we _do_ need LayoutSubviews to make a measurement pass if the parent is something else (for example,
133133
// the window); there's no guarantee that SizeThatFits has been called in that case.
134-
if (!IsMeasureValid(widthConstraint, heightConstraint) && Superview is not ICrossPlatformLayoutBacking)
134+
if (!IsMeasureValid(widthConstraint, heightConstraint) && !this.IsFinalMeasureHandledBySuperView())
135135
{
136136
CrossPlatformMeasure(widthConstraint, heightConstraint);
137137
CacheMeasureConstraints(widthConstraint, heightConstraint);

src/Core/src/Platform/iOS/ViewExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,5 +945,7 @@ internal static float GetDisplayDensity(this UIView? view) =>
945945
internal static bool ShowSoftInput(this UIView inputView) => inputView.BecomeFirstResponder();
946946

947947
internal static bool IsSoftInputShowing(this UIView inputView) => inputView.IsFirstResponder;
948+
949+
internal static bool IsFinalMeasureHandledBySuperView(this UIView? view) => view?.Superview is ICrossPlatformLayoutBacking { CrossPlatformLayout: not null };
948950
}
949951
}

src/Core/src/Platform/iOS/WrapperView.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,22 @@
99

1010
namespace Microsoft.Maui.Platform
1111
{
12-
public partial class WrapperView : UIView, IDisposable, IUIViewLifeCycleEvents
12+
public partial class WrapperView : UIView, IDisposable, IUIViewLifeCycleEvents, ICrossPlatformLayoutBacking
1313
{
1414
bool _fireSetNeedsLayoutOnParentWhenWindowAttached;
1515
WeakReference<ICrossPlatformLayout>? _crossPlatformLayoutReference;
1616

17-
internal ICrossPlatformLayout? CrossPlatformLayout
17+
ICrossPlatformLayout? ICrossPlatformLayoutBacking.CrossPlatformLayout
1818
{
1919
get => _crossPlatformLayoutReference != null && _crossPlatformLayoutReference.TryGetTarget(out var v) ? v : null;
2020
set => _crossPlatformLayoutReference = value == null ? null : new WeakReference<ICrossPlatformLayout>(value);
2121
}
22+
23+
internal ICrossPlatformLayout? CrossPlatformLayout
24+
{
25+
get => ((ICrossPlatformLayoutBacking)this).CrossPlatformLayout;
26+
set => ((ICrossPlatformLayoutBacking)this).CrossPlatformLayout = value;
27+
}
2228

2329
double _lastMeasureHeight = double.NaN;
2430
double _lastMeasureWidth = double.NaN;

0 commit comments

Comments
 (0)