Skip to content

Commit

Permalink
Flow strict TouchableHighlight (#22173)
Browse files Browse the repository at this point in the history
Summary:
Related to #22100

Enhance Flow types for TouchableOpacity specifying underlay functions and TvParallaxPropertiesType.
I had to export and enhance TvParallaxPropertiesType from TVViewPropTypes file. This does not break this other PR also using this exported type. #22146

There is still some work to do in order to turn flow to strict mode.

- All flow tests succeed.

[GENERAL] [ENHANCEMENT] [TouchableHighlight.js] - Flow types
[GENERAL] [ENHANCEMENT] [TVViewPropTypes.js] - Export and enhance type
Pull Request resolved: #22173

Differential Revision: D13033441

Pulled By: RSNara

fbshipit-source-id: 26a38970923dc7e6c02c03da5d08483a3f1fbd36
  • Loading branch information
exced authored and facebook-github-bot committed Nov 21, 2018
1 parent f22473e commit a97d104
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
25 changes: 20 additions & 5 deletions Libraries/Components/AppleTV/TVViewPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,42 @@ export type TVParallaxPropertiesType = $ReadOnly<{|
/**
* If true, parallax effects are enabled. Defaults to true.
*/
enabled: boolean,
enabled?: boolean,

/**
* Defaults to 2.0.
*/
shiftDistanceX: number,
shiftDistanceX?: number,

/**
* Defaults to 2.0.
*/
shiftDistanceY: number,
shiftDistanceY?: number,

/**
* Defaults to 0.05.
*/
tiltAngle: number,
tiltAngle?: number,

/**
* Defaults to 1.0
*/
magnification: number,
magnification?: number,

/**
* Defaults to 1.0
*/
pressMagnification?: number,

/**
* Defaults to 0.3
*/
pressDuration?: number,

/**
* Defaults to 0.3
*/
pressDelay?: number,
|}>;

/**
Expand Down
20 changes: 5 additions & 15 deletions Libraries/Components/Touchable/TouchableHighlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import type {PressEvent} from 'CoreEventTypes';
import type {ViewStyleProp} from 'StyleSheet';
import type {ColorValue} from 'StyleSheetTypes';
import type {Props as TouchableWithoutFeedbackProps} from 'TouchableWithoutFeedback';
import type {TVParallaxPropertiesType} from 'TVViewPropTypes';

const DEFAULT_PROPS = {
activeOpacity: 0.85,
Expand All @@ -39,7 +40,7 @@ const PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};

type IOSProps = $ReadOnly<{|
hasTVPreferredFocus?: ?boolean,
tvParallaxProperties?: ?Object,
tvParallaxProperties?: ?TVParallaxPropertiesType,
|}>;

type Props = $ReadOnly<{|
Expand All @@ -49,8 +50,8 @@ type Props = $ReadOnly<{|
activeOpacity?: ?number,
underlayColor?: ?ColorValue,
style?: ?ViewStyleProp,
onShowUnderlay?: ?Function,
onHideUnderlay?: ?Function,
onShowUnderlay?: ?() => void,
onHideUnderlay?: ?() => void,
testOnly_pressed?: ?boolean,
|}>;

Expand Down Expand Up @@ -185,18 +186,7 @@ const TouchableHighlight = ((createReactClass({
*/
hasTVPreferredFocus: PropTypes.bool,
/**
* *(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
* Apple TV parallax effects
*/
tvParallaxProperties: PropTypes.object,
/**
Expand Down

0 comments on commit a97d104

Please sign in to comment.