Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

SharedDocument.js 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. )
  65. });
  66. }
  67. /**
  68. * Implements React's {@link Component#render()}.
  69. *
  70. * @inheritdoc
  71. */
  72. render() {
  73. const { _documentUrl } = this.props;
  74. return (
  75. <JitsiScreen
  76. addHeaderHeightValue = { true }
  77. style = { styles.sharedDocContainer }>
  78. <WebView
  79. renderLoading = { this._renderLoading }
  80. source = {{ uri: _documentUrl }}
  81. startInLoadingState = { true } />
  82. </JitsiScreen>
  83. );
  84. }
  85. _renderLoading: () => React$Component<any>;
  86. /**
  87. * Renders the loading indicator.
  88. *
  89. * @returns {React$Component<any>}
  90. */
  91. _renderLoading() {
  92. return (
  93. <View style = { styles.indicatorWrapper }>
  94. <LoadingIndicator
  95. color = { INDICATOR_COLOR }
  96. size = 'large' />
  97. </View>
  98. );
  99. }
  100. }
  101. /**
  102. * Maps (parts of) the redux state to {@link SharedDocument} React {@code Component} props.
  103. *
  104. * @param {Object} state - The redux store/state.
  105. * @private
  106. * @returns {Object}
  107. */
  108. export function _mapStateToProps(state: Object) {
  109. const documentUrl = getSharedDocumentUrl(state);
  110. return {
  111. _documentUrl: documentUrl,
  112. _headerStyles: ColorSchemeRegistry.get(state, 'Header')
  113. };
  114. }
  115. export default translate(connect(_mapStateToProps)(SharedDocument));