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.tsx 2.8KB

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