feat: can disable send button (#1042)

This commit is contained in:
Egidio Caprino
2019-01-18 10:55:17 +01:00
committed by Xavier Carpentier
parent 5f33b90fcd
commit 5d088ae263

View File

@@ -5,7 +5,7 @@ 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, alwaysShowSend }) {
export default function Send({ text, containerStyle, onSend, children, textStyle, label, alwaysShowSend, disabled }) {
if (alwaysShowSend || text.trim().length > 0) {
return (
<TouchableOpacity
@@ -17,6 +17,7 @@ export default function Send({ text, containerStyle, onSend, children, textStyle
onSend({ text: text.trim() }, true);
}}
accessibilityTraits="button"
disabled={disabled}
>
<View>{children || <Text style={[styles.text, textStyle]}>{label}</Text>}</View>
</TouchableOpacity>
@@ -49,6 +50,7 @@ Send.defaultProps = {
textStyle: {},
children: null,
alwaysShowSend: false,
disabled: false,
};
Send.propTypes = {
@@ -59,4 +61,5 @@ Send.propTypes = {
textStyle: Text.propTypes.style,
children: PropTypes.element,
alwaysShowSend: PropTypes.bool,
disabled: PropTypes.bool,
};