Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[iOS] Fix ContentPage BackgroundImageSource not working (#17789)
* Fix ContentPage BackgroundImageSource not working on iOS/Catalyst * Adding UI Test * Updated screenshots * Updated screenshot * Updated test * Created iOS PageExtensions * Enabled test for all the platforms * Add pending snapshots * Changed iOS PageExtensions to internal
- Loading branch information
1 parent
00f39ee
commit 5dcb340
Showing
9 changed files
with
78 additions
and
7 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
src/Controls/samples/Controls.Sample.UITests/Issues/Issues17789.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Maui.Controls.Sample.Issues.Issue17789" | ||
BackgroundImageSource="oasis.jpg"> | ||
<StackLayout> | ||
<Label | ||
AutomationId="WaitForStubControl" | ||
Text="Issue 17789" | ||
VerticalOptions="Center" | ||
HorizontalOptions="Center" /> | ||
</StackLayout> | ||
</ContentPage> |
15 changes: 15 additions & 0 deletions
15
src/Controls/samples/Controls.Sample.UITests/Issues/Issues17789.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Microsoft.Maui.Controls; | ||
using Microsoft.Maui.Controls.Xaml; | ||
|
||
namespace Maui.Controls.Sample.Issues | ||
{ | ||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
[Issue(IssueTracker.Github, 17789, "ContentPage BackgroundImageSource not working", PlatformAffected.iOS)] | ||
public partial class Issue17789 : ContentPage | ||
{ | ||
public Issue17789() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
} |
Binary file added
BIN
+122 KB
src/Controls/samples/Controls.Sample.UITests/Resources/Images/oasis.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.AppiumTests.Issues | ||
{ | ||
public class Issue17789 : _IssuesUITest | ||
{ | ||
public Issue17789(TestDevice device) : base(device) | ||
{ | ||
} | ||
|
||
public override string Issue => "ContentPage BackgroundImageSource not working"; | ||
|
||
[Test] | ||
public void ContentPageBackgroundImageSourceWorks() | ||
{ | ||
App.WaitForElement("WaitForStubControl"); | ||
VerifyScreenshot(); | ||
} | ||
} | ||
} |
Binary file added
BIN
+1.48 MB
...trols/tests/UITests/snapshots/android/ContentPageBackgroundImageSourceWorks.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.85 MB
src/Controls/tests/UITests/snapshots/ios/ContentPageBackgroundImageSourceWorks.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+769 KB
...trols/tests/UITests/snapshots/windows/ContentPageBackgroundImageSourceWorks.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using UIKit; | ||
|
||
namespace Microsoft.Maui.Platform | ||
{ | ||
internal static class PageExtensions | ||
{ | ||
public static void UpdateTitle(this UIViewController viewController, IContentView page) | ||
{ | ||
if (page is not ITitledElement titled) | ||
return; | ||
|
||
viewController.Title = titled.Title; | ||
} | ||
|
||
public static void UpdateBackground(this UIView platformView, IContentView page, IImageSourceServiceProvider? provider) | ||
{ | ||
if (page.Background is ImageSourcePaint image) | ||
platformView.UpdateBackgroundImageSourceAsync(image.ImageSource, provider).FireAndForget(); | ||
else | ||
platformView.UpdateBackground(page); | ||
} | ||
} | ||
} |