-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Windows] Fixed Shell flyout background image does not displayed #28977
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
830232d
0e4cfb6
c5ee726
bcc6432
09f5fff
258a93b
67fcac9
8f060de
6d34bf0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 21472, "Shell FlyoutBackgroundImage doesn't shown", PlatformAffected.UWP)] | ||
| public class Issue21472 : TestShell | ||
| { | ||
| protected override void Init() | ||
| { | ||
| var page = new ContentPage(); | ||
| this.BindingContext = this; | ||
|
|
||
| FlyoutBackgroundImage = "dotnet_bot.png"; | ||
| AddFlyoutItem(page, "Flyout Item"); | ||
|
|
||
| var button = new Button | ||
| { | ||
| Text = "RemoveFlyoutBackground", | ||
| HorizontalOptions = LayoutOptions.Center, | ||
| VerticalOptions = LayoutOptions.Center, | ||
| AutomationId = "button" | ||
| }; | ||
|
|
||
| button.Clicked += (sender, e) => | ||
| { | ||
| Shell.Current.FlyoutBackgroundImage = null; | ||
| }; | ||
|
|
||
| page.Content = button; | ||
|
|
||
| FlyoutContentTemplate = new DataTemplate(() => | ||
| { | ||
| var stackLayout = new StackLayout(); | ||
|
|
||
| var closeButton = new Button | ||
| { | ||
| Text = "Close Flyout", | ||
| AutomationId = "CloseFlyoutButton", | ||
| Margin = new Thickness(20), | ||
| HorizontalOptions = LayoutOptions.Center | ||
| }; | ||
|
|
||
| closeButton.Clicked += (sender, e) => | ||
| { | ||
| Shell.Current.FlyoutIsPresented = false; | ||
| }; | ||
|
|
||
| stackLayout.Add(closeButton); | ||
| return stackLayout; | ||
| }); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
| public class Issue21472 : _IssuesUITest | ||
| { | ||
| public Issue21472(TestDevice testDevice) : base(testDevice) | ||
| { | ||
| } | ||
| public override string Issue => "Shell FlyoutBackgroundImage doesn't shown"; | ||
|
|
||
| [Test, Order(1)] | ||
| [Category(UITestCategories.Shell)] | ||
| public void VerifyShellFlyoutBackgroundImage() | ||
| { | ||
| App.WaitForElement("button"); | ||
| App.ShowFlyout(); | ||
| App.WaitForElement("CloseFlyoutButton"); | ||
| VerifyScreenshot(); | ||
| App.Tap("CloseFlyoutButton"); | ||
| } | ||
|
|
||
| [Test, Order(2)] | ||
| [Category(UITestCategories.Shell)] | ||
| public void VerifyShellFlyoutBackgroundImageSetNull() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pending Snapshots were added. |
||
| { | ||
| App.WaitForElement("button"); | ||
| App.Tap("button"); | ||
| App.ShowFlyout(); | ||
| VerifyScreenshot(); | ||
jsuarezruiz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -256,6 +256,42 @@ public static void UpdateFlyoutWidth(this MauiNavigationView navigationView, IFl | |
| //handler.PlatformView.OpenPaneLength = handler.PlatformView.TemplateSettings.OpenPaneWidth; | ||
| } | ||
|
|
||
| internal static async Task UpdateBackgroundImageSourceAsync(this MauiNavigationView navigationView, IImageSource? imageSource, IImageSourceServiceProvider? provider, Aspect aspect) | ||
| { | ||
| if (provider is null || imageSource is null) | ||
| { | ||
| return; | ||
| } | ||
| var paneContentGrid = navigationView.PaneContentGrid; | ||
| if (paneContentGrid is null) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| var service = provider.GetRequiredImageSourceService(imageSource); | ||
| var nativeImageSource = await service.GetImageSourceAsync(imageSource); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have updated the requested changes |
||
|
|
||
| if (nativeImageSource is null) | ||
| { | ||
| paneContentGrid.Background = null; | ||
| return; | ||
| } | ||
|
|
||
| var BackgroundImage = new ImageBrush | ||
| { | ||
| ImageSource = nativeImageSource?.Value, | ||
| Stretch = aspect switch | ||
| { | ||
| Aspect.AspectFit => Stretch.Uniform, | ||
| Aspect.AspectFill => Stretch.UniformToFill, | ||
| Aspect.Fill => Stretch.Fill, | ||
| _ => Stretch.None | ||
| } | ||
| }; | ||
|
|
||
| paneContentGrid.Background = BackgroundImage; | ||
| } | ||
|
|
||
| public static async Task UpdateFlyoutIconAsync(this MauiNavigationView navigationView, IImageSource? imageSource, IImageSourceServiceProvider? provider) | ||
| { | ||
| var togglePaneButton = navigationView.TogglePaneButton; | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.