mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
8993ffc82e
Summary: <!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? --> NOTE: PR is based on https://github.com/facebook/react-native/pull/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: https://github.com/facebook/react-native-website/pull/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: https://github.com/facebook/react-native/pull/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
147 lines
3.2 KiB
JavaScript
147 lines
3.2 KiB
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format strict-local
|
|
* @flow
|
|
*/
|
|
|
|
import type {AnyAttributeType} from '../../Renderer/shims/ReactNativeTypes';
|
|
import processColor from '../../StyleSheet/processColor';
|
|
import processTransform from '../../StyleSheet/processTransform';
|
|
import sizesDiffer from '../../Utilities/differ/sizesDiffer';
|
|
|
|
const colorAttributes = {process: processColor};
|
|
|
|
const ReactNativeStyleAttributes: {[string]: AnyAttributeType, ...} = {
|
|
/**
|
|
* Layout
|
|
*/
|
|
alignContent: true,
|
|
alignItems: true,
|
|
alignSelf: true,
|
|
aspectRatio: true,
|
|
borderBottomWidth: true,
|
|
borderEndWidth: true,
|
|
borderLeftWidth: true,
|
|
borderRightWidth: true,
|
|
borderStartWidth: true,
|
|
borderTopWidth: true,
|
|
borderWidth: true,
|
|
bottom: true,
|
|
direction: true,
|
|
display: true,
|
|
end: true,
|
|
flex: true,
|
|
flexBasis: true,
|
|
flexDirection: true,
|
|
flexGrow: true,
|
|
flexShrink: true,
|
|
flexWrap: true,
|
|
height: true,
|
|
justifyContent: true,
|
|
left: true,
|
|
margin: true,
|
|
marginBottom: true,
|
|
marginEnd: true,
|
|
marginHorizontal: true,
|
|
marginLeft: true,
|
|
marginRight: true,
|
|
marginStart: true,
|
|
marginTop: true,
|
|
marginVertical: true,
|
|
maxHeight: true,
|
|
maxWidth: true,
|
|
minHeight: true,
|
|
minWidth: true,
|
|
overflow: true,
|
|
padding: true,
|
|
paddingBottom: true,
|
|
paddingEnd: true,
|
|
paddingHorizontal: true,
|
|
paddingLeft: true,
|
|
paddingRight: true,
|
|
paddingStart: true,
|
|
paddingTop: true,
|
|
paddingVertical: true,
|
|
position: true,
|
|
right: true,
|
|
start: true,
|
|
top: true,
|
|
width: true,
|
|
zIndex: true,
|
|
|
|
/**
|
|
* Shadow
|
|
*/
|
|
elevation: true,
|
|
shadowColor: colorAttributes,
|
|
shadowOffset: {diff: sizesDiffer},
|
|
shadowOpacity: true,
|
|
shadowRadius: true,
|
|
|
|
/**
|
|
* Transform
|
|
*/
|
|
transform: {process: processTransform},
|
|
|
|
/**
|
|
* View
|
|
*/
|
|
backfaceVisibility: true,
|
|
backgroundColor: colorAttributes,
|
|
borderBottomColor: colorAttributes,
|
|
borderBottomEndRadius: true,
|
|
borderBottomLeftRadius: true,
|
|
borderBottomRightRadius: true,
|
|
borderBottomStartRadius: true,
|
|
borderColor: colorAttributes,
|
|
borderCurve: true,
|
|
borderEndColor: colorAttributes,
|
|
borderLeftColor: colorAttributes,
|
|
borderRadius: true,
|
|
borderRightColor: colorAttributes,
|
|
borderStartColor: colorAttributes,
|
|
borderStyle: true,
|
|
borderTopColor: colorAttributes,
|
|
borderTopEndRadius: true,
|
|
borderTopLeftRadius: true,
|
|
borderTopRightRadius: true,
|
|
borderTopStartRadius: true,
|
|
opacity: true,
|
|
|
|
/**
|
|
* Text
|
|
*/
|
|
color: colorAttributes,
|
|
fontFamily: true,
|
|
fontSize: true,
|
|
fontStyle: true,
|
|
fontVariant: true,
|
|
fontWeight: true,
|
|
includeFontPadding: true,
|
|
letterSpacing: true,
|
|
lineHeight: true,
|
|
textAlign: true,
|
|
textAlignVertical: true,
|
|
textDecorationColor: colorAttributes,
|
|
textDecorationLine: true,
|
|
textDecorationStyle: true,
|
|
textShadowColor: colorAttributes,
|
|
textShadowOffset: true,
|
|
textShadowRadius: true,
|
|
textTransform: true,
|
|
writingDirection: true,
|
|
|
|
/**
|
|
* Image
|
|
*/
|
|
overlayColor: colorAttributes,
|
|
resizeMode: true,
|
|
tintColor: colorAttributes,
|
|
};
|
|
|
|
module.exports = ReactNativeStyleAttributes;
|