浏览代码

ref: SharedDocument to JitsiModal

master
Bettenbuk Zoltan 5 年前
父节点
当前提交
5574221044

+ 17
- 33
react/features/etherpad/components/native/SharedDocument.js 查看文件

@@ -1,16 +1,18 @@
1 1
 // @flow
2 2
 
3 3
 import React, { PureComponent } from 'react';
4
-import { SafeAreaView, View } from 'react-native';
4
+import { View } from 'react-native';
5 5
 import { WebView } from 'react-native-webview';
6 6
 import type { Dispatch } from 'redux';
7 7
 
8 8
 import { ColorSchemeRegistry } from '../../../base/color-scheme';
9 9
 import { translate } from '../../../base/i18n';
10
-import { HeaderWithNavigation, LoadingIndicator, SlidingView } from '../../../base/react';
10
+import { JitsiModal } from '../../../base/modal';
11
+import { LoadingIndicator } from '../../../base/react';
11 12
 import { connect } from '../../../base/redux';
12 13
 
13 14
 import { toggleDocument } from '../../actions';
15
+import { SHARE_DOCUMENT_VIEW_ID } from '../../constants';
14 16
 import { getSharedDocumentUrl } from '../../functions';
15 17
 
16 18
 import styles, { INDICATOR_COLOR } from './styles';
@@ -69,42 +71,24 @@ class SharedDocument extends PureComponent<Props> {
69 71
      * @inheritdoc
70 72
      */
71 73
     render() {
72
-        const { _documentUrl, _isOpen } = this.props;
73
-        const webViewStyles = this._getWebViewStyles();
74
+        const { _documentUrl } = this.props;
74 75
 
75 76
         return (
76
-            <SlidingView
77
-                onHide = { this._onClose }
78
-                position = 'bottom'
79
-                show = { _isOpen } >
80
-                <View style = { styles.webViewWrapper }>
81
-                    <HeaderWithNavigation
82
-                        headerLabelKey = 'documentSharing.title'
83
-                        onPressBack = { this._onClose } />
84
-                    <SafeAreaView style = { webViewStyles }>
85
-                        <WebView
86
-                            onError = { this._onError }
87
-                            renderLoading = { this._renderLoading }
88
-                            source = {{ uri: _documentUrl }}
89
-                            startInLoadingState = { true } />
90
-                    </SafeAreaView>
91
-                </View>
92
-            </SlidingView>
77
+            <JitsiModal
78
+                headerProps = {{
79
+                    headerLabelKey: 'documentSharing.title'
80
+                }}
81
+                modalId = { SHARE_DOCUMENT_VIEW_ID }
82
+                style = { styles.webView }>
83
+                <WebView
84
+                    onError = { this._onError }
85
+                    renderLoading = { this._renderLoading }
86
+                    source = {{ uri: _documentUrl }}
87
+                    startInLoadingState = { true } />
88
+            </JitsiModal>
93 89
         );
94 90
     }
95 91
 
96
-    /**
97
-     * Computes the styles required for the WebView component.
98
-     *
99
-     * @returns {Object}
100
-     */
101
-    _getWebViewStyles() {
102
-        return {
103
-            ...styles.webView,
104
-            backgroundColor: this.props._headerStyles.screenHeader.backgroundColor
105
-        };
106
-    }
107
-
108 92
     _onClose: () => boolean
109 93
 
110 94
     /**

+ 1
- 6
react/features/etherpad/components/native/styles.js 查看文件

@@ -14,11 +14,6 @@ export default {
14 14
     },
15 15
 
16 16
     webView: {
17
-        flex: 1
18
-    },
19
-
20
-    webViewWrapper: {
21
-        flex: 1,
22
-        flexDirection: 'column'
17
+        backgroundColor: 'rgb(242, 242, 242)'
23 18
     }
24 19
 };

+ 4
- 0
react/features/etherpad/constants.js 查看文件

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

+ 1
- 0
react/features/etherpad/index.js 查看文件

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

+ 10
- 2
react/features/etherpad/middleware.js 查看文件

@@ -1,11 +1,13 @@
1 1
 // @flow
2 2
 
3 3
 import { getCurrentConference } from '../base/conference';
4
+import { setActiveModalId } from '../base/modal';
4 5
 import { MiddlewareRegistry, StateListenerRegistry } from '../base/redux';
5 6
 import UIEvents from '../../../service/UI/UIEvents';
6 7
 
7 8
 import { TOGGLE_DOCUMENT_EDITING } from './actionTypes';
8 9
 import { setDocumentEditingState, setDocumentUrl } from './actions';
10
+import { SHARE_DOCUMENT_VIEW_ID } from './constants';
9 11
 
10 12
 declare var APP: Object;
11 13
 
@@ -23,9 +25,15 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
23 25
     switch (action.type) {
24 26
     case TOGGLE_DOCUMENT_EDITING: {
25 27
         if (typeof APP === 'undefined') {
26
-            const { editing } = getState()['features/etherpad'];
28
+            const editing = !getState()['features/etherpad'].editing;
27 29
 
28
-            dispatch(setDocumentEditingState(!editing));
30
+            dispatch(setDocumentEditingState(editing));
31
+
32
+            if (editing) {
33
+                dispatch(setActiveModalId(SHARE_DOCUMENT_VIEW_ID));
34
+            } else if (getState()['features/base/modal'].activeModalId === SHARE_DOCUMENT_VIEW_ID) {
35
+                dispatch(setActiveModalId(undefined));
36
+            }
29 37
         } else {
30 38
             APP.UI.emitEvent(UIEvents.ETHERPAD_CLICKED);
31 39
         }

正在加载...
取消
保存