forked from reactnativecomponent/react-native-imui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chatinput.android.js
96 lines (84 loc) · 2.37 KB
/
chatinput.android.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
'use strict';
import React from 'react';
import ReactNative from 'react-native';
var {
Component,
} = React;
var {
StyleSheet,
View,
requireNativeComponent,
ViewPropTypes
} = ReactNative;
import PropTypes from 'prop-types'
export default class ChatInput extends Component {
constructor(props) {
super(props);
this._onSendText = this._onSendText.bind(this);
this._onSendVideo = this._onSendVideo.bind(this);
this._onSendVoice = this._onSendVoice.bind(this);
this._onShowKeyboard = this._onShowKeyboard.bind(this);
this._onFeatureView = this._onFeatureView.bind(this);
this._onEditTextChange = this._onEditTextChange.bind(this);
}
_onSendText(event: Event) {
if (!this.props.onSendText) {
return;
}
this.props.onSendText(event.nativeEvent.text,event.nativeEvent.ids);
}
_onSendVideo(event: Event) {
if (!this.props.onSendVideo) {
return;
}
this.props.onSendVideo(event.nativeEvent.mediaPath);
}
_onSendVoice(event: Event) {
if (!this.props.onSendVoice) {
return;
}
this.props.onSendVoice(event.nativeEvent.mediaPath, event.nativeEvent.duration);
}
_onShowKeyboard(event:Event) {
if (!this.props.onShowKeyboard) {
return;
}
this.props.onShowKeyboard(event.nativeEvent.inputHeight,event.nativeEvent.showType);
}
_onFeatureView(event:Event) {
if (!this.props.onFeatureView) {
return;
}
this.props.onFeatureView(event.nativeEvent.inputHeight,event.nativeEvent.showType);
}
_onEditTextChange(event: Event) {
if (!this.props.onEditTextChange) {
return;
}
this.props.onEditTextChange(event.nativeEvent.text);
}
render() {
return (
<RCTChatInput
{...this.props}
onSendText={this._onSendText}
onSendVideo={this._onSendVideo}
onSendVoice={this._onSendVoice}
onShowKeyboard={this._onShowKeyboard}
onFeatureView={this._onFeatureView}
onEditTextChange={this._onEditTextChange}
/>
);
}
}
ChatInput.propTypes = {
menuContainerHeight: PropTypes.number,
isDismissMenuContainer: PropTypes.bool,
onSendVideo: PropTypes.func,
onSendVoice: PropTypes.func,
onShowKeyboard: PropTypes.func,
onFeatureView: PropTypes.func,
onEditTextChange: PropTypes.func,
...ViewPropTypes
};
var RCTChatInput = requireNativeComponent('RCTChatInput', ChatInput);