From f94d2ade867a7d3bfb3237afab9e56e580c083b8 Mon Sep 17 00:00:00 2001 From: Guilherme Varandas Date: Thu, 27 Sep 2018 19:31:28 -0700 Subject: [PATCH] Move and Rename propType definitions in ShadowPropTypesIOS (#21379) Summary: related #21342 move TransformPropTypes.js fix flow error - [x] yarn prettier - [x] yarn flow-check-android - [x] yarn flow-check-ios All flow checks pass. [GENERAL] [ENHANCEMENT] [DeprecatedShadowPropTypesIOS.js] - Created. Pull Request resolved: https://github.com/facebook/react-native/pull/21379 Differential Revision: D10098750 Pulled By: TheSavior fbshipit-source-id: f7f2e4bf7b837c00a14b1fbd930d1b29ffb63549 --- .../Components/View/ShadowPropTypesIOS.js | 50 ------------------- .../Components/View/ViewStylePropTypes.js | 4 +- .../DeprecatedShadowPropTypesIOS.js | 25 ++++++++++ Libraries/Image/ImageStylePropTypes.js | 4 +- Libraries/StyleSheet/StyleSheetTypes.js | 25 ++++++++++ 5 files changed, 54 insertions(+), 54 deletions(-) delete mode 100644 Libraries/Components/View/ShadowPropTypesIOS.js create mode 100644 Libraries/DeprecatedPropTypes/DeprecatedShadowPropTypesIOS.js diff --git a/Libraries/Components/View/ShadowPropTypesIOS.js b/Libraries/Components/View/ShadowPropTypesIOS.js deleted file mode 100644 index 6d723595742..00000000000 --- a/Libraries/Components/View/ShadowPropTypesIOS.js +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - * @format - */ -'use strict'; - -const DeprecatedColorPropType = require('DeprecatedColorPropType'); -const ReactPropTypes = require('prop-types'); - -/** - * These props can be used to dynamically generate shadows on views, images, text, etc. - * - * Because they are dynamically generated, they may cause performance regressions. Static - * shadow image asset may be a better way to go for optimal performance. - * - * These properties are iOS only - for similar functionality on Android, use the [`elevation` - * property](docs/viewstyleproptypes.html#elevation). - */ -const ShadowPropTypesIOS = { - /** - * Sets the drop shadow color - * @platform ios - */ - shadowColor: DeprecatedColorPropType, - /** - * Sets the drop shadow offset - * @platform ios - */ - shadowOffset: ReactPropTypes.shape({ - width: ReactPropTypes.number, - height: ReactPropTypes.number, - }), - /** - * Sets the drop shadow opacity (multiplied by the color's alpha component) - * @platform ios - */ - shadowOpacity: ReactPropTypes.number, - /** - * Sets the drop shadow blur radius - * @platform ios - */ - shadowRadius: ReactPropTypes.number, -}; - -module.exports = ShadowPropTypesIOS; diff --git a/Libraries/Components/View/ViewStylePropTypes.js b/Libraries/Components/View/ViewStylePropTypes.js index 0eb945d58ce..486d7426e58 100644 --- a/Libraries/Components/View/ViewStylePropTypes.js +++ b/Libraries/Components/View/ViewStylePropTypes.js @@ -13,7 +13,7 @@ const DeprecatedColorPropType = require('DeprecatedColorPropType'); const LayoutPropTypes = require('LayoutPropTypes'); const ReactPropTypes = require('prop-types'); -const ShadowPropTypesIOS = require('ShadowPropTypesIOS'); +const DeprecatedShadowPropTypesIOS = require('DeprecatedShadowPropTypesIOS'); const DeprecatedTransformPropTypes = require('DeprecatedTransformPropTypes'); /** @@ -21,7 +21,7 @@ const DeprecatedTransformPropTypes = require('DeprecatedTransformPropTypes'); */ const ViewStylePropTypes = { ...LayoutPropTypes, - ...ShadowPropTypesIOS, + ...DeprecatedShadowPropTypesIOS, ...DeprecatedTransformPropTypes, backfaceVisibility: ReactPropTypes.oneOf(['visible', 'hidden']), backgroundColor: DeprecatedColorPropType, diff --git a/Libraries/DeprecatedPropTypes/DeprecatedShadowPropTypesIOS.js b/Libraries/DeprecatedPropTypes/DeprecatedShadowPropTypesIOS.js new file mode 100644 index 00000000000..889b5624938 --- /dev/null +++ b/Libraries/DeprecatedPropTypes/DeprecatedShadowPropTypesIOS.js @@ -0,0 +1,25 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + * @format + */ +'use strict'; + +const DeprecatedColorPropType = require('DeprecatedColorPropType'); +const ReactPropTypes = require('prop-types'); + +const DeprecatedShadowPropTypesIOS = { + shadowColor: DeprecatedColorPropType, + shadowOffset: ReactPropTypes.shape({ + width: ReactPropTypes.number, + height: ReactPropTypes.number, + }), + shadowOpacity: ReactPropTypes.number, + shadowRadius: ReactPropTypes.number, +}; + +module.exports = DeprecatedShadowPropTypesIOS; diff --git a/Libraries/Image/ImageStylePropTypes.js b/Libraries/Image/ImageStylePropTypes.js index ebb7603ae84..20088ace1ab 100644 --- a/Libraries/Image/ImageStylePropTypes.js +++ b/Libraries/Image/ImageStylePropTypes.js @@ -13,12 +13,12 @@ const DeprecatedColorPropType = require('DeprecatedColorPropType'); const ImageResizeMode = require('ImageResizeMode'); const LayoutPropTypes = require('LayoutPropTypes'); const ReactPropTypes = require('prop-types'); -const ShadowPropTypesIOS = require('ShadowPropTypesIOS'); +const DeprecatedShadowPropTypesIOS = require('DeprecatedShadowPropTypesIOS'); const DeprecatedTransformPropTypes = require('DeprecatedTransformPropTypes'); const ImageStylePropTypes = { ...LayoutPropTypes, - ...ShadowPropTypesIOS, + ...DeprecatedShadowPropTypesIOS, ...DeprecatedTransformPropTypes, resizeMode: ReactPropTypes.oneOf(Object.keys(ImageResizeMode)), backfaceVisibility: ReactPropTypes.oneOf(['visible', 'hidden']), diff --git a/Libraries/StyleSheet/StyleSheetTypes.js b/Libraries/StyleSheet/StyleSheetTypes.js index 6b50b6bf9a8..cb26104a168 100644 --- a/Libraries/StyleSheet/StyleSheetTypes.js +++ b/Libraries/StyleSheet/StyleSheetTypes.js @@ -131,13 +131,38 @@ export type ____TransformStyle_Internal = $ReadOnly<{| >, |}>; +/** + * These props can be used to dynamically generate shadows on views, images, text, etc. + * + * Because they are dynamically generated, they may cause performance regressions. Static + * shadow image asset may be a better way to go for optimal performance. + * + * These properties are iOS only - for similar functionality on Android, use the [`elevation` + * property](docs/viewstyleproptypes.html#elevation). + */ export type ____ShadowStyle_Internal = $ReadOnly<{| + /** + * Sets the drop shadow color + * @platform ios + */ shadowColor?: ColorValue, + /** + * Sets the drop shadow offset + * @platform ios + */ shadowOffset?: $ReadOnly<{| width?: number, height?: number, |}>, + /** + * Sets the drop shadow opacity (multiplied by the color's alpha component) + * @platform ios + */ shadowOpacity?: number | AnimatedNode, + /** + * Sets the drop shadow blur radius + * @platform ios + */ shadowRadius?: number, |}>;