瀏覽代碼

[RN] LoadingIndicator while joining a conference

j8
Saúl Ibarra Corretgé 8 年之前
父節點
當前提交
720ae18194

+ 54
- 9
react/features/conference/components/Conference.native.js 查看文件

@@ -1,9 +1,11 @@
1
+import PropTypes from 'prop-types';
1 2
 import React, { Component } from 'react';
3
+import { View } from 'react-native';
2 4
 import { connect as reactReduxConnect } from 'react-redux';
3 5
 
4 6
 import { connect, disconnect } from '../../base/connection';
5 7
 import { DialogContainer } from '../../base/dialog';
6
-import { Container } from '../../base/react';
8
+import { Container, LoadingIndicator } from '../../base/react';
7 9
 import { createDesiredLocalTracks } from '../../base/tracks';
8 10
 import { Filmstrip } from '../../filmstrip';
9 11
 import { LargeVideo } from '../../large-video';
@@ -30,38 +32,44 @@ class Conference extends Component {
30 32
      * @static
31 33
      */
32 34
     static propTypes = {
35
+        /**
36
+         * The indicator which determines that we are still connecting to the
37
+         * conference which includes establishing the XMPP connection and then
38
+         * joining the room. If truthy, then an activity/loading indicator will
39
+         * be rendered.
40
+         *
41
+         * @private
42
+         */
43
+        _connecting: PropTypes.bool,
44
+
33 45
         /**
34 46
          * The handler which dispatches the (redux) action connect.
35 47
          *
36 48
          * @private
37
-         * @type {Function}
38 49
          */
39
-        _onConnect: React.PropTypes.func,
50
+        _onConnect: PropTypes.func,
40 51
 
41 52
         /**
42 53
          * The handler which dispatches the (redux) action disconnect.
43 54
          *
44 55
          * @private
45
-         * @type {Function}
46 56
          */
47
-        _onDisconnect: React.PropTypes.func,
57
+        _onDisconnect: PropTypes.func,
48 58
 
49 59
         /**
50 60
          * The handler which dispatches the (redux) action setToolboxVisible to
51 61
          * show/hide the Toolbox.
52 62
          *
53 63
          * @private
54
-         * @type {boolean}
55 64
          */
56
-        _setToolboxVisible: React.PropTypes.func,
65
+        _setToolboxVisible: PropTypes.func,
57 66
 
58 67
         /**
59 68
          * The indicator which determines whether the Toolbox is visible.
60 69
          *
61 70
          * @private
62
-         * @type {boolean}
63 71
          */
64
-        _toolboxVisible: React.PropTypes.bool
72
+        _toolboxVisible: PropTypes.bool
65 73
     };
66 74
 
67 75
     /**
@@ -152,6 +160,16 @@ class Conference extends Component {
152 160
                   */}
153 161
                 <OverlayContainer />
154 162
 
163
+                {/*
164
+                  * The activity/loading indicator goes above everything, except
165
+                  * the toolbox/toolbars and the dialogs.
166
+                  */
167
+                  this.props._connecting
168
+                      && <View style = { styles.connectingIndicator }>
169
+                          <LoadingIndicator />
170
+                      </View>
171
+                }
172
+
155 173
                 {/*
156 174
                   * The Toolbox is in a stacking layer above the Filmstrip.
157 175
                   */}
@@ -264,11 +282,38 @@ function _mapDispatchToProps(dispatch) {
264 282
  * @param {Object} state - The Redux state.
265 283
  * @private
266 284
  * @returns {{
285
+ *     _connecting: boolean,
267 286
  *     _toolboxVisible: boolean
268 287
  * }}
269 288
  */
270 289
 function _mapStateToProps(state) {
290
+    const { connecting, connection } = state['features/base/connection'];
291
+    const { conference, joining, leaving } = state['features/base/conference'];
292
+
293
+    // XXX There is a window of time between the successful establishment of the
294
+    // XMPP connection and the subsequent commencement of joining the MUC during
295
+    // which the app does not appear to be doing anything according to the redux
296
+    // state. In order to not toggle the _connecting props during the window of
297
+    // time in question, define _connecting as follows:
298
+    // - the XMPP connection is connecting, or
299
+    // - the XMPP connection is connected and the conference is joining, or
300
+    // - the XMPP connection is connected and we have no conference yet, nor we
301
+    //   are leaving one.
302
+    const connecting_
303
+        = connecting || (connection && (joining || (!conference && !leaving)));
304
+
271 305
     return {
306
+        /**
307
+         * The indicator which determines that we are still connecting to the
308
+         * conference which includes establishing the XMPP connection and then
309
+         * joining the room. If truthy, then an activity/loading indicator will
310
+         * be rendered.
311
+         *
312
+         * @private
313
+         * @type {boolean}
314
+         */
315
+        _connecting: Boolean(connecting_),
316
+
272 317
         /**
273 318
          * The indicator which determines whether the Toolbox is visible.
274 319
          *

+ 24
- 1
react/features/conference/components/styles.js 查看文件

@@ -15,5 +15,28 @@ export default createStyleSheet({
15 15
         alignSelf: 'stretch',
16 16
         backgroundColor: ColorPalette.appBackground,
17 17
         flex: 1
18
-    })
18
+    }),
19
+
20
+    /**
21
+     * The style of the View rendered while the conference is being connected
22
+     * (i.e. the XMPP connection is being established and the MUC is being
23
+     * joined).
24
+     */
25
+    connectingIndicator: {
26
+        alignItems: 'center',
27
+        bottom: 0,
28
+        justifyContent: 'center',
29
+        left: 0,
30
+        position: 'absolute',
31
+        right: 0,
32
+        top: 0,
33
+
34
+        // Because the background of LargeVideo varies wildly (e.g. the
35
+        // participant's video or avatar), the LoadingIndicator may be difficult
36
+        // to see. Reduce the variance of the background of LargeVideo and,
37
+        // thus, increase the visibility of LoadingIndicator by introducing
38
+        // contrast and translucency.
39
+        backgroundColor: ColorPalette.appBackground,
40
+        opacity: 0.5
41
+    }
19 42
 });

Loading…
取消
儲存