jiti-meet/react/features/chat/components/native/Chat.js

82 lines
2.1 KiB
JavaScript
Raw Normal View History

// @flow
import React from 'react';
import { KeyboardAvoidingView, SafeAreaView } from 'react-native';
import { translate } from '../../../base/i18n';
2019-05-07 14:46:52 +00:00
import { HeaderWithNavigation, SlidingView } from '../../../base/react';
2019-03-21 16:38:29 +00:00
import { connect } from '../../../base/redux';
import AbstractChat, {
_mapDispatchToProps,
_mapStateToProps,
type Props
} from '../AbstractChat';
import ChatInputBar from './ChatInputBar';
import MessageContainer from './MessageContainer';
import styles from './styles';
/**
* Implements a React native component that renders the chat window (modal) of
* the mobile client.
*/
class Chat extends AbstractChat<Props> {
2019-07-11 11:32:17 +00:00
/**
* Instantiates a new instance.
*
* @inheritdoc
*/
constructor(props: Props) {
super(props);
this._onClose = this._onClose.bind(this);
}
/**
* Implements React's {@link Component#render()}.
*
* @inheritdoc
*/
render() {
return (
<SlidingView
2019-07-11 11:32:17 +00:00
onHide = { this._onClose }
position = 'bottom'
show = { this.props._isOpen } >
<KeyboardAvoidingView
behavior = 'padding'
style = { styles.chatContainer }>
2019-05-07 14:46:52 +00:00
<HeaderWithNavigation
headerLabelKey = 'chat.title'
2019-07-11 11:32:17 +00:00
onPressBack = { this._onClose } />
<SafeAreaView style = { styles.backdrop }>
<MessageContainer messages = { this.props._messages } />
<ChatInputBar onSend = { this.props._onSendMessage } />
</SafeAreaView>
</KeyboardAvoidingView>
</SlidingView>
);
}
2019-07-11 11:32:17 +00:00
_onClose: () => boolean
/**
* Closes the chat window.
*
* @returns {boolean}
*/
_onClose() {
if (this.props._isOpen) {
this.props._onToggleChat();
return true;
}
return false;
}
}
export default translate(connect(_mapStateToProps, _mapDispatchToProps)(Chat));