Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

Chat.js 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // @flow
  2. import React from 'react';
  3. import { KeyboardAvoidingView, SafeAreaView } from 'react-native';
  4. import { translate } from '../../../base/i18n';
  5. import { HeaderWithNavigation, SlidingView } from '../../../base/react';
  6. import { connect } from '../../../base/redux';
  7. import AbstractChat, {
  8. _mapDispatchToProps,
  9. _mapStateToProps,
  10. type Props
  11. } from '../AbstractChat';
  12. import ChatInputBar from './ChatInputBar';
  13. import MessageContainer from './MessageContainer';
  14. import MessageRecipient from './MessageRecipient';
  15. import styles from './styles';
  16. /**
  17. * Implements a React native component that renders the chat window (modal) of
  18. * the mobile client.
  19. */
  20. class Chat extends AbstractChat<Props> {
  21. /**
  22. * Instantiates a new instance.
  23. *
  24. * @inheritdoc
  25. */
  26. constructor(props: Props) {
  27. super(props);
  28. this._onClose = this._onClose.bind(this);
  29. }
  30. /**
  31. * Implements React's {@link Component#render()}.
  32. *
  33. * @inheritdoc
  34. */
  35. render() {
  36. return (
  37. <SlidingView
  38. onHide = { this._onClose }
  39. position = 'bottom'
  40. show = { this.props._isOpen } >
  41. <KeyboardAvoidingView
  42. behavior = 'padding'
  43. style = { styles.chatContainer }>
  44. <HeaderWithNavigation
  45. headerLabelKey = 'chat.title'
  46. onPressBack = { this._onClose } />
  47. <SafeAreaView style = { styles.backdrop }>
  48. <MessageContainer messages = { this.props._messages } />
  49. <MessageRecipient />
  50. <ChatInputBar onSend = { this.props._onSendMessage } />
  51. </SafeAreaView>
  52. </KeyboardAvoidingView>
  53. </SlidingView>
  54. );
  55. }
  56. _onClose: () => boolean
  57. /**
  58. * Closes the chat window.
  59. *
  60. * @returns {boolean}
  61. */
  62. _onClose() {
  63. if (this.props._isOpen) {
  64. this.props._onToggleChat();
  65. return true;
  66. }
  67. return false;
  68. }
  69. }
  70. export default translate(connect(_mapStateToProps, _mapDispatchToProps)(Chat));