Skip to content
Merged
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 47 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue19568.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
namespace Maui.Controls.Sample.Issues
{

[Issue(IssueTracker.Github, 19568, "GraphicsView does not change the Background/BackgroundColor on Android", PlatformAffected.Android)]
public class Issue19568 : ContentPage
{
public Issue19568()
{
var graphicsView = new GraphicsView()
{
HeightRequest = 300,
WidthRequest = 300,
AutomationId = "graphicsView",
BackgroundColor = Colors.Red,
Drawable = new MyDrawable()
};

Content =
new VerticalStackLayout()
{
new Grid
{
Children = {
new Label() { Text = "The GraphicsView should have a blue background color" },
graphicsView
}
},
new Button
{
Text = "Change BackgroundColor & opacity",
AutomationId = "ChangeBackgroundColorButton",
Command = new Command(() =>
{
graphicsView.BackgroundColor = Colors.Blue;
graphicsView.Opacity = 0.1;
})
}
};
}

class MyDrawable : IDrawable
{
public void Draw(ICanvas canvas, RectF dirtyRect) { }
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
{
public class Issue19568 : _IssuesUITest
{
const string Success = "Success";

public Issue19568(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "GraphicsView does not change the Background/BackgroundColor on Android";

[Test]
[Category(UITestCategories.GraphicsView)]
public void GraphicsViewShouldHaveBackgroundColor()
{
App.WaitForElement("ChangeBackgroundColorButton");
App.Click("ChangeBackgroundColorButton");
VerifyScreenshot();
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Maui.Graphics.Platform;
using Microsoft.Maui.Graphics;
using Microsoft.Maui.Graphics.Platform;

namespace Microsoft.Maui.Handlers
{
Expand All @@ -11,6 +12,7 @@ internal static void MapBackground(IGraphicsViewHandler handler, IGraphicsView g
{
if (graphicsView.Background is not null)
{
handler.PlatformView?.UpdateBackground(graphicsView);
handler.PlatformView?.Invalidate();
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/Core/src/Platform/Android/GraphicsViewExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Maui.Graphics.Platform;
using Microsoft.Maui.Graphics;
using Microsoft.Maui.Graphics.Platform;

namespace Microsoft.Maui.Platform
{
Expand All @@ -8,5 +9,10 @@ public static void UpdateDrawable(this PlatformGraphicsView PlatformGraphicsView
{
PlatformGraphicsView.Drawable = graphicsView.Drawable;
}

internal static void UpdateBackground(this PlatformGraphicsView PlatformGraphicsView, IGraphicsView graphicsView)
{
PlatformGraphicsView.BackgroundColor = graphicsView.Background?.ToColor();
}
}
}