diff --git a/src/components/SwipeableView/index.js b/src/components/SwipeableView/index.js new file mode 100644 index 000000000000..96640b107608 --- /dev/null +++ b/src/components/SwipeableView/index.js @@ -0,0 +1,3 @@ +export default ({children}) => children; + +// Swipeable View is available just on Android/iOS for now. diff --git a/src/components/SwipeableView/index.native.js b/src/components/SwipeableView/index.native.js new file mode 100644 index 000000000000..b43d01a40f45 --- /dev/null +++ b/src/components/SwipeableView/index.native.js @@ -0,0 +1,40 @@ +import React, {PureComponent} from 'react'; +import {PanResponder, View} from 'react-native'; +import PropTypes from 'prop-types'; + +const propTypes = { + children: PropTypes.element.isRequired, + + // Callback to fire when the user swipes down on the child content + onSwipeDown: PropTypes.func.isRequired, +}; + +class SwipeableView extends PureComponent { + constructor(props) { + super(props); + + const minimumPixelDistance = 3; + this.panResponder = PanResponder.create({ + + // The PanResponder gets focus only when the y-axis movement is over minimumPixelDistance + onMoveShouldSetPanResponderCapture: + (_event, gestureState) => gestureState.dy > minimumPixelDistance, + + // Calls the callback when the swipe down is released; after the completion of the gesture + onPanResponderRelease: this.props.onSwipeDown, + }); + } + + render() { + return ( + // eslint-disable-next-line react/jsx-props-no-spreading + + {this.props.children} + + ); + } +} + +SwipeableView.propTypes = propTypes; +SwipeableView.displayName = 'SwipeableView'; +export default SwipeableView; diff --git a/src/components/TextInputFocusable/index.native.js b/src/components/TextInputFocusable/index.native.js index ce2c711e4941..a7d571949d02 100644 --- a/src/components/TextInputFocusable/index.native.js +++ b/src/components/TextInputFocusable/index.native.js @@ -47,6 +47,7 @@ class TextInputFocusable extends React.Component { this.textInput = el} maxHeight={116} + rejectResponderTermination={false} /* eslint-disable-next-line react/jsx-props-no-spreading */ {...this.props} /> diff --git a/src/pages/home/report/ReportView.js b/src/pages/home/report/ReportView.js index ce597338af06..d1f8c508e956 100644 --- a/src/pages/home/report/ReportView.js +++ b/src/pages/home/report/ReportView.js @@ -1,11 +1,12 @@ import React from 'react'; -import {View} from 'react-native'; +import {Keyboard, View} from 'react-native'; import PropTypes from 'prop-types'; import ReportActionsView from './ReportActionsView'; import ReportActionCompose from './ReportActionCompose'; import {addAction} from '../../../libs/actions/Report'; import KeyboardSpacer from '../../../components/KeyboardSpacer'; import styles from '../../../styles/styles'; +import SwipeableView from '../../../components/SwipeableView'; const propTypes = { // The ID of the report actions will be created for @@ -25,10 +26,12 @@ class ReportView extends React.Component { - addAction(this.props.reportID, text)} - reportID={this.props.reportID} - /> + Keyboard.dismiss()}> + addAction(this.props.reportID, text)} + reportID={this.props.reportID} + /> + );