From 88e45ef60174fb1c630bb2effc9ed5990896ca57 Mon Sep 17 00:00:00 2001 From: Eric Rozell Date: Mon, 26 Feb 2018 12:47:26 -0500 Subject: [PATCH] Add platform hook for View style props Similar to the `ViewPropTypes` hook to allow customization of prop types for iOS and Android, it's also useful to allow platforms to override style prop types. --- .../PlatformViewStylePropTypes.android.js | 20 +++++++++++++++++++ .../View/PlatformViewStylePropTypes.ios.js | 11 ++++++++++ .../Components/View/ViewStylePropTypes.js | 10 ++-------- 3 files changed, 33 insertions(+), 8 deletions(-) create mode 100644 Libraries/Components/View/PlatformViewStylePropTypes.android.js create mode 100644 Libraries/Components/View/PlatformViewStylePropTypes.ios.js diff --git a/Libraries/Components/View/PlatformViewStylePropTypes.android.js b/Libraries/Components/View/PlatformViewStylePropTypes.android.js new file mode 100644 index 00000000000000..22b7c60e30b8af --- /dev/null +++ b/Libraries/Components/View/PlatformViewStylePropTypes.android.js @@ -0,0 +1,20 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @providesModule PlatformViewStylePropTypes + * @flow + */ + +module.export = { + /** + * (Android-only) Sets the elevation of a view, using Android's underlying + * [elevation API](https://developer.android.com/training/material/shadows-clipping.html#Elevation). + * This adds a drop shadow to the item and affects z-order for overlapping views. + * Only supported on Android 5.0+, has no effect on earlier versions. + * @platform android + */ + elevation: ReactPropTypes.number, +}; diff --git a/Libraries/Components/View/PlatformViewStylePropTypes.ios.js b/Libraries/Components/View/PlatformViewStylePropTypes.ios.js new file mode 100644 index 00000000000000..fb50d2dc6546ed --- /dev/null +++ b/Libraries/Components/View/PlatformViewStylePropTypes.ios.js @@ -0,0 +1,11 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @providesModule PlatformViewStylePropTypes + * @flow + */ + +module.export = {}; diff --git a/Libraries/Components/View/ViewStylePropTypes.js b/Libraries/Components/View/ViewStylePropTypes.js index 6e9c92163b3181..c0fdf4e6f6ecec 100644 --- a/Libraries/Components/View/ViewStylePropTypes.js +++ b/Libraries/Components/View/ViewStylePropTypes.js @@ -12,6 +12,7 @@ var ColorPropType = require('ColorPropType'); var LayoutPropTypes = require('LayoutPropTypes'); var ReactPropTypes = require('prop-types'); +var PlatformViewStylePropTypes = require('PlatformViewStylePropTypes'); var ShadowPropTypesIOS = require('ShadowPropTypesIOS'); var TransformPropTypes = require('TransformPropTypes'); @@ -20,6 +21,7 @@ var TransformPropTypes = require('TransformPropTypes'); */ var ViewStylePropTypes = { ...LayoutPropTypes, + ...PlatformViewStylePropTypes, ...ShadowPropTypesIOS, ...TransformPropTypes, backfaceVisibility: ReactPropTypes.oneOf(['visible', 'hidden']), @@ -47,14 +49,6 @@ var ViewStylePropTypes = { borderBottomWidth: ReactPropTypes.number, borderLeftWidth: ReactPropTypes.number, opacity: ReactPropTypes.number, - /** - * (Android-only) Sets the elevation of a view, using Android's underlying - * [elevation API](https://developer.android.com/training/material/shadows-clipping.html#Elevation). - * This adds a drop shadow to the item and affects z-order for overlapping views. - * Only supported on Android 5.0+, has no effect on earlier versions. - * @platform android - */ - elevation: ReactPropTypes.number, }; module.exports = ViewStylePropTypes;