mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
b2452ab216
Summary: This PR aims to add support for objectFit a partial equivalent to the resizeMode style and prop of Image. ## Changelog [General] [Added] - Add support for objectFit style of Image. Pull Request resolved: https://github.com/facebook/react-native/pull/34576 Test Plan: 1. Open the RNTester app and navigate to the Image page 2. See the Object Fit section.  Reviewed By: rickhanlonii Differential Revision: D39261176 Pulled By: jacdebug fbshipit-source-id: 1eefd76b6c11ed5fc52b2c524ad78c91051077f6
150 lines
3.2 KiB
JavaScript
150 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,
|
|
pointerEvents: 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,
|
|
userSelect: true,
|
|
writingDirection: true,
|
|
|
|
/**
|
|
* Image
|
|
*/
|
|
overlayColor: colorAttributes,
|
|
resizeMode: true,
|
|
tintColor: colorAttributes,
|
|
objectFit: true,
|
|
};
|
|
|
|
module.exports = ReactNativeStyleAttributes;
|