您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

SharedDocument.tsx 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. renderLoading = { this._renderLoading }
  51. source = {{ uri: _documentUrl ?? '' }}
  52. startInLoadingState = { true }
  53. style = { styles.sharedDoc } />
  54. </JitsiScreen>
  55. );
  56. }
  57. /**
  58. * Renders the loading indicator.
  59. *
  60. * @returns {React$Component<any>}
  61. */
  62. _renderLoading() {
  63. return (
  64. <View style = { styles.indicatorWrapper as ViewStyle }>
  65. <LoadingIndicator
  66. color = { INDICATOR_COLOR }
  67. size = 'large' />
  68. </View>
  69. );
  70. }
  71. }
  72. /**
  73. * Maps (parts of) the redux state to {@link SharedDocument} React {@code Component} props.
  74. *
  75. * @param {Object} state - The redux store/state.
  76. * @param {any} _ownProps - Component's props.
  77. * @private
  78. * @returns {Object}
  79. */
  80. export function _mapStateToProps(state: IReduxState, _ownProps: any) {
  81. const documentUrl = getSharedDocumentUrl(state);
  82. return {
  83. _documentUrl: documentUrl
  84. };
  85. }
  86. export default translate(connect(_mapStateToProps)(SharedDocument));