Skip to content

Commit

Permalink
ref: SharedDocument to JitsiModal
Browse files Browse the repository at this point in the history
  • Loading branch information
zbettenbuk authored and root committed Apr 9, 2020
1 parent d5673c2 commit 3a5ef78
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 41 deletions.
50 changes: 17 additions & 33 deletions react/features/etherpad/components/native/SharedDocument.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
// @flow

import React, { PureComponent } from 'react';
import { SafeAreaView, View } from 'react-native';
import { View } from 'react-native';
import { WebView } from 'react-native-webview';
import type { Dispatch } from 'redux';

import { ColorSchemeRegistry } from '../../../base/color-scheme';
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 { toggleDocument } from '../../actions';
import { SHARE_DOCUMENT_VIEW_ID } from '../../constants';
import { getSharedDocumentUrl } from '../../functions';

import styles, { INDICATOR_COLOR } from './styles';
Expand Down Expand Up @@ -69,42 +71,24 @@ class SharedDocument extends PureComponent<Props> {
* @inheritdoc
*/
render() {
const { _documentUrl, _isOpen } = this.props;
const webViewStyles = this._getWebViewStyles();
const { _documentUrl } = this.props;

return (
<SlidingView
onHide = { this._onClose }
position = 'bottom'
show = { _isOpen } >
<View style = { styles.webViewWrapper }>
<HeaderWithNavigation
headerLabelKey = 'documentSharing.title'
onPressBack = { this._onClose } />
<SafeAreaView style = { webViewStyles }>
<WebView
onError = { this._onError }
renderLoading = { this._renderLoading }
source = {{ uri: _documentUrl }}
startInLoadingState = { true } />
</SafeAreaView>
</View>
</SlidingView>
<JitsiModal
headerProps = {{
headerLabelKey: 'documentSharing.title'
}}
modalId = { SHARE_DOCUMENT_VIEW_ID }
style = { styles.webView }>
<WebView
onError = { this._onError }
renderLoading = { this._renderLoading }
source = {{ uri: _documentUrl }}
startInLoadingState = { true } />
</JitsiModal>
);
}

/**
* Computes the styles required for the WebView component.
*
* @returns {Object}
*/
_getWebViewStyles() {
return {
...styles.webView,
backgroundColor: this.props._headerStyles.screenHeader.backgroundColor
};
}

_onClose: () => boolean

/**
Expand Down
7 changes: 1 addition & 6 deletions react/features/etherpad/components/native/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ export default {
},

webView: {
flex: 1
},

webViewWrapper: {
flex: 1,
flexDirection: 'column'
backgroundColor: 'rgb(242, 242, 242)'
}
};
4 changes: 4 additions & 0 deletions react/features/etherpad/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* Modal view ID of the SharedDocument view.
*/
export const SHARE_DOCUMENT_VIEW_ID = 'SHARE_DOCUMENT_VIEW_ID';
1 change: 1 addition & 0 deletions react/features/etherpad/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export * from './actions';
export * from './actionTypes';
export * from './components';
export * from './constants';
export * from './functions';

import './middleware';
Expand Down
12 changes: 10 additions & 2 deletions react/features/etherpad/middleware.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// @flow

import { getCurrentConference } from '../base/conference';
import { setActiveModalId } from '../base/modal';
import { MiddlewareRegistry, StateListenerRegistry } from '../base/redux';
import UIEvents from '../../../service/UI/UIEvents';

import { TOGGLE_DOCUMENT_EDITING } from './actionTypes';
import { setDocumentEditingState, setDocumentUrl } from './actions';
import { SHARE_DOCUMENT_VIEW_ID } from './constants';

declare var APP: Object;

Expand All @@ -23,9 +25,15 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
switch (action.type) {
case TOGGLE_DOCUMENT_EDITING: {
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 {
APP.UI.emitEvent(UIEvents.ETHERPAD_CLICKED);
}
Expand Down

0 comments on commit 3a5ef78

Please sign in to comment.