ref: SharedDocument to JitsiModal

This commit is contained in:
Bettenbuk Zoltan 2020-04-06 17:27:03 +02:00 committed by Zoltan Bettenbuk
parent 0f4369a9a9
commit 5574221044
5 changed files with 33 additions and 41 deletions

View File

@ -1,16 +1,18 @@
// @flow // @flow
import React, { PureComponent } from 'react'; import React, { PureComponent } from 'react';
import { SafeAreaView, View } from 'react-native'; import { View } from 'react-native';
import { WebView } from 'react-native-webview'; import { WebView } from 'react-native-webview';
import type { Dispatch } from 'redux'; import type { Dispatch } from 'redux';
import { ColorSchemeRegistry } from '../../../base/color-scheme'; import { ColorSchemeRegistry } from '../../../base/color-scheme';
import { translate } from '../../../base/i18n'; import { translate } from '../../../base/i18n';
import { HeaderWithNavigation, LoadingIndicator, SlidingView } from '../../../base/react'; import { JitsiModal } from '../../../base/modal';
import { LoadingIndicator } from '../../../base/react';
import { connect } from '../../../base/redux'; import { connect } from '../../../base/redux';
import { toggleDocument } from '../../actions'; import { toggleDocument } from '../../actions';
import { SHARE_DOCUMENT_VIEW_ID } from '../../constants';
import { getSharedDocumentUrl } from '../../functions'; import { getSharedDocumentUrl } from '../../functions';
import styles, { INDICATOR_COLOR } from './styles'; import styles, { INDICATOR_COLOR } from './styles';
@ -69,42 +71,24 @@ class SharedDocument extends PureComponent<Props> {
* @inheritdoc * @inheritdoc
*/ */
render() { render() {
const { _documentUrl, _isOpen } = this.props; const { _documentUrl } = this.props;
const webViewStyles = this._getWebViewStyles();
return ( return (
<SlidingView <JitsiModal
onHide = { this._onClose } headerProps = {{
position = 'bottom' headerLabelKey: 'documentSharing.title'
show = { _isOpen } > }}
<View style = { styles.webViewWrapper }> modalId = { SHARE_DOCUMENT_VIEW_ID }
<HeaderWithNavigation style = { styles.webView }>
headerLabelKey = 'documentSharing.title'
onPressBack = { this._onClose } />
<SafeAreaView style = { webViewStyles }>
<WebView <WebView
onError = { this._onError } onError = { this._onError }
renderLoading = { this._renderLoading } renderLoading = { this._renderLoading }
source = {{ uri: _documentUrl }} source = {{ uri: _documentUrl }}
startInLoadingState = { true } /> startInLoadingState = { true } />
</SafeAreaView> </JitsiModal>
</View>
</SlidingView>
); );
} }
/**
* Computes the styles required for the WebView component.
*
* @returns {Object}
*/
_getWebViewStyles() {
return {
...styles.webView,
backgroundColor: this.props._headerStyles.screenHeader.backgroundColor
};
}
_onClose: () => boolean _onClose: () => boolean
/** /**

View File

@ -14,11 +14,6 @@ export default {
}, },
webView: { webView: {
flex: 1 backgroundColor: 'rgb(242, 242, 242)'
},
webViewWrapper: {
flex: 1,
flexDirection: 'column'
} }
}; };

View File

@ -0,0 +1,4 @@
/**
* Modal view ID of the SharedDocument view.
*/
export const SHARE_DOCUMENT_VIEW_ID = 'SHARE_DOCUMENT_VIEW_ID';

View File

@ -1,6 +1,7 @@
export * from './actions'; export * from './actions';
export * from './actionTypes'; export * from './actionTypes';
export * from './components'; export * from './components';
export * from './constants';
export * from './functions'; export * from './functions';
import './middleware'; import './middleware';

View File

@ -1,11 +1,13 @@
// @flow // @flow
import { getCurrentConference } from '../base/conference'; import { getCurrentConference } from '../base/conference';
import { setActiveModalId } from '../base/modal';
import { MiddlewareRegistry, StateListenerRegistry } from '../base/redux'; import { MiddlewareRegistry, StateListenerRegistry } from '../base/redux';
import UIEvents from '../../../service/UI/UIEvents'; import UIEvents from '../../../service/UI/UIEvents';
import { TOGGLE_DOCUMENT_EDITING } from './actionTypes'; import { TOGGLE_DOCUMENT_EDITING } from './actionTypes';
import { setDocumentEditingState, setDocumentUrl } from './actions'; import { setDocumentEditingState, setDocumentUrl } from './actions';
import { SHARE_DOCUMENT_VIEW_ID } from './constants';
declare var APP: Object; declare var APP: Object;
@ -23,9 +25,15 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
switch (action.type) { switch (action.type) {
case TOGGLE_DOCUMENT_EDITING: { case TOGGLE_DOCUMENT_EDITING: {
if (typeof APP === 'undefined') { if (typeof APP === 'undefined') {
const { editing } = getState()['features/etherpad']; const editing = !getState()['features/etherpad'].editing;
dispatch(setDocumentEditingState(!editing)); dispatch(setDocumentEditingState(editing));
if (editing) {
dispatch(setActiveModalId(SHARE_DOCUMENT_VIEW_ID));
} else if (getState()['features/base/modal'].activeModalId === SHARE_DOCUMENT_VIEW_ID) {
dispatch(setActiveModalId(undefined));
}
} else { } else {
APP.UI.emitEvent(UIEvents.ETHERPAD_CLICKED); APP.UI.emitEvent(UIEvents.ETHERPAD_CLICKED);
} }