Skip to content

Commit f0c18dc

Browse files
elicwhitefacebook-github-bot
authored andcommitted
Flow type TouchableHighlight
Reviewed By: yungsters Differential Revision: D7983631 fbshipit-source-id: 98b3708b26e2bf96426d5acaa5c7e2311a3a34f6
1 parent 6b3aad3 commit f0c18dc

File tree

5 files changed

+35
-17
lines changed

5 files changed

+35
-17
lines changed

Libraries/Components/Touchable/TouchableHighlight.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ const createReactClass = require('create-react-class');
2525
const ensurePositiveDelayProps = require('ensurePositiveDelayProps');
2626

2727
import type {PressEvent} from 'CoreEventTypes';
28+
import type {Props as TouchableWithoutFeedbackProps} from 'TouchableWithoutFeedback';
29+
import type {ViewStyleProp} from 'StyleSheet';
30+
import type {ColorValue} from 'StyleSheetTypes';
2831

2932
const DEFAULT_PROPS = {
3033
activeOpacity: 0.85,
@@ -34,6 +37,23 @@ const DEFAULT_PROPS = {
3437

3538
const PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};
3639

40+
type IOSProps = $ReadOnly<{|
41+
hasTVPreferredFocus?: ?boolean,
42+
tvParallaxProperties?: ?Object,
43+
|}>;
44+
45+
type Props = $ReadOnly<{|
46+
...TouchableWithoutFeedbackProps,
47+
...IOSProps,
48+
49+
activeOpacity?: ?number,
50+
underlayColor?: ?ColorValue,
51+
style?: ?ViewStyleProp,
52+
onShowUnderlay?: ?Function,
53+
onHideUnderlay?: ?Function,
54+
testOnly_pressed?: ?boolean,
55+
|}>;
56+
3757
/**
3858
* A wrapper for making views respond properly to touches.
3959
* On press down, the opacity of the wrapped view is decreased, which allows
@@ -131,7 +151,7 @@ const PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};
131151
*
132152
*/
133153

134-
const TouchableHighlight = createReactClass({
154+
const TouchableHighlight = ((createReactClass({
135155
displayName: 'TouchableHighlight',
136156
propTypes: {
137157
...TouchableWithoutFeedback.propTypes,
@@ -362,6 +382,6 @@ const TouchableHighlight = createReactClass({
362382
</View>
363383
);
364384
},
365-
});
385+
}): any): React.ComponentType<Props>);
366386

367387
module.exports = TouchableHighlight;

Libraries/Components/Touchable/TouchableWithoutFeedback.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,11 @@
1313
const EdgeInsetsPropType = require('EdgeInsetsPropType');
1414
const React = require('React');
1515
const PropTypes = require('prop-types');
16-
/* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error
17-
* found when Flow v0.54 was deployed. To see the error delete this comment and
18-
* run Flow. */
1916
const TimerMixin = require('react-timer-mixin');
2017
const Touchable = require('Touchable');
2118

2219
const createReactClass = require('create-react-class');
2320
const ensurePositiveDelayProps = require('ensurePositiveDelayProps');
24-
/* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error
25-
* found when Flow v0.54 was deployed. To see the error delete this comment and
26-
* run Flow. */
2721
const warning = require('fbjs/lib/warning');
2822

2923
const {
@@ -35,21 +29,21 @@ import type {PressEvent} from 'CoreEventTypes';
3529
import type {EdgeInsetsProp} from 'EdgeInsetsPropType';
3630
import type {
3731
AccessibilityComponentType,
38-
AccessibilityTrait,
32+
AccessibilityTraits as AccessibilityTraitsFlow,
3933
} from 'ViewAccessibility';
4034

4135
const PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};
4236

43-
type Props = $ReadOnly<{|
44-
accessible?: boolean,
45-
accessibilityComponentType?: AccessibilityComponentType,
37+
export type Props = $ReadOnly<{|
38+
accessible?: ?boolean,
39+
accessibilityComponentType?: ?AccessibilityComponentType,
4640
accessibilityLabel?:
4741
| null
4842
| React$PropType$Primitive<any>
4943
| string
5044
| Array<any>
5145
| any,
52-
accessibilityTraits?: AccessibilityTrait | Array<AccessibilityTrait>,
46+
accessibilityTraits?: ?AccessibilityTraitsFlow,
5347
children?: ?React.Node,
5448
delayLongPress?: ?number,
5549
delayPressIn?: ?number,

Libraries/Components/View/ViewAccessibility.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ export type AccessibilityTrait =
2929
| 'allowsDirectInteraction'
3030
| 'pageTurn';
3131

32+
export type AccessibilityTraits =
33+
| AccessibilityTrait
34+
| $ReadOnlyArray<AccessibilityTrait>;
35+
3236
export type AccessibilityComponentType =
3337
| 'none'
3438
| 'button'

RNTester/js/RNTesterExampleList.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ class RowComponent extends React.PureComponent<{
5353
render() {
5454
const {item} = this.props;
5555
return (
56-
<TouchableHighlight {...this.props} onPress={this._onPress}>
56+
<TouchableHighlight
57+
onShowUnderlay={this.props.onShowUnderlay}
58+
onHideUnderlay={this.props.onHideUnderlay}
59+
onPress={this._onPress}>
5760
<View style={styles.row}>
5861
<Text style={styles.rowTitleText}>{item.module.title}</Text>
5962
<Text style={styles.rowDetailText}>{item.module.description}</Text>

RNTester/js/TouchableExample.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ exports.examples = [
5555
<TouchableHighlight
5656
style={styles.wrapper}
5757
activeOpacity={1}
58-
animationVelocity={0}
5958
tvParallaxProperties={{
6059
pressMagnification: 1.3,
6160
pressDuration: 0.6,
@@ -348,7 +347,6 @@ class TouchableDisabled extends React.Component<{}> {
348347
<TouchableHighlight
349348
activeOpacity={1}
350349
disabled={true}
351-
animationVelocity={0}
352350
underlayColor="rgb(210, 230, 255)"
353351
style={[styles.row, styles.block]}
354352
onPress={() => console.log('custom THW text - highlight')}>
@@ -357,7 +355,6 @@ class TouchableDisabled extends React.Component<{}> {
357355

358356
<TouchableHighlight
359357
activeOpacity={1}
360-
animationVelocity={0}
361358
underlayColor="rgb(210, 230, 255)"
362359
style={[styles.row, styles.block]}
363360
onPress={() => console.log('custom THW text - highlight')}>

0 commit comments

Comments
 (0)