Skip to content

Commit

Permalink
[Android] Align dash effect between Border and Shapes (dotnet#12693)
Browse files Browse the repository at this point in the history
* Align dash effect between Border and Shapes on Android

* Update src/Core/src/Graphics/MauiDrawable.Android.cs

Co-authored-by: Manuel de la Pena <mandel@microsoft.com>

---------

Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
  • Loading branch information
jsuarezruiz and mandel-macaque committed Feb 9, 2023
1 parent fbba9d1 commit 2218065
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Core/src/Graphics/MauiDrawable.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public void SetBorderWidth(double strokeWidth)

public void SetBorderDash(float[]? strokeDashArray, double strokeDashOffset)
{
if (strokeDashArray == null || strokeDashArray.Length == 0 || strokeDashOffset <= 0)
if (strokeDashArray is null || strokeDashArray.Length == 0)
_borderPathEffect = null;
else
{
Expand Down
23 changes: 23 additions & 0 deletions src/Core/tests/DeviceTests/Handlers/Border/BorderHandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,29 @@ public async Task StrokeInitializesCorrectly(uint color)
await ValidateHasColor(border, expected);
}

[Theory(DisplayName = "Dashed Stroke Initializes Correctly")]
[InlineData(0xFFFF0000)]
[InlineData(0xFF00FF00)]
[InlineData(0xFF0000FF)]
public async Task DashedStrokeInitializesCorrectly(uint color)
{
var expected = Color.FromUint(color);

var border = new BorderStub()
{
Content = new LabelStub { Text = "Stroke", TextColor = Colors.Black },
Shape = new RectangleShapeStub(),
Background = new SolidPaintStub(Colors.White),
Stroke = new SolidPaintStub(expected),
StrokeDashPattern = new float[2] { 1, 1 },
StrokeThickness = 6,
Height = 100,
Width = 300
};

await ValidateHasColor(border, expected);
}

[Theory(DisplayName = "StrokeShape Initializes Correctly")]
[InlineData("Rectangle")]
[InlineData("RoundRectangle")]
Expand Down

0 comments on commit 2218065

Please sign in to comment.