import PropTypes from 'prop-types' import React from 'react' import { StyleSheet, View, StyleProp, ViewStyle } from 'react-native' import { Composer, ComposerProps } from './Composer' import { Send, SendProps } from './Send' import { Actions, ActionsProps } from './Actions' import Color from './Color' import { StylePropType } from './utils' import { IMessage } from './Models' export interface InputToolbarProps { options?: { [key: string]: any } optionTintColor?: string containerStyle?: StyleProp primaryStyle?: StyleProp accessoryStyle?: StyleProp renderAccessory?(props: InputToolbarProps): React.ReactNode renderActions?(props: ActionsProps): React.ReactNode renderSend?(props: SendProps): React.ReactNode renderComposer?(props: ComposerProps): React.ReactNode onPressActionButton?(): void } export function InputToolbar ( props: InputToolbarProps ) { const { containerStyle, ...rest } = props const { renderActions, onPressActionButton, renderComposer, renderSend, renderAccessory, } = rest return ( {renderActions?.(rest) || (onPressActionButton && )} {renderComposer?.(props as ComposerProps) || } {renderSend?.(props) || } {renderAccessory && ( {renderAccessory(props)} )} ) } InputToolbar.propTypes = { renderAccessory: PropTypes.func, renderActions: PropTypes.func, renderSend: PropTypes.func, renderComposer: PropTypes.func, onPressActionButton: PropTypes.func, containerStyle: StylePropType, primaryStyle: StylePropType, accessoryStyle: StylePropType, } const styles = StyleSheet.create({ container: { borderTopWidth: StyleSheet.hairlineWidth, borderTopColor: Color.defaultColor, backgroundColor: Color.white, }, primary: { flexDirection: 'row', alignItems: 'flex-end', }, accessory: { height: 44, }, })