Skip to content
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

[Android] Border Stroke gradient can only switch to another gradient - fix #22168

Merged
merged 8 commits into from
Aug 7, 2024
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.
26 changes: 26 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue22042.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?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.Issue22042"
Title="Issue22042">

<ContentPage.Resources>
<RadialGradientBrush x:Key="PurpleGradiant"
Center="0.8,0.5">
<GradientStop Color="#AD27FF"
Offset="0.25" />
<GradientStop Color="#4447FE"
Offset="0.75" />
</RadialGradientBrush>
</ContentPage.Resources>

<Border x:Name="border"
VerticalOptions="Center"
StrokeThickness="2">
<Label AutomationId="label" Text="Hello, World!">
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped"/>
</Label.GestureRecognizers>
</Label>
</Border>
</ContentPage>
22 changes: 22 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue22042.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace Maui.Controls.Sample.Issues;

[XamlCompilation(XamlCompilationOptions.Compile)]
[Issue(IssueTracker.Github, 22042, "[Android] Border Stroke GradiantBrush can only switch to another gradiantbrush", PlatformAffected.Android)]

public partial class Issue22042 : ContentPage
{
private Brush _gradiantPurpleBrush => Resources.TryGetValue("PurpleGradiant", out object laColor) ? (Brush)laColor : null;

public Issue22042()
{
InitializeComponent();
}

private void TapGestureRecognizer_Tapped(object sender, TappedEventArgs e)
{
if (border.Stroke == _gradiantPurpleBrush)
border.Stroke = Colors.Red;
else
border.Stroke = _gradiantPurpleBrush;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#if !MACCATALYST
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
{
public class Issue22042 : _IssuesUITest
{
public Issue22042(TestDevice device) : base(device)
{
}

public override string Issue => "[Android] Border Stroke GradiantBrush can only switch to another gradiantbrush";

[Test]
[Category(UITestCategories.Border)]
public void BorderColorShouldChange()
{
App.WaitForElement("label");

//Applies a gradient
App.Click("label");

//Applies a solid color
App.Click("label");

VerifyScreenshot();
}
}
}
#endif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/Core/src/Graphics/MauiDrawable.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ public void SetBorderColor(AColor? borderColor)

_borderColor = borderColor;

InitializeBorderIfNeeded();
InvalidateSelf();
}

Expand Down Expand Up @@ -182,6 +183,7 @@ public void SetBorderBrush(SolidPaint solidPaint)
{
_invalidatePath = true;
_borderColor = null;
_borderPaint = null;

var borderColor = solidPaint.Color == null
? (AColor?)null
Expand Down
Loading