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

IBorder now works again for iOS/Android #4909

Merged
merged 3 commits into from
Feb 25, 2022
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
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do Windows require changes too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe? Was traveling without a windows machine. Was going to check tomorrow.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, taking a look to WrapperView on Windows the logic to manage the border is missing. I think we should use the BorderChanged method to detect changes and ContentPanel control instead Grid in the WrapperView.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will send another PR with the Windows implementation. In that way we can merge and not block this PR.

{
//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);
PureWeen marked this conversation as resolved.
Show resolved Hide resolved

}

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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We no longer need to bring it to front? @jsuarezruiz?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried and is not necessary. Is already done in other place.


SetClip();
SetShadow();
Expand Down