Add prop to always show send button (#717)

* Add prop to always show send button

* Clarify alwaysShowSend usage
This commit is contained in:
Aaron Lee
2018-03-27 04:08:07 +09:00
committed by Xavier Carpentier
parent 10f0a42d5a
commit a830d65cb6
2 changed files with 5 additions and 2 deletions

View File

@@ -152,6 +152,7 @@ e.g. System Message
* **`messageIdGenerator`** _(Function)_ - Generate an id for new messages. Defaults to UUID v4, generated by [uuid](https://github.com/kelektiv/node-uuid)
* **`user`** _(Object)_ - User sending the messages: `{ _id, name, avatar }`
* **`onSend`** _(Function)_ - Callback when sending a message
* **`alwaysShowSend`** _(Bool)_ - Always show send button in input text composer; default `false`, show only when text input is not empty
* **`locale`** _(String)_ - Locale to localize the dates
* **`timeFormat`** _(String)_ - Format to use for rendering times; default is `'LT'`
* **`dateFormat`** _(String)_ - Format to use for rendering dates; default is `'ll'`

View File

@@ -5,8 +5,8 @@ import React from 'react';
import { StyleSheet, Text, TouchableOpacity, View, ViewPropTypes } from 'react-native';
import Color from './Color';
export default function Send({ text, containerStyle, onSend, children, textStyle, label }) {
if (text.trim().length > 0) {
export default function Send({ text, containerStyle, onSend, children, textStyle, label, alwaysShowSend }) {
if (alwaysShowSend || text.trim().length > 0) {
return (
<TouchableOpacity
style={[styles.container, containerStyle]}
@@ -45,6 +45,7 @@ Send.defaultProps = {
containerStyle: {},
textStyle: {},
children: null,
alwaysShowSend: false,
};
Send.propTypes = {
@@ -54,4 +55,5 @@ Send.propTypes = {
containerStyle: ViewPropTypes.style,
textStyle: Text.propTypes.style,
children: PropTypes.element,
alwaysShowSend: PropTypes.bool,
};