commit b0ce4d46b250e36f3a24d52145fe9255b2495e63
parent 1b46f05d3ac3a71ecf728dde54fa5ca44cdf0584
Author: Matthew Horan <matt@matthoran.com>
Date: Sun, 14 Apr 2019 21:14:26 -0400
Support pasting multiline text
While we normally send messages on enter, it may be desirable to paste
multiple lines into weechatRN. Submit each line individually to the
relay.
This also causes the text input to grow like in weechat-android.
Bonus: double space now enters a period.
Closes #16
Diffstat:
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/src/usecase/buffers/ui/BufferContainer.tsx b/src/usecase/buffers/ui/BufferContainer.tsx
@@ -96,19 +96,22 @@ class BufferContainer extends React.Component<Props, State> {
}
}
+ clearTextInput = false;
+
handleChangeText = (textValue: string) => {
this.tabCompleteInProgress = false;
this.setState({
- textValue
+ textValue: this.clearTextInput ? "" : textValue
});
+ this.clearTextInput = false
};
handleSubmit = () => {
const { textValue } = this.state;
- this.props.sendMessage(textValue);
- this.setState({
- textValue: ""
+ textValue.split("\n").forEach((line) => {
+ this.props.sendMessage(line);
});
+ this.clearTextInput = true;
};
tabCompleteNick = () => {
@@ -196,6 +199,8 @@ class BufferContainer extends React.Component<Props, State> {
returnKeyType="send"
blurOnSubmit={false}
onSubmitEditing={this.handleSubmit}
+ multiline={true}
+ enablesReturnKeyAutomatically={true}
/>
{showTabButton && (
<TouchableOpacity
@@ -236,16 +241,16 @@ const styles = StyleSheet.create({
paddingVertical: 20
},
bottomBox: {
- height: 40,
paddingHorizontal: 10,
+ paddingVertical: 7.5,
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
backgroundColor: "#333"
},
inputBox: {
- height: 25,
- paddingHorizontal: 5,
+ maxHeight: 60.5,
+ padding: 5,
justifyContent: "center",
borderColor: "gray",
backgroundColor: "#fff",