Skip to content

Commit

Permalink
fix keyboard avoidance on android
Browse files Browse the repository at this point in the history
  • Loading branch information
calintamas committed Mar 2, 2021
1 parent 3117999 commit c179c42
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import InfoToast from './components/info';
import { complement } from './utils/arr';
import { includeKeys } from './utils/obj';
import { stylePropType } from './utils/prop-types';
import { isIOS } from './utils/platform';
import styles from './styles';

const FRICTION = 8;
Expand Down Expand Up @@ -126,14 +127,15 @@ class Toast extends Component {
}

componentDidMount() {
this.keyboardDidShowListener = Keyboard.addListener(
'keyboardDidShow',
this.keyboardDidShow
);
this.keyboardDidHideListner = Keyboard.addListener(
'keyboardDidHide',
this.keyboardDidHide
);
const noop = {
remove: () => {}
};
this.keyboardDidShowListener = isIOS
? Keyboard.addListener('keyboardDidShow', this.keyboardDidShow)
: noop;
this.keyboardDidHideListner = isIOS
? Keyboard.addListener('keyboardDidHide', this.keyboardDidHide)
: noop;
}

componentWillUnmount() {
Expand Down
5 changes: 5 additions & 0 deletions src/utils/platform.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Platform } from 'react-native';

const isIOS = Platform.OS === 'ios';

export { isIOS };

0 comments on commit c179c42

Please sign in to comment.