Przeglądaj źródła

[RN] Show a progress indicator in the BlankPage

It will only be shown when there are ongoing network requests.
j8
Saúl Ibarra Corretgé 8 lat temu
rodzic
commit
e33030582f

+ 43
- 0
react/features/welcome/components/AbstractBlankPage.js Wyświetl plik

@@ -0,0 +1,43 @@
1
+import PropTypes from 'prop-types';
2
+import { Component } from 'react';
3
+
4
+import { destroyLocalTracks } from '../../base/tracks';
5
+
6
+/**
7
+ * A React <tt>Component</tt> which represents a blank page. Destroys the local
8
+ * tracks upon mounting since no media is desired when this component utilized.
9
+ * Renders nothing.
10
+ */
11
+export default class AbstractBlankPage extends Component {
12
+    /**
13
+     * <tt>AbstractBlankPage</tt> React <tt>Component</tt>'s prop types.
14
+     *
15
+     * @static
16
+     */
17
+    static propTypes = {
18
+        dispatch: PropTypes.func
19
+    };
20
+
21
+    /**
22
+     * Destroys the local tracks (if any) since no media is desired when this
23
+     * component is rendered.
24
+     *
25
+     * @inheritdoc
26
+     * @returns {void}
27
+     */
28
+    componentWillMount() {
29
+        this.props.dispatch(destroyLocalTracks());
30
+    }
31
+
32
+    /**
33
+     * Implements React's {@link Component#render()}. Returns null because the
34
+     * purpose of this component is to destroy the local tracks and render
35
+     * nothing.
36
+     *
37
+     * @inheritdoc
38
+     * @returns {null}
39
+     */
40
+    render() {
41
+        return null;
42
+    }
43
+}

+ 0
- 49
react/features/welcome/components/BlankPage.js Wyświetl plik

@@ -1,49 +0,0 @@
1
-import PropTypes from 'prop-types';
2
-import { Component } from 'react';
3
-import { connect } from 'react-redux';
4
-
5
-import { destroyLocalTracks } from '../../base/tracks';
6
-
7
-/**
8
- * A React <tt>Component<tt> which represents a blank page. It renders nothing
9
- * and destroys local tracks upon being mounted since no media is desired when
10
- * this component is rendered.
11
- *
12
- * The use case which prompted the introduction of this component is mobile
13
- * where SDK users probably disable the Welcome page.
14
- */
15
-class BlankPage extends Component {
16
-    /**
17
-     * {@code BlankPage} component's property types.
18
-     *
19
-     * @static
20
-     */
21
-    static propTypes = {
22
-        dispatch: PropTypes.func
23
-    };
24
-
25
-    /**
26
-     * Destroys the local tracks (if any) since no media is desired when this
27
-     * component is rendered.
28
-     *
29
-     * @inheritdoc
30
-     * @returns {void}
31
-     */
32
-    componentWillMount() {
33
-        this.props.dispatch(destroyLocalTracks());
34
-    }
35
-
36
-    /**
37
-     * Implements React's {@link Component#render()}. In this particular case
38
-     * we return null, because the entire purpose of this component is to render
39
-     * nothing.
40
-     *
41
-     * @inheritdoc
42
-     * @returns {null}
43
-     */
44
-    render() {
45
-        return null;
46
-    }
47
-}
48
-
49
-export default connect()(BlankPage);

+ 71
- 0
react/features/welcome/components/BlankPage.native.js Wyświetl plik

@@ -0,0 +1,71 @@
1
+import PropTypes from 'prop-types';
2
+import React from 'react';
3
+import { ActivityIndicator, View } from 'react-native';
4
+import { connect } from 'react-redux';
5
+
6
+import AbstractBlankPage from './AbstractBlankPage';
7
+import styles from './styles';
8
+
9
+/**
10
+ * Mobile/React Native implementation of <tt>AbstractBlankPage</tt>. Since this
11
+ * is the <tt>Component</tt> rendered when there is no <tt>WelcomePage</tt>,
12
+ * it will show a progress indicator when there are ongoing network requests
13
+ * (notably, the loading of config.js before joining a conference). The use case
14
+ * which prompted the introduction of this <tt>Component</tt> is mobile where
15
+ * SDK users probably disable the <tt>WelcomePage</tt>.
16
+ */
17
+class BlankPage extends AbstractBlankPage {
18
+    /**
19
+     * <tt>BlankPage</tt> React <tt>Component</tt>'s prop types.
20
+     *
21
+     * @static
22
+     */
23
+    static propTypes = {
24
+        ...AbstractBlankPage.propTypes,
25
+
26
+        /**
27
+         * Indicates whether there is network activity i.e. ongoing network
28
+         * requests.
29
+         *
30
+         * @private
31
+         */
32
+        _networkActivity: PropTypes.bool
33
+    };
34
+
35
+    /**
36
+     * Implements React's {@link Component#render()}.
37
+     *
38
+     * @inheritdoc
39
+     * @override
40
+     * @returns {ReactElement}
41
+     */
42
+    render() {
43
+        return (
44
+            <View style = { styles.blankPage }>
45
+                <ActivityIndicator
46
+                    animating = { this.props._networkActivity }
47
+                    size = { 'large' } />
48
+            </View>
49
+        );
50
+    }
51
+}
52
+
53
+/**
54
+ * Maps (parts of) the redux state to the React <tt>Component</tt> props of
55
+ * <tt>BlankPage</tt>.
56
+ *
57
+ * @param {Object} state - The redux state.
58
+ * @private
59
+ * @returns {{
60
+ *     networkActivity: boolean
61
+ * }}
62
+ */
63
+function _mapStateToProps(state) {
64
+    const { requests } = state['features/net-interceptor'];
65
+
66
+    return {
67
+        _networkActivity: Boolean(requests && Object.keys(requests).length)
68
+    };
69
+}
70
+
71
+export default connect(_mapStateToProps)(BlankPage);

+ 10
- 0
react/features/welcome/components/BlankPage.web.js Wyświetl plik

@@ -0,0 +1,10 @@
1
+import AbstractBlankPage from './AbstractBlankPage';
2
+
3
+/**
4
+ * Default <tt>BlankPage</tt> implementation for Web/React. It's not currently
5
+ * in use but it's here for symmetry with mobile/React Native should we choose
6
+ * to take advantage of it in the future. Destroys the local tracks and renders
7
+ * nothing.
8
+ */
9
+export default class BlankPage extends AbstractBlankPage {
10
+}

+ 13
- 1
react/features/welcome/components/styles.js Wyświetl plik

@@ -11,9 +11,21 @@ import {
11 11
 const TEXT_COLOR = ColorPalette.white;
12 12
 
13 13
 /**
14
- * The styles of WelcomePage.
14
+ * The styles of the React <tt>Components</tt> of the feature welcome including
15
+ * <tt>WelcomePage</tt> and <tt>BlankPage</tt>.
15 16
  */
16 17
 export default createStyleSheet({
18
+    /**
19
+     * The style of <tt>BlankPage</tt>.
20
+     */
21
+    blankPage: {
22
+        alignItems: 'center',
23
+        backgroundColor: 'transparent',
24
+        flex: 1,
25
+        flexDirection: 'column',
26
+        justifyContent: 'center'
27
+    },
28
+
17 29
     /**
18 30
      * Join button style.
19 31
      */

Ładowanie…
Anuluj
Zapisz