-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
Added border curve style prop ("Squircle" effect - iOS only) #33783
Conversation
Base commit: f3db6cc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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. |
I think similar logic could be used here https://github.com/facebook/react-native/blob/main/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm#L582. |
@janicduplessis you're correct, this doesn't work with Fabric yet. Will take a look into it! Thanks |
@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 |
@janicduplessis quick bump 🙂 |
Cold you rebase this? I can see |
@cipolleschi rebased + tested again on RNTester app after merge, all good |
@cipolleschi quick bump! |
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@cipolleschi No worries! Fixed the new line and aligned with main. Let me know if there's anything else |
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
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: facebook/react-native-website#2785
Changelog
[iOS] [Added] - Added
borderCurve
style prop for smooth border radius (squircle effect)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 hascornerRadius
set tofalse
, and the one in the foreground is set totrue
. We can clearly see where the borders differs on the corners.