Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update when topSpacing prop is changed. #56

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
27 changes: 19 additions & 8 deletions KeyboardSpacer.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ export default class KeyboardSpacer extends Component {
// when external physical keyboard is connected
// event.endCoordinates.height still equals virtual keyboard height
// however only the keyboard toolbar is showing if there should be one
const keyboardSpace = (screenHeight - event.endCoordinates.screenY) + this.props.topSpacing;
const keyboardSpace = screenHeight - event.endCoordinates.screenY;
this.setState({
keyboardSpace,
isKeyboardOpened: true
}, this.props.onToggle(true, keyboardSpace));
keyboardSpace,
isKeyboardOpened: true
}, this.props.onToggle(true, keyboardSpace));
}

resetKeyboardSpace(event) {
Expand All @@ -108,13 +108,24 @@ export default class KeyboardSpacer extends Component {
LayoutAnimation.configureNext(animationConfig);

this.setState({
keyboardSpace: 0,
isKeyboardOpened: false
}, this.props.onToggle(false, 0));
keyboardSpace: 0,
isKeyboardOpened: false
}, this.props.onToggle(false, 0));
}

render() {
return (
<View style={[styles.container, { height: this.state.keyboardSpace }, this.props.style]} />);
<View
style={[
styles.container,
{
height:
this.state.keyboardSpace +
(this.state.isKeyboardOpened ? this.props.topSpacing : 0)
},
this.props.style
]}
/>
);
}
}