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 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. // @flow
  2. import React, { PureComponent } from 'react';
  3. import { View } from 'react-native';
  4. import { WebView } from 'react-native-webview';
  5. import { ColorSchemeRegistry } from '../../../base/color-scheme';
  6. import { translate } from '../../../base/i18n';
  7. import { IconArrowBack } from '../../../base/icons';
  8. import JitsiScreen from '../../../base/modal/components/JitsiScreen';
  9. import { LoadingIndicator } from '../../../base/react';
  10. import { connect } from '../../../base/redux';
  11. import HeaderNavigationButton
  12. from '../../../mobile/navigation/components/HeaderNavigationButton';
  13. import { goBack } from '../../../mobile/navigation/components/conference/ConferenceNavigationContainerRef';
  14. import { getSharedDocumentUrl } from '../../functions';
  15. import styles, { INDICATOR_COLOR } from './styles';
  16. /**
  17. * The type of the React {@code Component} props of {@code ShareDocument}.
  18. */
  19. type Props = {
  20. /**
  21. * URL for the shared document.
  22. */
  23. _documentUrl: string,
  24. /**
  25. * Color schemed style of the header component.
  26. */
  27. _headerStyles: Object,
  28. /**
  29. * Default prop for navigation between screen components(React Navigation).
  30. */
  31. navigation: Object,
  32. /**
  33. * Function to be used to translate i18n labels.
  34. */
  35. t: Function
  36. };
  37. /**
  38. * Implements a React native component that renders the shared document window.
  39. */
  40. class SharedDocument extends PureComponent<Props> {
  41. /**
  42. * Instantiates a new instance.
  43. *
  44. * @inheritdoc
  45. */
  46. constructor(props: Props) {
  47. super(props);
  48. this._renderLoading = this._renderLoading.bind(this);
  49. }
  50. /**
  51. * Implements React's {@link Component#componentDidMount()}. Invoked
  52. * immediately after this component is mounted.
  53. *
  54. * @inheritdoc
  55. * @returns {void}
  56. */
  57. componentDidMount() {
  58. const { navigation } = this.props;
  59. navigation.setOptions({
  60. headerLeft: () => (
  61. <HeaderNavigationButton
  62. onPress = { goBack }
  63. src = { IconArrowBack }
  64. style = { styles.headerArrowBack } />
  65. )
  66. });
  67. }
  68. /**
  69. * Implements React's {@link Component#render()}.
  70. *
  71. * @inheritdoc
  72. */
  73. render() {
  74. const { _documentUrl } = this.props;
  75. return (
  76. <JitsiScreen
  77. addHeaderHeightValue = { true }
  78. style = { styles.sharedDocContainer }>
  79. <WebView
  80. renderLoading = { this._renderLoading }
  81. source = {{ uri: _documentUrl }}
  82. startInLoadingState = { true } />
  83. </JitsiScreen>
  84. );
  85. }
  86. _renderLoading: () => React$Component<any>;
  87. /**
  88. * Renders the loading indicator.
  89. *
  90. * @returns {React$Component<any>}
  91. */
  92. _renderLoading() {
  93. return (
  94. <View style = { styles.indicatorWrapper }>
  95. <LoadingIndicator
  96. color = { INDICATOR_COLOR }
  97. size = 'large' />
  98. </View>
  99. );
  100. }
  101. }
  102. /**
  103. * Maps (parts of) the redux state to {@link SharedDocument} React {@code Component} props.
  104. *
  105. * @param {Object} state - The redux store/state.
  106. * @private
  107. * @returns {Object}
  108. */
  109. export function _mapStateToProps(state: Object) {
  110. const documentUrl = getSharedDocumentUrl(state);
  111. return {
  112. _documentUrl: documentUrl,
  113. _headerStyles: ColorSchemeRegistry.get(state, 'Header')
  114. };
  115. }
  116. export default translate(connect(_mapStateToProps)(SharedDocument));