UNPKG

zl-react-native-gifted-chat

Version:

The most complete chat UI for React Native, based on 'react-native-gifted-chat'

96 lines (85 loc) 2.03 kB
import React from 'react'; import { StyleSheet, View, } from 'react-native'; import Composer from './Composer'; import Send from './Send'; export default class InputToolbar extends React.Component { renderActions() { if (this.props.renderActions) { return this.props.renderActions(this.props); } return null; } renderSend() { if (this.props.renderSend) { return this.props.renderSend(this.props); } return <Send {...this.props}/>; } renderComposer() { if (this.props.renderComposer) { return this.props.renderComposer(this.props); } return ( <Composer {...this.props} /> ); } renderAccessory() { if (this.props.renderAccessory) { return ( <View style={[styles.accessory, this.props.accessoryStyle]}> {this.props.renderAccessory(this.props)} </View> ); } return null; } render() { return ( <View style={[styles.container, this.props.containerStyle]}> <View style={[styles.primary, this.props.primaryStyle]}> {this.renderActions()} {this.renderComposer()} {this.renderSend()} </View> {this.renderAccessory()} </View> ); } } const styles = StyleSheet.create({ container: { borderTopWidth: StyleSheet.hairlineWidth, borderTopColor: '#b2b2b2', backgroundColor: '#FFFFFF', }, primary: { flexDirection: 'row', alignItems: 'flex-end', }, accessory: { height: 44, }, }); InputToolbar.defaultProps = { containerStyle: {}, primaryStyle: {}, accessoryStyle: {}, renderAccessory: null, renderActions: null, renderSend: null, renderComposer: null, }; InputToolbar.propTypes = { containerStyle: React.PropTypes.object, primaryStyle: React.PropTypes.object, accessoryStyle: React.PropTypes.object, renderAccessory: React.PropTypes.func, renderActions: React.PropTypes.func, renderSend: React.PropTypes.func, renderComposer: React.PropTypes.func, };