Skip to content

Commit

Permalink
IBorder now works again for iOS/Android (#4909)
Browse files Browse the repository at this point in the history
* IBorder now works again for iOS/Android

* Update src/Core/src/Platform/Android/StrokeExtensions.cs

Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com>

* Update StrokeExtensions.cs

Co-authored-by: Shane Neuville <shane94@hotmail.com>
Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com>
  • Loading branch information
3 people authored Feb 25, 2022
1 parent 3551378 commit 5d8b798
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
23 changes: 22 additions & 1 deletion src/Core/src/Platform/Android/StrokeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,27 @@ namespace Microsoft.Maui.Platform
{
public static class StrokeExtensions
{
public static void UpdateBorderStroke(this AView platformView, IBorderStroke border)
{
//Always set the drawable first
platformView.UpdateMauiDrawable(border);

var borderShape = border.Shape;
MauiDrawable? mauiDrawable = platformView.Background as MauiDrawable;

if (mauiDrawable == null && borderShape == null)
return;

mauiDrawable?.SetBorderBrush(border.Stroke);
mauiDrawable?.SetBorderWidth(border.StrokeThickness);
platformView.UpdateStrokeDashPattern(border);
platformView.UpdateStrokeDashOffset(border);
mauiDrawable?.SetBorderMiterLimit(border.StrokeMiterLimit);
mauiDrawable?.SetBorderLineCap(border.StrokeLineCap);
mauiDrawable?.SetBorderLineJoin(border.StrokeLineJoin);

}

public static void UpdateStrokeShape(this AView platformView, IBorderStroke border)
{
var borderShape = border.Shape;
Expand Down Expand Up @@ -121,4 +142,4 @@ internal static void UpdateMauiDrawable(this AView platformView, IBorderStroke b
mauiDrawable.SetBorderShape(border.Shape);
}
}
}
}
2 changes: 1 addition & 1 deletion src/Core/src/Platform/Android/ViewExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public static void UpdateBackground(this ContentViewGroup platformView, IBorderS
bool hasBorder = border.Shape != null && border.Stroke != null;

if (hasBorder)
platformView.UpdateMauiDrawable(border);
platformView.UpdateBorderStroke(border);
}

public static void UpdateBackground(this AView platformView, IView view, Drawable? defaultBackground = null) =>
Expand Down
2 changes: 1 addition & 1 deletion src/Core/src/Platform/Android/WrapperView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ partial void BorderChanged()
{
this.AddView(BorderView = new AView(Context));
}
BorderView.UpdateMauiDrawable(Border);
BorderView.UpdateBorderStroke(Border);
}

void ClipChild(Canvas canvas)
Expand Down
2 changes: 1 addition & 1 deletion src/Core/src/Platform/iOS/WrapperView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public override void LayoutSubviews()
ShadowLayer.Frame = Bounds;

if (BorderView != null)
BringSubviewToFront(BorderView);
BorderView.Frame = Bounds;

SetClip();
SetShadow();
Expand Down

0 comments on commit 5d8b798

Please sign in to comment.