You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SharedDocument.js 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import React, { PureComponent } from 'react';
  2. import { View } from 'react-native';
  3. import { WebView } from 'react-native-webview';
  4. import { translate } from '../../../base/i18n';
  5. import JitsiScreen from '../../../base/modal/components/JitsiScreen';
  6. import { LoadingIndicator } from '../../../base/react';
  7. import { connect } from '../../../base/redux';
  8. import { getSharedDocumentUrl } from '../../functions';
  9. import styles, { INDICATOR_COLOR } from './styles';
  10. /**
  11. * The type of the React {@code Component} props of {@code ShareDocument}.
  12. */
  13. type Props = {
  14. /**
  15. * URL for the shared document.
  16. */
  17. _documentUrl: string,
  18. /**
  19. * Default prop for navigation between screen components(React Navigation).
  20. */
  21. navigation: Object,
  22. /**
  23. * Function to be used to translate i18n labels.
  24. */
  25. t: Function
  26. };
  27. /**
  28. * Implements a React native component that renders the shared document window.
  29. */
  30. class SharedDocument extends PureComponent<Props> {
  31. /**
  32. * Instantiates a new instance.
  33. *
  34. * @inheritdoc
  35. */
  36. constructor(props: Props) {
  37. super(props);
  38. this._renderLoading = this._renderLoading.bind(this);
  39. }
  40. /**
  41. * Implements React's {@link Component#render()}.
  42. *
  43. * @inheritdoc
  44. */
  45. render() {
  46. const { _documentUrl } = this.props;
  47. return (
  48. <JitsiScreen
  49. addHeaderHeightValue = { true }
  50. style = { styles.sharedDocContainer }>
  51. <WebView
  52. hideKeyboardAccessoryView = { true }
  53. renderLoading = { this._renderLoading }
  54. source = {{ uri: _documentUrl }}
  55. startInLoadingState = { true }
  56. style = { styles.sharedDoc } />
  57. </JitsiScreen>
  58. );
  59. }
  60. /**
  61. * Renders the loading indicator.
  62. *
  63. * @returns {React$Component<any>}
  64. */
  65. _renderLoading() {
  66. return (
  67. <View style = { styles.indicatorWrapper }>
  68. <LoadingIndicator
  69. color = { INDICATOR_COLOR }
  70. size = 'large' />
  71. </View>
  72. );
  73. }
  74. }
  75. /**
  76. * Maps (parts of) the redux state to {@link SharedDocument} React {@code Component} props.
  77. *
  78. * @param {Object} state - The redux store/state.
  79. * @private
  80. * @returns {Object}
  81. */
  82. export function _mapStateToProps(state: Object) {
  83. const documentUrl = getSharedDocumentUrl(state);
  84. return {
  85. _documentUrl: documentUrl
  86. };
  87. }
  88. export default translate(connect(_mapStateToProps)(SharedDocument));