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

add support for borderTopLeftRadius and the three other one-corner-on… #1871

Merged
Merged
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
44 changes: 41 additions & 3 deletions ReactWindows/ReactNative/Views/Image/ReactImageManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,53 @@ public void SetSource(Border view, JArray sources)
}
}

/// <summary>
/// Enum values correspond to positions of prop names in ReactPropGroup attribute
/// applied to <see cref="SetBorderRadius(Border, int, double)"/>
/// </summary>
private enum Radius
Copy link
Collaborator

Choose a reason for hiding this comment

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

BEGIN NITPICK

In general I don't know why we add private enums when ints work just fine.

END NITPICK

{
All,
TopLeft,
TopRight,
BottomLeft,
BottomRight,
}

/// <summary>
/// The border radius of the <see cref="ReactRootView"/>.
/// </summary>
/// <param name="view">The image view instance.</param>
/// <param name="index">The prop index.</param>
/// <param name="radius">The border radius value.</param>
[ReactProp("borderRadius")]
public void SetBorderRadius(Border view, double radius)
[ReactPropGroup(
Copy link
Contributor

Choose a reason for hiding this comment

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

modify WPF implementation to match as well. test prop in Playground and provide code+screenshot for both UWP and WPF.

Copy link
Member Author

@zholobov zholobov Jul 11, 2018

Choose a reason for hiding this comment

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

@matthargett I have another PR ready to be submitted which fixes a bug in borderRadius and which has WPF part updated too. Is it okay if you approve this PR and I will do the Playground screenshots and code as part of the next PR?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd prefer to see a contribution upstream for a border*Radius example in RNTester. Does not need to be done for this repo.

Copy link
Member Author

Choose a reason for hiding this comment

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

ReactNative already has examples of border*Radius at https://github.com/facebook/react-native/edit/master/RNTester/js/BorderExample.js see styles border6, border9, border10, border14.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes - but not for Image

Copy link
Member Author

@zholobov zholobov Aug 8, 2018

Choose a reason for hiding this comment

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

@rozele PR into ReactNative for border*Radius test for Image seems to be in process of landing here.

ViewProps.BorderRadius,
ViewProps.BorderTopLeftRadius,
ViewProps.BorderTopRightRadius,
ViewProps.BorderBottomLeftRadius,
ViewProps.BorderBottomRightRadius)]
public void SetBorderRadius(Border view, int index, double radius)
{
view.CornerRadius = new CornerRadius(radius);
var cornerRadius = view.CornerRadius;
Copy link
Contributor

@rigdern rigdern Jun 25, 2018

Choose a reason for hiding this comment

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

view.CornerRadius [](start = 31, length = 17)

Can view.CornerRadius ever be null? You can see ReactViewManager uses this expression:

var cornerRadius = border.CornerRadius == null ? new CornerRadius() : border.CornerRadius;
``` #Closed

Copy link
Contributor

@rigdern rigdern Jun 25, 2018

Choose a reason for hiding this comment

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

Spoke with Yury. CornerRadius is a struct so it can't be null and a null check is not needed.


In reply to: 197945901 [](ancestors = 197945901)

switch ((Radius)index)
{
case Radius.All:
cornerRadius = new CornerRadius(radius);
break;
case Radius.TopLeft:
cornerRadius.TopLeft = radius;
break;
case Radius.TopRight:
cornerRadius.TopRight = radius;
break;
case Radius.BottomLeft:
cornerRadius.BottomLeft = radius;
break;
case Radius.BottomRight:
cornerRadius.BottomRight = radius;
break;
}
view.CornerRadius = cornerRadius;
}

/// <summary>
Expand Down