TVViewPropTypes, PlatformViewPropTypes, DeprecatedTVViewPropTypes (#21372)

Summary:
Related to #21342

- Split TVViewPropTypes
- PlatformViewPropTypes (dependencies) flow types and old prop-type definitions
- ViewStylePropTypes (dependencies) rm prop-type

Flow tests succeed

[GENERAL] [ENHANCEMENT] [TVViewPropTypes.js] - rm prop-types
[GENERAL] [ENHANCEMENT] [PlatformViewPropTypes.android.js] - replace prop-types by Flow
[GENERAL] [ENHANCEMENT] [PlatformViewPropTypes.ios.js] - replace prop-types by Flow
[GENERAL] [ENHANCEMENT] [DeprecatedTVViewPropTypes.js] - old prop-types
Pull Request resolved: https://github.com/facebook/react-native/pull/21372

Differential Revision: D10095528

Pulled By: TheSavior

fbshipit-source-id: 4fc52ab194f680f95aabefedcbf119d6897672b7
This commit is contained in:
Thomas BARRAS 2018-09-27 16:24:52 -07:00 committed by Facebook Github Bot
parent 0da7e8d9ae
commit e3ae85d7c7
5 changed files with 96 additions and 53 deletions

View File

@ -9,76 +9,85 @@
*/ */
'use strict'; 'use strict';
const PropTypes = require('prop-types');
type TVParallaxPropertiesType = $ReadOnly<{|
/**
* If true, parallax effects are enabled. Defaults to true.
*/
enabled: boolean,
/**
* Defaults to 2.0.
*/
shiftDistanceX: number,
/**
* Defaults to 2.0.
*/
shiftDistanceY: number,
/**
* Defaults to 0.05.
*/
tiltAngle: number,
/**
* Defaults to 1.0
*/
magnification: number,
|}>;
/** /**
* Additional View properties for Apple TV * Additional View properties for Apple TV
*/ */
const TVViewPropTypes = { export type TVViewProps = $ReadOnly<{|
/** /**
* When set to true, this view will be focusable * *(Apple TV only)* When set to true, this view will be focusable
* and navigable using the TV remote. * and navigable using the Apple TV remote.
*
* @platform ios
*/ */
isTVSelectable: PropTypes.bool, isTVSelectable?: boolean,
/** /**
* May be set to true to force the TV focus engine to move focus to this view. * *(Apple TV only)* May be set to true to force the Apple TV focus engine to move focus to this view.
*
* @platform ios
*/ */
hasTVPreferredFocus: PropTypes.bool, hasTVPreferredFocus?: boolean,
/** /**
* *(Apple TV only)* Object with properties to control Apple TV parallax effects. * *(Apple TV only)* Object with properties to control Apple TV parallax effects.
* *
* enabled: If true, parallax effects are enabled. Defaults to true.
* shiftDistanceX: Defaults to 2.0.
* shiftDistanceY: Defaults to 2.0.
* tiltAngle: Defaults to 0.05.
* magnification: Defaults to 1.0.
* pressMagnification: Defaults to 1.0.
* pressDuration: Defaults to 0.3.
* pressDelay: Defaults to 0.0.
*
* @platform ios * @platform ios
*/ */
tvParallaxProperties: PropTypes.object, tvParallaxProperties?: TVParallaxPropertiesType,
/** /**
* *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 2.0. * *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 2.0.
* *
* @platform ios * @platform ios
*/ */
tvParallaxShiftDistanceX: PropTypes.number, tvParallaxShiftDistanceX?: number,
/** /**
* *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 2.0. * *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 2.0.
* *
* @platform ios * @platform ios
*/ */
tvParallaxShiftDistanceY: PropTypes.number, tvParallaxShiftDistanceY?: number,
/** /**
* *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 0.05. * *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 0.05.
* *
* @platform ios * @platform ios
*/ */
tvParallaxTiltAngle: PropTypes.number, tvParallaxTiltAngle?: number,
/** /**
* *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 1.0. * *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 1.0.
* *
* @platform ios * @platform ios
*/ */
tvParallaxMagnification: PropTypes.number,
};
export type TVViewProps = $ReadOnly<{|
isTVSelectable?: boolean,
hasTVPreferredFocus?: boolean,
tvParallaxProperties?: Object,
tvParallaxShiftDistanceX?: number,
tvParallaxShiftDistanceY?: number,
tvParallaxTiltAngle?: number,
tvParallaxMagnification?: number, tvParallaxMagnification?: number,
|}>; |}>;
module.exports = TVViewPropTypes;

View File

@ -0,0 +1,14 @@
/**
* 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.
*
* @providesModule PlatformViewPropTypes
* @format
* @flow
*/
'use strict';
export type PlatformViewPropTypes = {};

View File

@ -0,0 +1,16 @@
/**
* 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.
*
* @providesModule PlatformViewPropTypes
* @format
* @flow
*/
'use strict';
import type {TVViewProps} from 'TVViewPropTypes';
export type PlatformViewPropTypes = TVViewProps;

View File

@ -1,21 +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.
*
* @format
* @flow strict-local
*/
const Platform = require('Platform');
let TVViewPropTypes = {};
// We need to always include TVViewPropTypes on Android
// as unlike on iOS we can't detect TV devices at build time
// and hence make view manager export a different list of native properties.
if (Platform.isTV || Platform.OS === 'android') {
TVViewPropTypes = require('TVViewPropTypes');
}
module.exports = TVViewPropTypes;

View File

@ -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.
*
* @format
* @flow
*/
'use strict';
const PropTypes = require('prop-types');
const DeprecatedTVViewPropTypes = {
isTVSelectable: PropTypes.bool,
hasTVPreferredFocus: PropTypes.bool,
tvParallaxProperties: PropTypes.object,
tvParallaxShiftDistanceX: PropTypes.number,
tvParallaxShiftDistanceY: PropTypes.number,
tvParallaxTiltAngle: PropTypes.number,
tvParallaxMagnification: PropTypes.number,
};
module.exports = DeprecatedTVViewPropTypes;