Uh oh!
There was an error while loading. Please reload this page.
Added border curve style prop ("Squircle" effect - iOS only) - #32017
Added border curve style prop ("Squircle" effect - iOS only)#32017eric-edouard wants to merge 11 commits into
Conversation
Base commit: 8fef520 |
Base commit: 8fef520 |
Relates to this PR: react/react-native#32017
There was a problem hiding this comment.
What about naming it borderCurve (borderRadiusCurve? cornerCurve? borderRadiusStyle?) with value 'circular' | 'continuous'.
cc @yungsters
| RCT_CUSTOM_VIEW_PROPERTY(cornerSmoothing, BOOL, RCTView) | ||
| { | ||
| if ([RCTConvert BOOL:json]) { | ||
| view.layer.cornerCurve = @"continuous"; |
There was a problem hiding this comment.
Use kCACornerCurveContinuous / kCACornerCurveCircular
| } | ||
| RCT_CUSTOM_VIEW_PROPERTY(cornerSmoothing, BOOL, RCTView) | ||
| { | ||
| if ([RCTConvert BOOL:json]) { |
There was a problem hiding this comment.
cornerCurve seems to be available on iOS 13+ only. You can add if (@available(iOS 13.0, *)) { so it does nothing on older versions.
yungsters
commented
Oct 4, 2021
Sounds good to me. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
eric-edouard
commented
Oct 5, 2021
@janicduplessis is it normal that the CI fails here ? Thanks |
janicduplessis
commented
Oct 5, 2021
I think its fine, failures don't seem related to your changes. LGTM thanks for the PR!! @yungsters Can you import this? |
facebook-github-bot
commented
Oct 20, 2021
@yungsters has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
philIip
left a comment
There was a problem hiding this comment.
thanks so much for working on this! looking real snazzy - just have one change i'd like to be made.
Uh oh!
There was an error while loading. Please reload this page.
janicduplessis
commented
Feb 28, 2022
@philIip Could you have a look at this again? seems like all feedback have been addressed. |
eric-edouard
commented
May 7, 2022
@janicduplessis@philIip quick bump on this one, looks like the Any help on what should I do next to get this feature merged? Thanks! |
giautm
commented
May 7, 2022
I think this commit can help, 7b9490b Just move the change to |
eric-edouard
commented
May 7, 2022
thanks @giautm |
Summary: <!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? --> NOTE: PR is based on #32017 which went stale for quite a long time but can now safely be closed  Since iOS 13+, it is possible to change the corner curve property on iOS in order to smoothen border radius and make it more "rounded" (also called "squircle") Here's an [article](https://medium.com/arthurofbabylon/a-smooth-corner-radius-in-ios-54b80aa2d372) explaining in details what it is. This property is also built in figma, but currently there is no way to implement this directly with react-native despite it being available natively on iOS. Many open source react-native libraries were created in order to simulate this behaviour: [react-native-super-ellipse-mask](https://github.com/everdrone/react-native-super-ellipse-mask) [react-native-squircle-view](https://github.com/everdrone/react-native-squircle-view) [react-native-figma-squircle](https://github.com/tienphaw/react-native-figma-squircle) But they rely on creating an SVG shape with the smoothed corners and masking the view behind. This makes it not very performant (flickering on mounting was a common side-effect) This PR aims at implementing the property natively. PR for the docs update: react/react-native-website#2785 ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://github.com/facebook/react-native/wiki/Changelog --> [iOS] [Added] - Added `borderCurve` style prop for smooth border radius (squircle effect) Pull Request resolved: #33783 Test Plan: We used the RNTester app and added an example with `cornerCurve ` set to `'continuous'` (only on iOS). As the difference is quite subtle, we also made some more tests to better illustrate the difference (these are not in the RN-tester app):  We overlapped two views with `position: absolute`, the one in the background has a red background and has `cornerRadius` set to `false`, and the one in the foreground is set to `true`. We can clearly see where the borders differs on the corners. Reviewed By: sammy-SC Differential Revision: D37883631 Pulled By: cipolleschi fbshipit-source-id: 09f06de9628fa326323eba63875de30102c4a59e
Summary
Since iOS 13+, it is possible to change the corner curve property on iOS in order to smoothen border radius and make it more "rounded" (also called "squircle")
Here's an article explaining in details what it is.
This property is also built in figma, but currently there is no way to implement this directly with react-native despite it being available natively on iOS.
Many open source react-native libraries were created in order to simulate this behaviour:
react-native-super-ellipse-mask
react-native-squircle-view
react-native-figma-squircle
But they rely on creating an SVG shape with the smoothed corners and masking the view behind. This makes it not very performant (flickering on mounting was a common side-effect)
This PR aims at implementing the property natively.
PR for the docs update: react/react-native-website#2785
Changelog
[iOS] [Added] - Added
cornerCurvestyle prop to smoothen the border radius (squircle effect)Test Plan
We used the RNTester app and added an example with
cornerCurveset to'continuous'(only on iOS).As the difference is quite subtle, we also made some more tests to better illustrate the difference (these are not in the showcase app):
We overlapped two views with
position: absolute, the one in the background has a red background and hascornerRadiusset tofalse, and the one in the foreground is set totrue. We can clearly see where the borders differs on the corners.