Skip to content

Commit 2ee16b7

Browse files
SubhikshaSf4851PureWeen
authored andcommitted
[Windows] Fixed Shell flyout background image does not displayed (#28977)
* [Windows] Fix for FlyoutBackgroundImage * [Windows] Fix for Flyout Background Image * Test case sample for FlyoutBackgroundImage * [Windows] Fix for FlyoutBackgroundImage * [Windows] Fix for FlyoutBackgroundImage * Updated Test sample * Changed test sample and added snapshots for android and iOS * BackgroundImage set Snapshot for windows and mac * BackgroundImage set Null Snapshot for windows and mac
1 parent 4f62988 commit 2ee16b7

File tree

13 files changed

+133
-0
lines changed

13 files changed

+133
-0
lines changed

src/Controls/src/Core/Handlers/Shell/ShellHandler.Windows.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ private void OnLoaded(object sender, UI.Xaml.RoutedEventArgs e)
4242
{
4343
UpdateValue(nameof(Shell.FlyoutIcon));
4444
UpdateValue(nameof(Shell.FlyoutBackground));
45+
UpdateValue(nameof(Shell.FlyoutBackgroundImage));
4546
}
4647

4748
protected override void DisconnectHandler(ShellView platformView)
@@ -93,6 +94,7 @@ void OnPaneOpening(UI.Xaml.Controls.NavigationView sender, object args)
9394
{
9495
UpdateValue(nameof(Shell.FlyoutBackground));
9596
UpdateValue(nameof(Shell.FlyoutVerticalScrollMode));
97+
UpdateValue(nameof(Shell.FlyoutBackgroundImage));
9698
PlatformView.UpdateFlyoutBackdrop();
9799
PlatformView.UpdateFlyoutPosition();
98100
VirtualView.FlyoutIsPresented = true;
@@ -127,6 +129,16 @@ public static void MapFlyoutBackground(ShellHandler handler, Shell view)
127129
view.FlyoutBackgroundColor?.AsPaint());
128130
}
129131

132+
//TODO: Make it public in .NET 10.
133+
internal static void MapFlyoutBackgroundImage(ShellHandler handler, Shell view)
134+
{
135+
var provider = handler.GetRequiredService<IImageSourceServiceProvider>();
136+
if (handler?.PlatformView is not null && provider is not null)
137+
{
138+
handler.PlatformView.UpdateBackgroundImageSourceAsync(view.FlyoutBackgroundImage, provider, view.FlyoutBackgroundImageAspect).FireAndForget();
139+
}
140+
}
141+
130142
public static void MapFlyoutIcon(ShellHandler handler, Shell view)
131143
{
132144
var flyoutIcon = view.FlyoutIcon;

src/Controls/src/Core/Handlers/Shell/ShellHandler.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ public partial class ShellHandler
3535
[nameof(Shell.FlyoutIcon)] = MapFlyoutIcon,
3636
[nameof(Shell.FlyoutContentTemplate)] = MapFlyout,
3737
[nameof(Shell.FlowDirection)] = MapFlowDirection,
38+
[nameof(Shell.FlyoutBackgroundImage)] = MapFlyoutBackgroundImage,
39+
[nameof(Shell.FlyoutBackgroundImageAspect)] = MapFlyoutBackgroundImage,
3840
#endif
3941
};
4042

291 KB
Loading
17.6 KB
Loading
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
namespace Maui.Controls.Sample.Issues;
2+
3+
[Issue(IssueTracker.Github, 21472, "Shell FlyoutBackgroundImage doesn't shown", PlatformAffected.UWP)]
4+
public class Issue21472 : TestShell
5+
{
6+
protected override void Init()
7+
{
8+
var page = new ContentPage();
9+
this.BindingContext = this;
10+
11+
FlyoutBackgroundImage = "dotnet_bot.png";
12+
AddFlyoutItem(page, "Flyout Item");
13+
14+
var button = new Button
15+
{
16+
Text = "RemoveFlyoutBackground",
17+
HorizontalOptions = LayoutOptions.Center,
18+
VerticalOptions = LayoutOptions.Center,
19+
AutomationId = "button"
20+
};
21+
22+
button.Clicked += (sender, e) =>
23+
{
24+
Shell.Current.FlyoutBackgroundImage = null;
25+
};
26+
27+
page.Content = button;
28+
29+
FlyoutContentTemplate = new DataTemplate(() =>
30+
{
31+
var stackLayout = new StackLayout();
32+
33+
var closeButton = new Button
34+
{
35+
Text = "Close Flyout",
36+
AutomationId = "CloseFlyoutButton",
37+
Margin = new Thickness(20),
38+
HorizontalOptions = LayoutOptions.Center
39+
};
40+
41+
closeButton.Clicked += (sender, e) =>
42+
{
43+
Shell.Current.FlyoutIsPresented = false;
44+
};
45+
46+
stackLayout.Add(closeButton);
47+
return stackLayout;
48+
});
49+
}
50+
}
62.9 KB
Loading
10.6 KB
Loading
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using NUnit.Framework;
2+
using UITest.Appium;
3+
using UITest.Core;
4+
5+
namespace Microsoft.Maui.TestCases.Tests.Issues;
6+
public class Issue21472 : _IssuesUITest
7+
{
8+
public Issue21472(TestDevice testDevice) : base(testDevice)
9+
{
10+
}
11+
public override string Issue => "Shell FlyoutBackgroundImage doesn't shown";
12+
13+
[Test, Order(1)]
14+
[Category(UITestCategories.Shell)]
15+
public void VerifyShellFlyoutBackgroundImage()
16+
{
17+
App.WaitForElement("button");
18+
App.ShowFlyout();
19+
App.WaitForElement("CloseFlyoutButton");
20+
VerifyScreenshot();
21+
App.Tap("CloseFlyoutButton");
22+
}
23+
24+
[Test, Order(2)]
25+
[Category(UITestCategories.Shell)]
26+
public void VerifyShellFlyoutBackgroundImageSetNull()
27+
{
28+
App.WaitForElement("button");
29+
App.Tap("button");
30+
App.ShowFlyout();
31+
VerifyScreenshot();
32+
}
33+
}
76.1 KB
Loading
7.75 KB
Loading

0 commit comments

Comments
 (0)