2019-10-04 15:10:19 +00:00
|
|
|
import React, { PureComponent } from 'react';
|
2020-04-06 15:27:03 +00:00
|
|
|
import { View } from 'react-native';
|
2019-10-04 15:10:19 +00:00
|
|
|
import { WebView } from 'react-native-webview';
|
|
|
|
|
|
|
|
import { translate } from '../../../base/i18n';
|
2021-10-20 19:29:21 +00:00
|
|
|
import JitsiScreen from '../../../base/modal/components/JitsiScreen';
|
2020-04-06 15:27:03 +00:00
|
|
|
import { LoadingIndicator } from '../../../base/react';
|
2019-10-04 15:10:19 +00:00
|
|
|
import { connect } from '../../../base/redux';
|
|
|
|
import { getSharedDocumentUrl } from '../../functions';
|
|
|
|
|
|
|
|
import styles, { INDICATOR_COLOR } from './styles';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The type of the React {@code Component} props of {@code ShareDocument}.
|
|
|
|
*/
|
|
|
|
type Props = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* URL for the shared document.
|
|
|
|
*/
|
|
|
|
_documentUrl: string,
|
|
|
|
|
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* Default prop for navigation between screen components(React Navigation).
|
2019-10-04 15:10:19 +00:00
|
|
|
*/
|
2021-10-20 19:29:21 +00:00
|
|
|
navigation: Object,
|
2019-10-04 15:10:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function to be used to translate i18n labels.
|
|
|
|
*/
|
|
|
|
t: Function
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements a React native component that renders the shared document window.
|
|
|
|
*/
|
|
|
|
class SharedDocument extends PureComponent<Props> {
|
|
|
|
/**
|
|
|
|
* Instantiates a new instance.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
constructor(props: Props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this._renderLoading = this._renderLoading.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
render() {
|
2020-04-06 15:27:03 +00:00
|
|
|
const { _documentUrl } = this.props;
|
2019-10-04 15:10:19 +00:00
|
|
|
|
|
|
|
return (
|
2021-10-20 19:29:21 +00:00
|
|
|
<JitsiScreen
|
|
|
|
addHeaderHeightValue = { true }
|
|
|
|
style = { styles.sharedDocContainer }>
|
2020-04-06 15:27:03 +00:00
|
|
|
<WebView
|
2022-07-05 12:15:59 +00:00
|
|
|
hideKeyboardAccessoryView = { true }
|
2020-04-06 15:27:03 +00:00
|
|
|
renderLoading = { this._renderLoading }
|
|
|
|
source = {{ uri: _documentUrl }}
|
2022-07-05 12:15:59 +00:00
|
|
|
startInLoadingState = { true }
|
|
|
|
style = { styles.sharedDoc } />
|
2021-10-20 19:29:21 +00:00
|
|
|
</JitsiScreen>
|
2019-10-04 15:10:19 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders the loading indicator.
|
|
|
|
*
|
|
|
|
* @returns {React$Component<any>}
|
|
|
|
*/
|
|
|
|
_renderLoading() {
|
|
|
|
return (
|
|
|
|
<View style = { styles.indicatorWrapper }>
|
|
|
|
<LoadingIndicator
|
|
|
|
color = { INDICATOR_COLOR }
|
|
|
|
size = 'large' />
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps (parts of) the redux state to {@link SharedDocument} React {@code Component} props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The redux store/state.
|
|
|
|
* @private
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
|
|
|
export function _mapStateToProps(state: Object) {
|
|
|
|
const documentUrl = getSharedDocumentUrl(state);
|
|
|
|
|
|
|
|
return {
|
2022-06-20 21:09:13 +00:00
|
|
|
_documentUrl: documentUrl
|
2019-10-04 15:10:19 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default translate(connect(_mapStateToProps)(SharedDocument));
|