Skip to content

Commit

Permalink
Use keyboardDidShow/keyboardDidHide events for android
Browse files Browse the repository at this point in the history
  • Loading branch information
sbycrosz committed Feb 26, 2016
1 parent d7a9488 commit d206639
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions KeyboardSpacer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ var React = require('react-native');
var {
DeviceEventEmitter,
LayoutAnimation,
View
View,
Platform
} = React;

// From: https://medium.com/man-moon/writing-modern-react-native-ui-e317ff956f02
Expand Down Expand Up @@ -72,10 +73,17 @@ class KeyboardSpacer extends React.Component {
}

componentDidMount() {
this._listeners = [
DeviceEventEmitter.addListener('keyboardWillShow', this.updateKeyboardSpace),
DeviceEventEmitter.addListener('keyboardWillHide', this.resetKeyboardSpace)
];
if (Platform.OS == "android") {
this._listeners = [
DeviceEventEmitter.addListener('keyboardDidShow', this.updateKeyboardSpace),
DeviceEventEmitter.addListener('keyboardDidHide', this.resetKeyboardSpace)
];
} else {
this._listeners = [
DeviceEventEmitter.addListener('keyboardWillShow', this.updateKeyboardSpace),
DeviceEventEmitter.addListener('keyboardWillHide', this.resetKeyboardSpace)
];
}
}

componentWillUnmount() {
Expand Down

0 comments on commit d206639

Please sign in to comment.