zl-react-native-gifted-chat
Version:
The most complete chat UI for React Native, based on 'react-native-gifted-chat'
69 lines (64 loc) • 1.59 kB
JavaScript
import React from 'react';
import {
Platform,
StyleSheet,
TextInput,
} from 'react-native';
export default class Composer extends React.Component {
render() {
return (
<TextInput
placeholder={this.props.placeholder}
placeholderTextColor={this.props.placeholderTextColor}
multiline={true}
onChange={(e) => {
this.props.onChange(e);
}}
style={[styles.textInput, this.props.textInputStyle, {
height: this.props.composerHeight,
}]}
value={this.props.text}
enablesReturnKeyAutomatically={true}
underlineColorAndroid="transparent"
{...this.props.textInputProps}
/>
);
}
}
const styles = StyleSheet.create({
textInput: {
flex: 1,
marginLeft: 10,
fontSize: 16,
lineHeight: 16,
marginTop: Platform.select({
ios: 6,
android: 0,
}),
marginBottom: Platform.select({
ios: 5,
android: 3,
}),
},
});
Composer.defaultProps = {
textInputStyle: {},
onChange: () => {},
composerHeight: Platform.select({
ios: 33,
android: 41,
}), // TODO SHARE with GiftedChat.js and tests
text: '',
placeholder: 'Type a message...',
placeholderTextColor: '#b2b2b2',
textInputProps: null,
};
Composer.propTypes = {
textInputStyle: React.PropTypes.object,
onChange: React.PropTypes.func,
composerHeight: React.PropTypes.number,
text: React.PropTypes.string,
placeholder: React.PropTypes.string,
placeholderTextColor: React.PropTypes.string,
textInputProps: React.PropTypes.object,
};