From 59105f6b1edb3c4dbbe78177ab8bb3e0ab405a09 Mon Sep 17 00:00:00 2001 From: Eric Rozell Date: Mon, 24 Jul 2017 12:00:43 -0700 Subject: [PATCH] Adds hook for platform-specific View props Summary: Platforms that plug in to react-native may require additional props that are specific to those platforms. For example, already in react-native there are props that are specific to Android (`accessibilityComponentType`, `needsOffscreenAlphaCompositing`, etc.), props that are specific to iOS (`accessibilityTraits`, `shouldRasterizeIOS`, etc.) and props that are specific to tvOS (`isTVSelectable`, `tvParallaxProperties`, etc.). I need to add properties to `react-native-windows`, and I'd prefer not to override the entire `ViewPropTypes` file as it is a risk that things in react-native-windows fall out of sync with react-native. Fixes #15173 Closes https://github.com/facebook/react-native/pull/15175 Differential Revision: D5481444 Pulled By: hramos fbshipit-source-id: 3da08716d03ccdf317ec447536eea3699dd7a760 --- .../View/PlatformViewPropTypes.android.js | 13 ++++++++++++ .../View/PlatformViewPropTypes.ios.js | 20 +++++++++++++++++++ Libraries/Components/View/ViewPropTypes.js | 9 ++------- 3 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 Libraries/Components/View/PlatformViewPropTypes.android.js create mode 100644 Libraries/Components/View/PlatformViewPropTypes.ios.js diff --git a/Libraries/Components/View/PlatformViewPropTypes.android.js b/Libraries/Components/View/PlatformViewPropTypes.android.js new file mode 100644 index 000000000..7d4734bda --- /dev/null +++ b/Libraries/Components/View/PlatformViewPropTypes.android.js @@ -0,0 +1,13 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule PlatformViewPropTypes + * @flow + */ + +module.export = {}; diff --git a/Libraries/Components/View/PlatformViewPropTypes.ios.js b/Libraries/Components/View/PlatformViewPropTypes.ios.js new file mode 100644 index 000000000..7957c7b4a --- /dev/null +++ b/Libraries/Components/View/PlatformViewPropTypes.ios.js @@ -0,0 +1,20 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule PlatformViewPropTypes + * @flow + */ + +const Platform = require('Platform'); + +var TVViewPropTypes = {}; +if (Platform.isTVOS) { + TVViewPropTypes = require('TVViewPropTypes'); +} + +module.exports = TVViewPropTypes; diff --git a/Libraries/Components/View/ViewPropTypes.js b/Libraries/Components/View/ViewPropTypes.js index 6e332f561..30cfc2020 100644 --- a/Libraries/Components/View/ViewPropTypes.js +++ b/Libraries/Components/View/ViewPropTypes.js @@ -12,7 +12,7 @@ 'use strict'; const EdgeInsetsPropType = require('EdgeInsetsPropType'); -const Platform = require('Platform'); +const PlatformViewPropTypes = require('PlatformViewPropTypes'); const PropTypes = require('prop-types'); const StyleSheetPropType = require('StyleSheetPropType'); const ViewStylePropTypes = require('ViewStylePropTypes'); @@ -22,11 +22,6 @@ const { AccessibilityTraits, } = require('ViewAccessibility'); -var TVViewPropTypes = {}; -if (Platform.isTVOS) { - TVViewPropTypes = require('TVViewPropTypes'); -} - import type { AccessibilityComponentType, AccessibilityTrait, @@ -85,7 +80,7 @@ export type ViewProps = { } & TVViewProps; module.exports = { - ...TVViewPropTypes, + ...PlatformViewPropTypes, /** * When `true`, indicates that the view is an accessibility element. By default,