Permalink
Browse files

Flow strict TouchableBounce (#22197)

Summary:
Related to #22100

Enhance TouchableBounce with press event types, callback and hitslop types.

There is still some work to do in order to turn flow to strict mode. (requireNativeComponent and render function)

- All flow tests succeed.

[GENERAL] [ENHANCEMENT] [TouchableBounce.js] - Flow types
Pull Request resolved: #22197

Reviewed By: TheSavior

Differential Revision: D13032452

Pulled By: RSNara

fbshipit-source-id: b21140722ce924698aa15323602e2e3fc663dbb6
  • Loading branch information...
exced authored and facebook-github-bot committed Nov 21, 2018
1 parent aad83cc commit 45c51835d69e111b67b4fcf1af39a13f7df1ee48
Showing with 8 additions and 9 deletions.
  1. +8 −9 Libraries/Components/Touchable/TouchableBounce.js
@@ -23,8 +23,7 @@ const createReactClass = require('create-react-class');
import type {EdgeInsetsProp} from 'EdgeInsetsPropType';
import type {ViewStyleProp} from 'StyleSheet';
import type {Props as TouchableWithoutFeedbackProps} from 'TouchableWithoutFeedback';

type Event = Object;
import type {PressEvent} from 'CoreEventTypes';

type State = {
animationID: ?number,
@@ -36,8 +35,8 @@ const PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};
type Props = $ReadOnly<{|
...TouchableWithoutFeedbackProps,

onPressWithCompletion?: ?Function,
onPressAnimationComplete?: ?Function,
onPressWithCompletion?: ?(fn: () => void) => void,
onPressAnimationComplete?: ?() => void,
pressRetentionOffset?: ?EdgeInsetsProp,
releaseVelocity?: ?number,
releaseBounciness?: ?number,
@@ -95,7 +94,7 @@ const TouchableBounce = ((createReactClass({
value: number,
velocity: number,
bounciness: number,
callback?: ?Function,
callback?: ?() => void,
) {
Animated.spring(this.state.scale, {
toValue: value,
@@ -116,17 +115,17 @@ const TouchableBounce = ((createReactClass({
* `Touchable.Mixin` self callbacks. The mixin will invoke these if they are
* defined on your component.
*/
touchableHandleActivePressIn: function(e: Event) {
touchableHandleActivePressIn: function(e: PressEvent) {
this.bounceTo(0.93, 0.1, 0);
this.props.onPressIn && this.props.onPressIn(e);
},

touchableHandleActivePressOut: function(e: Event) {
touchableHandleActivePressOut: function(e: PressEvent) {
this.bounceTo(1, 0.4, 0);
this.props.onPressOut && this.props.onPressOut(e);
},

touchableHandlePress: function(e: Event) {
touchableHandlePress: function(e: PressEvent) {
const onPressWithCompletion = this.props.onPressWithCompletion;
if (onPressWithCompletion) {
onPressWithCompletion(() => {
@@ -154,7 +153,7 @@ const TouchableBounce = ((createReactClass({
return this.props.pressRetentionOffset || PRESS_RETENTION_OFFSET;
},

touchableGetHitSlop: function(): ?Object {
touchableGetHitSlop: function(): ?EdgeInsetsProp {
return this.props.hitSlop;
},

0 comments on commit 45c5183

Please sign in to comment.