From 42b5e0c907c9b5704ddf9417c2aa3a61446c48be Mon Sep 17 00:00:00 2001 From: "javiersuarezruiz@hotmail.com" Date: Wed, 10 Jan 2024 13:57:38 +0100 Subject: [PATCH 1/5] Fix the issue --- .../Handlers/Shell/Android/ShellFlyoutRenderer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellFlyoutRenderer.cs b/src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellFlyoutRenderer.cs index f3d917de1b2f..bbd4a800fa4d 100644 --- a/src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellFlyoutRenderer.cs +++ b/src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellFlyoutRenderer.cs @@ -183,9 +183,9 @@ protected override bool DrawChild(Canvas canvas, AView child, long drawingTime) canvas.DrawRect(0, 0, Width, Height, _scrimPaint); } - if (!FlyoutFirstDrawPassFinished && _flyoutContent != null) + if (!FlyoutFirstDrawPassFinished && _flyoutContent is not null) { - if (child == _flyoutContent?.AndroidView) + if (_flyoutContent?.AndroidView is not null) FlyoutFirstDrawPassFinished = true; if (this.IsDrawerOpen(_flyoutContent.AndroidView) != _shellContext.Shell.FlyoutIsPresented) From a7ec95063bb86b5cfabd311ddc8ceefc8db60eca Mon Sep 17 00:00:00 2001 From: "javiersuarezruiz@hotmail.com" Date: Wed, 10 Jan 2024 13:57:49 +0100 Subject: [PATCH 2/5] Added device test --- .../Shell/ShellFlyoutTests.Android.cs | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/Controls/tests/DeviceTests/Elements/Shell/ShellFlyoutTests.Android.cs diff --git a/src/Controls/tests/DeviceTests/Elements/Shell/ShellFlyoutTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/Shell/ShellFlyoutTests.Android.cs new file mode 100644 index 000000000000..120a2018187f --- /dev/null +++ b/src/Controls/tests/DeviceTests/Elements/Shell/ShellFlyoutTests.Android.cs @@ -0,0 +1,38 @@ +using AndroidX.DrawerLayout.Widget; +using Microsoft.Maui.Controls; +using System.Threading.Tasks; +using Xunit; + +namespace Microsoft.Maui.DeviceTests +{ + [Category(TestCategory.Shell)] + public partial class ShellTests + { + [Fact(DisplayName = "FlyoutIsPresented=true sets the visible status of the Shell Flyout.")] + public async Task FlyoutIsPresentedOpenDrawer() + { + await RunShellTest(shell => + { + shell.FlyoutContent = new VerticalStackLayout() { new Label() { Text = "Flyout Content" } }; + + // 1. Set FlyoutIsPresented=true to make the Shell Flyout visible. + shell.FlyoutIsPresented = true; + }, + async (shell, handler) => + { + await Task.Delay(100); + + var dl = GetDrawerLayout(handler) as DrawerLayout; + Assert.NotNull(dl); + + // 2. Check that the Flyout has size. + var flyoutFrame = GetFlyoutFrame(handler); + Assert.True(flyoutFrame.Width > 0); + Assert.True(flyoutFrame.Height > 0); + + // 3. Check that the Flyout status. It must be open. + Assert.True(dl.IsOpen); + }); + } + } +} From 7e7bd983bafa74b291bf4f442443e084efbf0c49 Mon Sep 17 00:00:00 2001 From: "javiersuarezruiz@hotmail.com" Date: Wed, 10 Jan 2024 13:57:55 +0100 Subject: [PATCH 3/5] Added sample --- .../Pages/Core/ShellGalleries/ShellChromeGallery.cs | 5 +++++ .../Pages/Core/ShellGalleries/ShellChromeGallery.xaml | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/Controls/samples/Controls.Sample/Pages/Core/ShellGalleries/ShellChromeGallery.cs b/src/Controls/samples/Controls.Sample/Pages/Core/ShellGalleries/ShellChromeGallery.cs index 2775bc88904a..469754b94148 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Core/ShellGalleries/ShellChromeGallery.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Core/ShellGalleries/ShellChromeGallery.cs @@ -76,6 +76,11 @@ protected override void OnAppearing() AppShell!.FlyoutHeaderBehavior = (FlyoutHeaderBehavior)flyoutHeaderBehavior.SelectedIndex; } + void OnToggleFlyoutIsPresented(object sender, EventArgs e) + { + AppShell!.FlyoutIsPresented = !AppShell!.FlyoutIsPresented; + } + void OnToggleFlyoutBackgroundColor(object sender, EventArgs e) { AppShell!.RemoveBinding(Shell.FlyoutBackgroundProperty); diff --git a/src/Controls/samples/Controls.Sample/Pages/Core/ShellGalleries/ShellChromeGallery.xaml b/src/Controls/samples/Controls.Sample/Pages/Core/ShellGalleries/ShellChromeGallery.xaml index 7fae4ca459cf..f1b1ee64a747 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Core/ShellGalleries/ShellChromeGallery.xaml +++ b/src/Controls/samples/Controls.Sample/Pages/Core/ShellGalleries/ShellChromeGallery.xaml @@ -13,6 +13,10 @@ Text="Flyout Behavior" Style="{StaticResource Headline}"/> +