Uh oh!
There was an error while loading. Please reload this page.
Added border curve style prop ("Squircle" effect - iOS only) - #33783
Added border curve style prop ("Squircle" effect - iOS only)#33783eric-edouard wants to merge 8 commits into
Conversation
Base commit: f3db6cc |
janicduplessis
commented
May 8, 2022
@eric-edouard Did you test if this work with the Fabric renderer? I think RN tester uses it by default now. Can you also rebase, I think CI was broken recently and was fixed here 94341f0. |
janicduplessis
commented
May 8, 2022
I think similar logic could be used here https://github.com/facebook/react-native/blob/main/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm#L582. |
eric-edouard
commented
May 9, 2022
@janicduplessis you're correct, this doesn't work with Fabric yet. Will take a look into it! Thanks |
Uh oh!
There was an error while loading. Please reload this page.
eric-edouard
commented
May 14, 2022
@janicduplessis I've adapted the logic to have it work with Fabric, works well on my end with the same testing strategy as in the PR description. |
Base commit: f3db6cc |
eric-edouard
commented
Jun 8, 2022
@janicduplessis quick bump 🙂 |
cipolleschi
commented
Jun 10, 2022
Cold you rebase this? I can see |
eric-edouard
commented
Jun 16, 2022
@cipolleschi rebased + tested again on RNTester app after merge, all good |
eric-edouard
commented
Jun 27, 2022
@cipolleschi quick bump! |
facebook-github-bot
commented
Jul 15, 2022
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
cipolleschi
left a comment
There was a problem hiding this comment.
Sorry if this took a while to be imported. Thanks again for the contribution.
Can I ask if you can rebase it and fix the small comment I left?
Besides these, it looks very good.
Uh oh!
There was an error while loading. Please reload this page.
@cipolleschi No worries! Fixed the new line and aligned with main. Let me know if there's anything else |
facebook-github-bot
commented
Jul 18, 2022
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
react-native-bot
commented
Jul 21, 2022
This pull request was successfully merged by @eric-edouard in 8993ffc. When will my fix make it into a release? | Upcoming Releases |
Summary
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 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
borderCurvestyle prop for smooth 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 RN-tester 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.