|
@@ -1,8 +1,9 @@
|
1
|
1
|
// @flow
|
2
|
2
|
|
3
|
3
|
import React, { Component } from 'react';
|
4
|
|
-import { TextInput, View } from 'react-native';
|
|
4
|
+import { TextInput, TouchableOpacity, View } from 'react-native';
|
5
|
5
|
|
|
6
|
+import { Icon } from '../../../base/font-icons';
|
6
|
7
|
import { Platform } from '../../../base/react';
|
7
|
8
|
|
8
|
9
|
import styles from './styles';
|
|
@@ -25,7 +26,12 @@ type State = {
|
25
|
26
|
/**
|
26
|
27
|
* The value of the input field.
|
27
|
28
|
*/
|
28
|
|
- message: string
|
|
29
|
+ message: string,
|
|
30
|
+
|
|
31
|
+ /**
|
|
32
|
+ * Boolean to show or hide the send button.
|
|
33
|
+ */
|
|
34
|
+ showSend: boolean
|
29
|
35
|
};
|
30
|
36
|
|
31
|
37
|
/**
|
|
@@ -42,7 +48,8 @@ export default class ChatInputBar extends Component<Props, State> {
|
42
|
48
|
|
43
|
49
|
this.state = {
|
44
|
50
|
addPadding: false,
|
45
|
|
- message: ''
|
|
51
|
+ message: '',
|
|
52
|
+ showSend: false
|
46
|
53
|
};
|
47
|
54
|
|
48
|
55
|
this._onChangeText = this._onChangeText.bind(this);
|
|
@@ -72,6 +79,13 @@ export default class ChatInputBar extends Component<Props, State> {
|
72
|
79
|
returnKeyType = 'send'
|
73
|
80
|
style = { styles.inputField }
|
74
|
81
|
value = { this.state.message } />
|
|
82
|
+ {
|
|
83
|
+ this.state.showSend && <TouchableOpacity onPress = { this._onSubmit }>
|
|
84
|
+ <Icon
|
|
85
|
+ name = 'send'
|
|
86
|
+ style = { styles.sendButtonIcon } />
|
|
87
|
+ </TouchableOpacity>
|
|
88
|
+ }
|
75
|
89
|
</View>
|
76
|
90
|
);
|
77
|
91
|
}
|
|
@@ -86,7 +100,8 @@ export default class ChatInputBar extends Component<Props, State> {
|
86
|
100
|
*/
|
87
|
101
|
_onChangeText(text) {
|
88
|
102
|
this.setState({
|
89
|
|
- message: text
|
|
103
|
+ message: text,
|
|
104
|
+ showSend: Boolean(text)
|
90
|
105
|
});
|
91
|
106
|
}
|
92
|
107
|
|
|
@@ -117,6 +132,9 @@ export default class ChatInputBar extends Component<Props, State> {
|
117
|
132
|
const message = this.state.message.trim();
|
118
|
133
|
|
119
|
134
|
message && this.props.onSend(message);
|
120
|
|
- this.setState({ message: '' });
|
|
135
|
+ this.setState({
|
|
136
|
+ message: '',
|
|
137
|
+ showSend: false
|
|
138
|
+ });
|
121
|
139
|
}
|
122
|
140
|
}
|