Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,15 @@ void UpdateScrim(Brush backdrop)
}
}

protected override void OnLayout(bool changed, int left, int top, int right, int bottom)
{
base.OnLayout(changed, left, top, right, bottom);

var destination = Context.ToCrossPlatformRectInReferenceFrame(left, top, right, bottom);
if (Shell.Frame != destination)
Shell.Frame = destination;
}

internal void Disconnect()
{
ShellController?.RemoveAppearanceObserver(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ public override void ViewDidLayoutSubviews()
base.ViewDidLayoutSubviews();
if (_currentShellItemRenderer != null)
_currentShellItemRenderer.ViewController.View.Frame = View.Bounds;

var destination = View.Bounds.ToRectangle();
if (Shell.Frame != destination)
Shell.Frame = destination;
}

public override void ViewDidLoad()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#nullable enable
override Microsoft.Maui.Controls.Platform.Compatibility.ShellFlyoutRenderer.OnLayout(bool changed, int left, int top, int right, int bottom) -> void
override Microsoft.Maui.Controls.Shapes.Shape.OnPropertyChanged(string? propertyName = null) -> void
~override Microsoft.Maui.Controls.Handlers.Items.MauiRecyclerView<TItemsView, TAdapter, TItemsViewSource>.OnInterceptTouchEvent(Android.Views.MotionEvent e) -> bool
~override Microsoft.Maui.Controls.Handlers.Items.MauiRecyclerView<TItemsView, TAdapter, TItemsViewSource>.OnTouchEvent(Android.Views.MotionEvent e) -> bool
26 changes: 26 additions & 0 deletions src/Controls/tests/DeviceTests/Elements/Shell/ShellTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,32 @@ await CreateHandlerAndAddToWindow<IWindowHandler>(shell, _ =>
});
}

[Fact]
public async Task SettingFrameDoesTriggerInvalidatedMeasure()
{
SetupBuilder();

int measureInvalidatedCount = 0;

var page = new ContentPage();
var shell = await CreateShellAsync(shell =>
{
shell.CurrentItem = new ShellContent { Content = page };
});

shell.MeasureInvalidated += (s, e) =>
{
measureInvalidatedCount++;
};

shell.Frame = new Microsoft.Maui.Graphics.Rect(0, 0, 100, 100);

await CreateHandlerAndAddToWindow<IWindowHandler>(shell, _ =>
{
Assert.Equal(1, measureInvalidatedCount);
});
}

protected Task<Shell> CreateShellAsync(Action<Shell> action) =>
InvokeOnMainThreadAsync(() =>
{
Expand Down
Loading