Skip to content

Commit aeb87cb

Browse files
excedfacebook-github-bot
authored andcommitted
Flow strict TouchableHighlight (facebook#22173)
Summary: Related to facebook#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. facebook#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: facebook#22173 Differential Revision: D13033441 Pulled By: RSNara fbshipit-source-id: 26a38970923dc7e6c02c03da5d08483a3f1fbd36
1 parent dbd501f commit aeb87cb

File tree

2 files changed

+25
-20
lines changed

2 files changed

+25
-20
lines changed

Libraries/Components/AppleTV/TVViewPropTypes.js

+20-5
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,42 @@ export type TVParallaxPropertiesType = $ReadOnly<{|
1414
/**
1515
* If true, parallax effects are enabled. Defaults to true.
1616
*/
17-
enabled: boolean,
17+
enabled?: boolean,
1818

1919
/**
2020
* Defaults to 2.0.
2121
*/
22-
shiftDistanceX: number,
22+
shiftDistanceX?: number,
2323

2424
/**
2525
* Defaults to 2.0.
2626
*/
27-
shiftDistanceY: number,
27+
shiftDistanceY?: number,
2828

2929
/**
3030
* Defaults to 0.05.
3131
*/
32-
tiltAngle: number,
32+
tiltAngle?: number,
3333

3434
/**
3535
* Defaults to 1.0
3636
*/
37-
magnification: number,
37+
magnification?: number,
38+
39+
/**
40+
* Defaults to 1.0
41+
*/
42+
pressMagnification?: number,
43+
44+
/**
45+
* Defaults to 0.3
46+
*/
47+
pressDuration?: number,
48+
49+
/**
50+
* Defaults to 0.3
51+
*/
52+
pressDelay?: number,
3853
|}>;
3954

4055
/**

Libraries/Components/Touchable/TouchableHighlight.js

+5-15
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import type {PressEvent} from 'CoreEventTypes';
2828
import type {ViewStyleProp} from 'StyleSheet';
2929
import type {ColorValue} from 'StyleSheetTypes';
3030
import type {Props as TouchableWithoutFeedbackProps} from 'TouchableWithoutFeedback';
31+
import type {TVParallaxPropertiesType} from 'TVViewPropTypes';
3132

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

4041
type IOSProps = $ReadOnly<{|
4142
hasTVPreferredFocus?: ?boolean,
42-
tvParallaxProperties?: ?Object,
43+
tvParallaxProperties?: ?TVParallaxPropertiesType,
4344
|}>;
4445

4546
type Props = $ReadOnly<{|
@@ -49,8 +50,8 @@ type Props = $ReadOnly<{|
4950
activeOpacity?: ?number,
5051
underlayColor?: ?ColorValue,
5152
style?: ?ViewStyleProp,
52-
onShowUnderlay?: ?Function,
53-
onHideUnderlay?: ?Function,
53+
onShowUnderlay?: ?() => void,
54+
onHideUnderlay?: ?() => void,
5455
testOnly_pressed?: ?boolean,
5556
|}>;
5657

@@ -185,18 +186,7 @@ const TouchableHighlight = ((createReactClass({
185186
*/
186187
hasTVPreferredFocus: PropTypes.bool,
187188
/**
188-
* *(Apple TV only)* Object with properties to control Apple TV parallax effects.
189-
*
190-
* enabled: If true, parallax effects are enabled. Defaults to true.
191-
* shiftDistanceX: Defaults to 2.0.
192-
* shiftDistanceY: Defaults to 2.0.
193-
* tiltAngle: Defaults to 0.05.
194-
* magnification: Defaults to 1.0.
195-
* pressMagnification: Defaults to 1.0.
196-
* pressDuration: Defaults to 0.3.
197-
* pressDelay: Defaults to 0.0.
198-
*
199-
* @platform ios
189+
* Apple TV parallax effects
200190
*/
201191
tvParallaxProperties: PropTypes.object,
202192
/**

0 commit comments

Comments
 (0)