Skip to content

Commit

Permalink
Merge pull request #3733 from parasharrajat/swipekeyboard
Browse files Browse the repository at this point in the history
Fixed swipe on composer
  • Loading branch information
stitesExpensify authored Jun 24, 2021
2 parents cef11b7 + 38e1566 commit 11476f7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/CONST.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions src/components/SwipeableView/index.native.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, {PureComponent} from 'react';
import {PanResponder, View} from 'react-native';
import PropTypes from 'prop-types';
import CONST from '../../CONST';

const propTypes = {
children: PropTypes.element.isRequired,
Expand All @@ -13,12 +14,19 @@ class SwipeableView extends PureComponent {
constructor(props) {
super(props);

const minimumPixelDistance = 3;
const minimumPixelDistance = CONST.COMPOSER_MAX_HEIGHT;
this.oldY = 0;
this.panResponder = PanResponder.create({

// The PanResponder gets focus only when the y-axis movement is over minimumPixelDistance
// & swip direction is downwards
onMoveShouldSetPanResponderCapture:
(_event, gestureState) => gestureState.dy > minimumPixelDistance,
(_event, gestureState) => {
if ((gestureState.dy - this.oldY) > 0 && gestureState.dy > minimumPixelDistance) {
return true;
}
this.oldY = gestureState.dy;
},

// Calls the callback when the swipe down is released; after the completion of the gesture
onPanResponderRelease: this.props.onSwipeDown,
Expand Down
3 changes: 2 additions & 1 deletion src/components/TextInputFocusable/index.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {TextInput} from 'react-native';
import PropTypes from 'prop-types';
import _ from 'underscore';
import themeColors from '../../styles/themes/default';
import CONST from '../../CONST';

/**
* On native layers we like to have the Text Input not focused so the user can read new chats without they keyboard in
Expand Down Expand Up @@ -61,7 +62,7 @@ class TextInputFocusable extends React.Component {
<TextInput
placeholderTextColor={themeColors.placeholderText}
ref={el => this.textInput = el}
maxHeight={116}
maxHeight={CONST.COMPOSER_MAX_HEIGHT}
rejectResponderTermination={false}
editable={!this.props.isDisabled}
/* eslint-disable-next-line react/jsx-props-no-spreading */
Expand Down
3 changes: 2 additions & 1 deletion src/components/TextInputFocusable/index.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {TextInput} from 'react-native';
import PropTypes from 'prop-types';
import _ from 'underscore';
import themeColors from '../../styles/themes/default';
import CONST from '../../CONST';

/**
* On native layers we like to have the Text Input not focused so the user can read new chats without they keyboard in
Expand Down Expand Up @@ -73,7 +74,7 @@ class TextInputFocusable extends React.Component {
<TextInput
placeholderTextColor={themeColors.placeholderText}
ref={el => this.textInput = el}
maxHeight={116}
maxHeight={CONST.COMPOSER_MAX_HEIGHT}
rejectResponderTermination={false}
editable={!this.props.isDisabled}
/* eslint-disable-next-line react/jsx-props-no-spreading */
Expand Down

0 comments on commit 11476f7

Please sign in to comment.