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

Fix hidden TextInput on Android/Expo #737

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
},
"jest": {
"preset": "react-native",
"setupFiles": ["./tests/setup.js"]
"setupFiles": [
"./tests/setup.js"
]
},
"devDependencies": {
"babel": "6.23.0",
Expand All @@ -59,6 +61,7 @@
"prop-types": "15.6.0",
"react-native-communications": "2.2.1",
"react-native-invertible-scroll-view": "^1.1.0",
"react-native-keyboard-spacer": "^0.4.1",
"react-native-lightbox": "^0.7.0",
"react-native-parsed-text": "^0.0.20",
"shallowequal": "1.0.2",
Expand Down
26 changes: 20 additions & 6 deletions src/GiftedChat.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import PropTypes from 'prop-types';
import React from 'react';
import { Animated, Platform, StyleSheet, View } from 'react-native';
import KeyboardSpacer from 'react-native-keyboard-spacer';

import ActionSheet from '@expo/react-native-action-sheet';
import moment from 'moment';
Expand Down Expand Up @@ -322,6 +323,14 @@ class GiftedChat extends React.Component {
);
}

renderKeyboardSpacer() {
if (Platform.OS === 'android') {
return (<KeyboardSpacer />);
}
return null;
}


onSend(messages = [], shouldResetInputToolbar = false) {
if (!Array.isArray(messages)) {
messages = [messages];
Expand Down Expand Up @@ -475,12 +484,15 @@ class GiftedChat extends React.Component {
render() {
if (this.state.isInitialized === true) {
return (
<ActionSheet ref={(component) => (this._actionSheetRef = component)}>
<View style={styles.container} onLayout={this.onMainViewLayout}>
{this.renderMessages()}
{this.renderInputToolbar()}
</View>
</ActionSheet>
<View style={styles.container}>
<ActionSheet ref={(component) => (this._actionSheetRef = component)}>
<View style={styles.container} onLayout={this.onMainViewLayout}>
{this.renderMessages()}
{this.renderInputToolbar()}
</View>
</ActionSheet>
{this.renderKeyboardSpacer()}
</View>
);
}
return (
Expand Down Expand Up @@ -521,6 +533,7 @@ GiftedChat.defaultProps = {
onLoadEarlier: () => { },
isLoadingEarlier: false,
renderLoading: null,
renderKeyboardSpacer: null,
renderLoadEarlier: null,
renderAvatar: undefined,
showUserAvatar: false,
Expand Down Expand Up @@ -573,6 +586,7 @@ GiftedChat.propTypes = {
loadEarlier: PropTypes.bool,
onLoadEarlier: PropTypes.func,
isLoadingEarlier: PropTypes.bool,
renderKeyboardSpacer: PropTypes.func,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this props if you don't use it?

renderLoading: PropTypes.func,
renderLoadEarlier: PropTypes.func,
renderAvatar: PropTypes.func,
Expand Down