1 | import PropTypes from 'prop-types';
|
2 | import React, { Component } from 'react';
|
3 | import { StyleSheet, Text, TouchableOpacity, View, } from 'react-native';
|
4 | import Color from './Color';
|
5 | import { StylePropType } from './utils';
|
6 | const styles = StyleSheet.create({
|
7 | container: {
|
8 | height: 44,
|
9 | justifyContent: 'flex-end',
|
10 | },
|
11 | text: {
|
12 | color: Color.defaultBlue,
|
13 | fontWeight: '600',
|
14 | fontSize: 17,
|
15 | backgroundColor: Color.backgroundTransparent,
|
16 | marginBottom: 12,
|
17 | marginLeft: 10,
|
18 | marginRight: 10,
|
19 | },
|
20 | });
|
21 | export default class Send extends Component {
|
22 | constructor() {
|
23 | super(...arguments);
|
24 | this.handleOnPress = () => {
|
25 | const { text, onSend } = this.props;
|
26 | if (text && onSend) {
|
27 | onSend({ text: text.trim() }, true);
|
28 | }
|
29 | };
|
30 | }
|
31 | render() {
|
32 | const { text, containerStyle, children, textStyle, label, alwaysShowSend, disabled, sendButtonProps, } = this.props;
|
33 | if (alwaysShowSend || (text && text.trim().length > 0)) {
|
34 | return (<TouchableOpacity testID='send' accessible accessibilityLabel='send' style={[styles.container, containerStyle]} onPress={this.handleOnPress} accessibilityTraits='button' disabled={disabled} {...sendButtonProps}>
|
35 | <View>
|
36 | {children || <Text style={[styles.text, textStyle]}>{label}</Text>}
|
37 | </View>
|
38 | </TouchableOpacity>);
|
39 | }
|
40 | return <View />;
|
41 | }
|
42 | }
|
43 | Send.defaultProps = {
|
44 | text: '',
|
45 | onSend: () => { },
|
46 | label: 'Send',
|
47 | containerStyle: {},
|
48 | textStyle: {},
|
49 | children: null,
|
50 | alwaysShowSend: false,
|
51 | disabled: false,
|
52 | sendButtonProps: null,
|
53 | };
|
54 | Send.propTypes = {
|
55 | text: PropTypes.string,
|
56 | onSend: PropTypes.func,
|
57 | label: PropTypes.string,
|
58 | containerStyle: StylePropType,
|
59 | textStyle: StylePropType,
|
60 | children: PropTypes.element,
|
61 | alwaysShowSend: PropTypes.bool,
|
62 | disabled: PropTypes.bool,
|
63 | sendButtonProps: PropTypes.object,
|
64 | };
|
65 | //# sourceMappingURL=Send.js.map |
\ | No newline at end of file |