ソースを参照

ref: change JitsiModal to better fit to needs

master
Bettenbuk Zoltan 5年前
コミット
678ed605d7

+ 0
- 12
react/features/app/components/AbstractApp.js ファイルの表示

@@ -89,22 +89,10 @@ export class AbstractApp extends BaseApp<Props, *> {
89 89
         return (
90 90
             <Fragment>
91 91
                 <OverlayContainer />
92
-                { this._createExtraPlatformSpecificElement() }
93 92
             </Fragment>
94 93
         );
95 94
     }
96 95
 
97
-    /**
98
-     * Renders platform specific extra elements to be added alongside with the main element, if need be.
99
-     *
100
-     * NOTE: Overridden by child components.
101
-     *
102
-     * @returns {React$Element}
103
-     */
104
-    _createExtraPlatformSpecificElement() {
105
-        return null;
106
-    }
107
-
108 96
     _createMainElement: (React$Element<*>, Object) => ?React$Element<*>;
109 97
 
110 98
     /**

+ 0
- 12
react/features/app/components/App.native.js ファイルの表示

@@ -12,7 +12,6 @@ import { Platform } from '../../base/react';
12 12
 import '../../base/responsive-ui';
13 13
 import { updateSettings } from '../../base/settings';
14 14
 import '../../google-api';
15
-import { HelpView } from '../../help';
16 15
 import '../../mobile/audio-mode';
17 16
 import '../../mobile/back-button';
18 17
 import '../../mobile/background';
@@ -108,17 +107,6 @@ export class App extends AbstractApp {
108 107
         });
109 108
     }
110 109
 
111
-    /**
112
-     * Renders platform specific extra elements to be added alongside with the main element, if need be.
113
-     *
114
-     * @inheritdoc
115
-     */
116
-    _createExtraPlatformSpecificElement() {
117
-        return (
118
-            <HelpView />
119
-        );
120
-    }
121
-
122 110
     /**
123 111
      * Attempts to disable the use of React Native
124 112
      * {@link ExceptionsManager#handleException} on platforms and in

+ 3
- 1
react/features/base/modal/actions.js ファイルの表示

@@ -6,14 +6,16 @@ import { SET_ACTIVE_MODAL_ID } from './actionTypes';
6 6
  * Action to set the ID of the active modal (or undefined if needs to be hidden).
7 7
  *
8 8
  * @param {string} activeModalId - The new modal ID or undefined.
9
+ * @param {Object} modalProps - The props to pass to the modal.
9 10
  * @returns {{
10 11
  *     activeModalId: string,
11 12
  *     type: SET_ACTIVE_MODAL_ID
12 13
  * }}
13 14
  */
14
-export function setActiveModalId(activeModalId: ?string) {
15
+export function setActiveModalId(activeModalId: ?string, modalProps: Object = {}) {
15 16
     return {
16 17
         activeModalId,
18
+        modalProps,
17 19
         type: SET_ACTIVE_MODAL_ID
18 20
     };
19 21
 }

+ 28
- 12
react/features/base/modal/components/JitsiModal.js ファイルの表示

@@ -1,7 +1,7 @@
1 1
 // @flow
2 2
 
3 3
 import React, { PureComponent } from 'react';
4
-import { SafeAreaView, View } from 'react-native';
4
+import { KeyboardAvoidingView, SafeAreaView } from 'react-native';
5 5
 
6 6
 import { ColorSchemeRegistry } from '../../color-scheme';
7 7
 import { HeaderWithNavigation, SlidingView } from '../../react';
@@ -40,9 +40,16 @@ type Props = {
40 40
     dispatch: Function,
41 41
 
42 42
     /**
43
-     * The i18n label key of the header title.
43
+     * Optional function that renders a footer component, if needed.
44 44
      */
45
-    headerLabelKey: string,
45
+    footerComponent?: Function,
46
+
47
+    /**
48
+     * Props to be passed over to the header.
49
+     *
50
+     * See {@code HeaderWithNavigation} for more details.
51
+     */
52
+    headerProps: Object,
46 53
 
47 54
     /**
48 55
      * The ID of the modal that is being rendered. This is used to show/hide the modal.
@@ -58,7 +65,12 @@ type Props = {
58 65
      * The position from where the modal should be opened. This is derived from the
59 66
      * props of the {@code SlidingView} with the same name.
60 67
      */
61
-    position?: string
68
+    position?: string,
69
+
70
+    /**
71
+     * Additional style to be appended to the View containing the content of the modal.
72
+     */
73
+    style?: StyleType
62 74
 };
63 75
 
64 76
 /**
@@ -87,25 +99,28 @@ class JitsiModal extends PureComponent<Props> {
87 99
      * @inheritdoc
88 100
      */
89 101
     render() {
90
-        const { _headerStyles, _show, _styles, children, headerLabelKey, position } = this.props;
102
+        const { _headerStyles, _show, _styles, children, footerComponent, headerProps, position, style } = this.props;
91 103
 
92 104
         return (
93 105
             <SlidingView
94 106
                 onHide = { this._onRequestClose }
95 107
                 position = { position }
96 108
                 show = { _show }>
97
-                <View
109
+                <KeyboardAvoidingView
110
+                    behavior = 'padding'
98 111
                     style = { [
99 112
                         _headerStyles.page,
100
-                        _styles.page
113
+                        _styles.page,
114
+                        style
101 115
                     ] }>
102 116
                     <HeaderWithNavigation
103
-                        headerLabelKey = { headerLabelKey }
117
+                        { ...headerProps }
104 118
                         onPressBack = { this._onRequestClose } />
105 119
                     <SafeAreaView style = { styles.safeArea }>
106 120
                         { children }
107 121
                     </SafeAreaView>
108
-                </View>
122
+                    { footerComponent && footerComponent() }
123
+                </KeyboardAvoidingView>
109 124
             </SlidingView>
110 125
         );
111 126
     }
@@ -119,14 +134,15 @@ class JitsiModal extends PureComponent<Props> {
119 134
      */
120 135
     _onRequestClose() {
121 136
         const { _show, dispatch, onClose } = this.props;
137
+        let shouldCloseModal = true;
122 138
 
123 139
         if (_show) {
124 140
             if (typeof onClose === 'function') {
125
-                onClose();
141
+                shouldCloseModal = onClose();
126 142
             }
127
-            dispatch(setActiveModalId());
143
+            shouldCloseModal && dispatch(setActiveModalId());
128 144
 
129
-            return true;
145
+            return shouldCloseModal;
130 146
         }
131 147
 
132 148
         return false;

+ 1
- 0
react/features/base/modal/components/styles.js ファイルの表示

@@ -10,6 +10,7 @@ export default {
10 10
 
11 11
 ColorSchemeRegistry.register('Modal', {
12 12
     page: {
13
+        alignItems: 'stretch',
13 14
         backgroundColor: schemeColor('background')
14 15
     }
15 16
 });

+ 2
- 1
react/features/base/modal/reducer.js ファイルの表示

@@ -9,7 +9,8 @@ ReducerRegistry.register('features/base/modal', (state = {}, action) => {
9 9
     case SET_ACTIVE_MODAL_ID:
10 10
         return {
11 11
             ...state,
12
-            activeModalId: action.activeModalId
12
+            activeModalId: action.activeModalId,
13
+            modalProps: action.modalProps
13 14
         };
14 15
     }
15 16
 

+ 6
- 10
react/features/chat/components/native/Chat.js ファイルの表示

@@ -1,7 +1,6 @@
1 1
 // @flow
2 2
 
3 3
 import React from 'react';
4
-import { KeyboardAvoidingView } from 'react-native';
5 4
 
6 5
 import { translate } from '../../../base/i18n';
7 6
 import { JitsiModal } from '../../../base/modal';
@@ -18,7 +17,6 @@ import AbstractChat, {
18 17
 import ChatInputBar from './ChatInputBar';
19 18
 import MessageContainer from './MessageContainer';
20 19
 import MessageRecipient from './MessageRecipient';
21
-import styles from './styles';
22 20
 
23 21
 /**
24 22
  * Implements a React native component that renders the chat window (modal) of
@@ -33,15 +31,13 @@ class Chat extends AbstractChat<Props> {
33 31
     render() {
34 32
         return (
35 33
             <JitsiModal
36
-                headerLabelKey = 'chat.title'
34
+                headerProps = {{
35
+                    headerLabelKey: 'chat.title'
36
+                }}
37 37
                 modalId = { CHAT_VIEW_MODAL_ID }>
38
-                <KeyboardAvoidingView
39
-                    behavior = 'padding'
40
-                    style = { styles.chatContainer }>
41
-                    <MessageContainer messages = { this.props._messages } />
42
-                    <MessageRecipient />
43
-                    <ChatInputBar onSend = { this.props._onSendMessage } />
44
-                </KeyboardAvoidingView>
38
+                <MessageContainer messages = { this.props._messages } />
39
+                <MessageRecipient />
40
+                <ChatInputBar onSend = { this.props._onSendMessage } />
45 41
             </JitsiModal>
46 42
         );
47 43
     }

+ 0
- 6
react/features/chat/components/native/styles.js ファイルの表示

@@ -23,12 +23,6 @@ export default {
23 23
         width: 32
24 24
     },
25 25
 
26
-    chatContainer: {
27
-        alignItems: 'stretch',
28
-        flex: 1,
29
-        flexDirection: 'column'
30
-    },
31
-
32 26
     chatLink: {
33 27
         color: ColorPalette.blue
34 28
     },

+ 15
- 4
react/features/conference/components/native/Conference.js ファイルの表示

@@ -213,6 +213,19 @@ class Conference extends AbstractConference<Props, *> {
213 213
         return true;
214 214
     }
215 215
 
216
+    /**
217
+     * Renders JitsiModals that are supposed to be on the conference screen.
218
+     *
219
+     * @returns {Array<ReactElement>}
220
+     */
221
+    _renderConferenceModals() {
222
+        return [
223
+            <AddPeopleDialog key = 'addPeopleDialog' />,
224
+            <Chat key = 'chat' />,
225
+            <SharedDocument key = 'sharedDocument' />
226
+        ];
227
+    }
228
+
216 229
     /**
217 230
      * Renders the conference notification badge if the feature is enabled.
218 231
      *
@@ -252,10 +265,6 @@ class Conference extends AbstractConference<Props, *> {
252 265
 
253 266
         return (
254 267
             <>
255
-                <AddPeopleDialog />
256
-                <Chat />
257
-                <SharedDocument />
258
-
259 268
                 {/*
260 269
                   * The LargeVideo is the lowermost stacking layer.
261 270
                   */
@@ -335,6 +344,8 @@ class Conference extends AbstractConference<Props, *> {
335 344
                 <TestConnectionInfo />
336 345
 
337 346
                 { this._renderConferenceNotification() }
347
+
348
+                { this._renderConferenceModals() }
338 349
             </>
339 350
         );
340 351
     }

+ 4
- 0
react/features/conference/middleware.js ファイルの表示

@@ -10,6 +10,7 @@ import {
10 10
     setPreferredReceiverVideoQuality
11 11
 } from '../base/conference';
12 12
 import { hideDialog, isDialogOpen } from '../base/dialog';
13
+import { setActiveModalId } from '../base/modal';
13 14
 import { pinParticipant } from '../base/participants';
14 15
 import { SET_REDUCED_UI } from '../base/responsive-ui';
15 16
 import { MiddlewareRegistry, StateListenerRegistry } from '../base/redux';
@@ -84,5 +85,8 @@ StateListenerRegistry.register(
84 85
                 // dialog we might have open.
85 86
                 dispatch(hideDialog());
86 87
             }
88
+
89
+            // We want to close all modals.
90
+            dispatch(setActiveModalId());
87 91
         }
88 92
     });

+ 3
- 1
react/features/help/components/HelpView.js ファイルの表示

@@ -31,7 +31,9 @@ class HelpView extends PureComponent<Props> {
31 31
     render() {
32 32
         return (
33 33
             <JitsiModal
34
-                headerLabelKey = 'helpView.header'
34
+                headerProps = {{
35
+                    headerLabelKey: 'helpView.header'
36
+                }}
35 37
                 modalId = { HELP_VIEW_MODAL_ID }>
36 38
                 <WebView source = {{ uri: this.props._url }} />
37 39
             </JitsiModal>

+ 15
- 2
react/features/welcome/components/WelcomePage.native.js ファイルの表示

@@ -22,6 +22,7 @@ import {
22 22
     createDesiredLocalTracks,
23 23
     destroyLocalTracks
24 24
 } from '../../base/tracks';
25
+import { HelpView } from '../../help';
25 26
 import { DialInSummary } from '../../invite';
26 27
 import { SettingsView } from '../../settings';
27 28
 
@@ -288,10 +289,9 @@ class WelcomePage extends AbstractWelcomePage {
288 289
                         </View>
289 290
                     </SafeAreaView>
290 291
                     <WelcomePageLists disabled = { this.state._fieldFocused } />
291
-                    <SettingsView />
292
-                    <DialInSummary />
293 292
                 </View>
294 293
                 <WelcomePageSideBar />
294
+                { this._renderWelcomePageModals() }
295 295
             </LocalVideoTrackUnderlay>
296 296
         );
297 297
     }
@@ -312,6 +312,19 @@ class WelcomePage extends AbstractWelcomePage {
312 312
             </View>
313 313
         );
314 314
     }
315
+
316
+    /**
317
+     * Renders JitsiModals that are supposed to be on the welcome page.
318
+     *
319
+     * @returns {Array<ReactElement>}
320
+     */
321
+    _renderWelcomePageModals() {
322
+        return [
323
+            <HelpView key = 'helpView' />,
324
+            <DialInSummary key = 'dialInSummary' />,
325
+            <SettingsView key = 'settings' />
326
+        ];
327
+    }
315 328
 }
316 329
 
317 330
 /**

読み込み中…
キャンセル
保存