Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/components/SwipeableView/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default ({children}) => children;

// Swipeable View is available just on Android/iOS for now.
40 changes: 40 additions & 0 deletions src/components/SwipeableView/index.native.js
Original file line number Diff line number Diff line change
@@ -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
<View {...this.panResponder.panHandlers}>
{this.props.children}
</View>
);
}
}

SwipeableView.propTypes = propTypes;
SwipeableView.displayName = 'SwipeableView';
export default SwipeableView;
1 change: 1 addition & 0 deletions src/components/TextInputFocusable/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class TextInputFocusable extends React.Component {
<TextInput
ref={el => this.textInput = el}
maxHeight={116}
rejectResponderTermination={false}
/* eslint-disable-next-line react/jsx-props-no-spreading */
{...this.props}
/>
Expand Down
13 changes: 8 additions & 5 deletions src/pages/home/report/ReportView.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -25,10 +26,12 @@ class ReportView extends React.Component {
<ReportActionsView
reportID={this.props.reportID}
/>
<ReportActionCompose
onSubmit={text => addAction(this.props.reportID, text)}
reportID={this.props.reportID}
/>
<SwipeableView onSwipeDown={() => Keyboard.dismiss()}>
<ReportActionCompose
onSubmit={text => addAction(this.props.reportID, text)}
reportID={this.props.reportID}
/>
</SwipeableView>
<KeyboardSpacer />
</View>
);
Expand Down