Browse Source

Coding style

master
Lyubo Marinov 7 years ago
parent
commit
d0c079dba5

+ 5
- 4
react/features/app/components/App.native.js View File

@@ -89,16 +89,17 @@ export class App extends AbstractApp {
89 89
     }
90 90
 
91 91
     /**
92
-     * Overrides the super method to inject {@link AspectRatioDetector} as
93
-     * the top most component.
92
+     * Injects {@link AspectRatioDetector} in order to detect the aspect ratio
93
+     * of this {@code App}'s user interface and afford {@link AspectRatioAware}.
94 94
      *
95 95
      * @override
96 96
      */
97 97
     _createElement(component, props) {
98 98
         return (
99 99
             <AspectRatioDetector>
100
-                {super._createElement(component, props)}
101
-            </AspectRatioDetector>);
100
+                { super._createElement(component, props) }
101
+            </AspectRatioDetector>
102
+        );
102 103
     }
103 104
 
104 105
     /**

+ 5
- 4
react/features/base/aspect-ratio/actionTypes.js View File

@@ -1,9 +1,10 @@
1 1
 /**
2
- * The type of (redux) action which signals that a new aspect ratio has been
3
- * detected by the app.
2
+ * The type of (redux) action which sets the aspect ratio of the app's user
3
+ * interface.
4
+ *
4 5
  * {
5
- *      type: SET_ASPECT_RATIO,
6
- *      aspectRatio: Symbol
6
+ *     type: SET_ASPECT_RATIO,
7
+ *     aspectRatio: Symbol
7 8
  * }
8 9
  */
9 10
 export const SET_ASPECT_RATIO = Symbol('SET_ASPECT_RATIO');

+ 7
- 7
react/features/base/aspect-ratio/actions.js View File

@@ -1,22 +1,22 @@
1
-/* @flow */
1
+// @flow
2 2
 
3 3
 import { SET_ASPECT_RATIO } from './actionTypes';
4 4
 import { ASPECT_RATIO_NARROW, ASPECT_RATIO_WIDE } from './constants';
5 5
 
6 6
 /**
7
- * Calculates new aspect ratio for the app based on provided width and height
8
- * values.
7
+ * Sets the aspect ratio of the app's user interface based on specific width and
8
+ * height.
9 9
  *
10
- * @param {number} width - The width of the app's area used on the screen.
11
- * @param {number} height - The height of the app's area used on the screen.
10
+ * @param {number} width - The width of the app's user interface.
11
+ * @param {number} height - The height of the app's user interface.
12 12
  * @returns {{
13 13
  *      type: SET_ASPECT_RATIO,
14 14
  *      aspectRatio: Symbol
15 15
  * }}
16 16
  */
17
-export function calculateNewAspectRatio(width: number, height: number): Object {
17
+export function setAspectRatio(width: number, height: number): Object {
18 18
     return {
19 19
         type: SET_ASPECT_RATIO,
20
-        aspectRatio: width > height ? ASPECT_RATIO_WIDE : ASPECT_RATIO_NARROW
20
+        aspectRatio: width < height ? ASPECT_RATIO_NARROW : ASPECT_RATIO_WIDE
21 21
     };
22 22
 }

+ 8
- 8
react/features/base/aspect-ratio/components/AspectRatioAware.js View File

@@ -7,12 +7,12 @@ import { connect } from 'react-redux';
7 7
 import { ASPECT_RATIO_NARROW, ASPECT_RATIO_WIDE } from '../constants';
8 8
 
9 9
 /**
10
- * Checks if given React component decorated in {@link AspectRatioAwareWrapper}
11
- * has currently the {@link ASPECT_RATIO_NARROW} set in the aspect ratio
12
- * property.
10
+ * Determines whether a specific React {@code Component} decorated into an
11
+ * {@link AspectRatioAware} has {@link ASPECT_RATIO_NARROW} as the value of its
12
+ * {@code aspectRatio} React prop.
13 13
  *
14
- * @param {AspectRatioAwareWrapper} component - A
15
- * {@link AspectRatioAwareWrapper} which has <tt>aspectRation</tt> property.
14
+ * @param {AspectRatioAware} component - An {@link AspectRatioAware} which may
15
+ * have an {@code aspectRatio} React prop.
16 16
  * @returns {boolean}
17 17
  */
18 18
 export function isNarrowAspectRatio(component: React$Component<*>) {
@@ -62,13 +62,13 @@ export function makeAspectRatioAware(
62 62
 }
63 63
 
64 64
 /**
65
- * Maps Redux state to {@link AspectRatioAwareWrapper} properties.
65
+ * Maps (parts of) the redux state to {@link AspectRatioAware} props.
66 66
  *
67
- * @param {Object} state - The Redux whole state.
67
+ * @param {Object} state - The whole redux state.
68
+ * @private
68 69
  * @returns {{
69 70
  *      aspectRatio: Symbol
70 71
  * }}
71
- * @private
72 72
  */
73 73
 function _mapStateToProps(state) {
74 74
     return {

+ 11
- 12
react/features/base/aspect-ratio/components/AspectRatioDetector.native.js View File

@@ -3,7 +3,7 @@ import React, { Component } from 'react';
3 3
 import { View } from 'react-native';
4 4
 import { connect } from 'react-redux';
5 5
 
6
-import { calculateNewAspectRatio } from '../actions';
6
+import { setAspectRatio } from '../actions';
7 7
 import styles from './styles';
8 8
 
9 9
 /**
@@ -25,7 +25,7 @@ class AspectRatioDetector extends Component {
25 25
         /**
26 26
          * Any nested components.
27 27
          */
28
-        children: PropTypes.object
28
+        children: PropTypes.node
29 29
     };
30 30
 
31 31
     /**
@@ -37,9 +37,10 @@ class AspectRatioDetector extends Component {
37 37
         return (
38 38
             <View
39 39
                 onLayout = { this.props._onLayout }
40
-                style = { styles.aspectRatioDetectorStyle } >
41
-                {this.props.children}
42
-            </View>);
40
+                style = { styles.aspectRatioDetector } >
41
+                { this.props.children }
42
+            </View>
43
+        );
43 44
     }
44 45
 }
45 46
 
@@ -58,15 +59,13 @@ function _mapDispatchToProps(dispatch) {
58 59
          * Handles the "on layout" View's event and dispatches aspect ratio
59 60
          * changed action.
60 61
          *
61
-         * @param {{ width: number, height: number }} event - The "on layout"
62
-         * event structure passed by react-native.
63
-         * @returns {void}
62
+         * @param {Object} event - The "on layout" event object/structure passed
63
+         * by react-native.
64 64
          * @private
65
+         * @returns {void}
65 66
          */
66
-        _onLayout(event) {
67
-            const { width, height } = event.nativeEvent.layout;
68
-
69
-            dispatch(calculateNewAspectRatio(width, height));
67
+        _onLayout({ nativeEvent: { layout: { height, width } } }) {
68
+            dispatch(setAspectRatio(width, height));
70 69
         }
71 70
     };
72 71
 }

+ 5
- 5
react/features/base/aspect-ratio/components/styles.js View File

@@ -1,14 +1,14 @@
1
-import { createStyleSheet, fixAndroidViewClipping } from '../../styles/index';
1
+import { createStyleSheet } from '../../styles';
2 2
 
3 3
 /**
4
- * The styles of the feature app.
4
+ * The styles of the feature base/aspect-ratio.
5 5
  */
6 6
 export default createStyleSheet({
7 7
     /**
8
-     * The style for {@link AspectRatioDetector} root view used on react-native.
8
+     * The style of {@link AspectRatioDetector} used on react-native.
9 9
      */
10
-    aspectRatioDetectorStyle: fixAndroidViewClipping({
10
+    aspectRatioDetector: {
11 11
         alignSelf: 'stretch',
12 12
         flex: 1
13
-    })
13
+    }
14 14
 });

+ 4
- 4
react/features/base/aspect-ratio/constants.js View File

@@ -1,14 +1,14 @@
1 1
 /**
2
- * The aspect ratio constant indicates that the app area's width is smaller than
3
- * the height.
2
+ * The aspect ratio constant which indicates that the width (of whatever the
3
+ * aspect ratio constant is used for) is smaller than the height.
4 4
  *
5 5
  * @type {Symbol}
6 6
  */
7 7
 export const ASPECT_RATIO_NARROW = Symbol('ASPECT_RATIO_NARROW');
8 8
 
9 9
 /**
10
- * Aspect ratio constant indicates that the app area's width is larger than
11
- * the height.
10
+ * The aspect ratio constant which indicates that the width (of whatever the
11
+ * aspect ratio constant is used for) is larger than the height.
12 12
  *
13 13
  * @type {Symbol}
14 14
  */

+ 12
- 9
react/features/base/aspect-ratio/reducer.js View File

@@ -3,17 +3,20 @@ import { ReducerRegistry, set } from '../redux';
3 3
 import { SET_ASPECT_RATIO } from './actionTypes';
4 4
 import { ASPECT_RATIO_NARROW } from './constants';
5 5
 
6
-const INITIAL_STATE = {
6
+/**
7
+ * The initial redux state of the feature base/aspect-ratio.
8
+ */
9
+const _INITIAL_STATE = {
7 10
     aspectRatio: ASPECT_RATIO_NARROW
8 11
 };
9 12
 
10 13
 ReducerRegistry.register(
11
-'features/base/aspect-ratio',
12
-(state = INITIAL_STATE, action) => {
13
-    switch (action.type) {
14
-    case SET_ASPECT_RATIO:
15
-        return set(state, 'aspectRatio', action.aspectRatio);
16
-    }
14
+    'features/base/aspect-ratio',
15
+    (state = _INITIAL_STATE, action) => {
16
+        switch (action.type) {
17
+        case SET_ASPECT_RATIO:
18
+            return set(state, 'aspectRatio', action.aspectRatio);
19
+        }
17 20
 
18
-    return state;
19
-});
21
+        return state;
22
+    });

+ 6
- 7
react/features/conference/components/Conference.native.js View File

@@ -202,16 +202,15 @@ class Conference extends Component {
202 202
 
203 203
                 <View style = { styles.toolboxAndFilmstripContainer } >
204 204
                     {/*
205
-                      * The Toolbox is in a stacking layer above the Filmstrip.
205
+                      * The Toolbox is in a stacking layer bellow the Filmstrip.
206 206
                       */}
207 207
                     <Toolbox />
208 208
                     {/*
209
-                      * The Filmstrip is in a stacking layer above
210
-                      * the LargeVideo.
211
-                      * The LargeVideo and the Filmstrip form what the Web/React
212
-                      * app calls "videospace". Presumably, the name and
213
-                      * grouping stem from the fact that these two React
214
-                      * Components depict the videos of the conference's
209
+                      * The Filmstrip is in a stacking layer above the
210
+                      * LargeVideo. The LargeVideo and the Filmstrip form what
211
+                      * the Web/React app calls "videospace". Presumably, the
212
+                      * name and grouping stem from the fact that these two
213
+                      * React Components depict the videos of the conference's
215 214
                       * participants.
216 215
                       */}
217 216
                     <Filmstrip />

+ 1
- 1
react/features/conference/components/styles.js View File

@@ -47,8 +47,8 @@ export default createStyleSheet({
47 47
     toolboxAndFilmstripContainer: {
48 48
         bottom: 0,
49 49
         flexDirection: 'column',
50
-        left: 0,
51 50
         justifyContent: 'flex-end',
51
+        left: 0,
52 52
         position: 'absolute',
53 53
         right: 0,
54 54
         top: 0

+ 9
- 10
react/features/filmstrip/components/Filmstrip.native.js View File

@@ -51,20 +51,21 @@ class Filmstrip extends Component<*> {
51 51
      * @returns {ReactElement}
52 52
      */
53 53
     render() {
54
+        const isNarrowAspectRatio_ = isNarrowAspectRatio(this);
54 55
         const filmstripStyle
55
-            = isNarrowAspectRatio(this)
56
-                ? styles.filmstripNarrow : styles.filmstripWide;
56
+            = isNarrowAspectRatio_
57
+                ? styles.filmstripNarrow
58
+                : styles.filmstripWide;
57 59
 
58 60
         return (
59 61
             <Container
60 62
                 style = { filmstripStyle }
61
-                visible = { this.props._visible } >
63
+                visible = { this.props._visible }>
62 64
                 <ScrollView
63
-                    horizontal = { isNarrowAspectRatio(this) }
65
+                    horizontal = { isNarrowAspectRatio_ }
64 66
                     showsHorizontalScrollIndicator = { false }
65 67
                     showsVerticalScrollIndicator = { false }>
66 68
                     {
67
-
68 69
                         /* eslint-disable react/jsx-wrap-multilines */
69 70
 
70 71
                         this._sort(this.props._participants)
@@ -138,11 +139,9 @@ function _mapStateToProps(state) {
138 139
         _participants: participants,
139 140
 
140 141
         /**
141
-         * The indicator which determines whether the filmstrip is visible.
142
-         *
143
-         * XXX The React Component Filmstrip is used on mobile only at the time
144
-         * of this writing and on mobile the filmstrip is when there are at
145
-         * least 2 participants in the conference (including the local one).
142
+         * The indicator which determines whether the filmstrip is visible. The
143
+         * mobile/react-native Filmstrip is visible when there are at least 2
144
+         * participants in the conference (including the local one).
146 145
          *
147 146
          * @private
148 147
          * @type {boolean}

+ 10
- 10
react/features/filmstrip/components/styles.js View File

@@ -2,11 +2,11 @@ import { Platform } from '../../base/react';
2 2
 import { BoxModel, ColorPalette } from '../../base/styles';
3 3
 
4 4
 /**
5
- * The base filmstrip style shared between narrow and wide versions.
5
+ * The base style of {@link Filmstrip} shared between narrow and wide versions.
6 6
  */
7
-const filmstripBaseStyle = {
8
-    flexGrow: 0,
9
-    flexDirection: 'column'
7
+const filmstrip = {
8
+    flexDirection: 'column',
9
+    flexGrow: 0
10 10
 };
11 11
 
12 12
 /**
@@ -48,11 +48,11 @@ export default {
48 48
     },
49 49
 
50 50
     /**
51
-     * The style of the narrow filmstrip version which displays thumbnails
52
-     * in a row at the bottom of the screen.
51
+     * The style of the narrow {@link Filmstrip} version which displays
52
+     * thumbnails in a row at the bottom of the screen.
53 53
      */
54 54
     filmstripNarrow: {
55
-        ...filmstripBaseStyle,
55
+        ...filmstrip,
56 56
         alignItems: 'flex-end',
57 57
         height: 90,
58 58
         marginBottom: BoxModel.margin,
@@ -61,11 +61,11 @@ export default {
61 61
     },
62 62
 
63 63
     /**
64
-     * The style of the wide version of the filmstrip which appears as a column
65
-     * on the short side of the screen.
64
+     * The style of the wide {@link Filmstrip} version which displays thumbnails
65
+     * in a column on the short size of the screen.
66 66
      */
67 67
     filmstripWide: {
68
-        ...filmstripBaseStyle,
68
+        ...filmstrip,
69 69
         bottom: BoxModel.margin,
70 70
         left: BoxModel.margin,
71 71
         position: 'absolute',

+ 12
- 16
react/features/toolbox/components/Toolbox.native.js View File

@@ -123,12 +123,14 @@ class Toolbox extends Component {
123 123
      * @returns {ReactElement}
124 124
      */
125 125
     render() {
126
+        const toolboxStyle
127
+            = isNarrowAspectRatio(this)
128
+                ? styles.toolboxNarrow
129
+                : styles.toolboxWide;
130
+
126 131
         return (
127 132
             <Container
128
-                style = {
129
-                    isNarrowAspectRatio(this)
130
-                        ? styles.toolbarContainerNarrow
131
-                        : styles.toolbarContainerWide }
133
+                style = { toolboxStyle }
132 134
                 visible = { this.props._visible } >
133 135
                 { this._renderToolbars() }
134 136
             </Container>
@@ -311,23 +313,17 @@ class Toolbox extends Component {
311 313
     }
312 314
 
313 315
     /**
314
-     * Renders the primary and the secondary toolbars in the order depending on
315
-     * the current aspect ratio.
316
+     * Renders the primary and the secondary toolbars.
316 317
      *
317
-     * @returns {[ReactElement, ReactElement]}
318 318
      * @private
319
+     * @returns {[ReactElement, ReactElement]}
319 320
      */
320 321
     _renderToolbars() {
321
-        if (isNarrowAspectRatio(this)) {
322
-            return [
323
-                this._renderSecondaryToolbar(),
324
-                this._renderPrimaryToolbar()
325
-            ];
326
-        }
327
-
328
-        return [ this._renderPrimaryToolbar(), this._renderSecondaryToolbar() ];
322
+        return [
323
+            this._renderSecondaryToolbar(),
324
+            this._renderPrimaryToolbar()
325
+        ];
329 326
     }
330
-
331 327
 }
332 328
 
333 329
 /**

+ 6
- 6
react/features/toolbox/components/styles.js View File

@@ -139,19 +139,19 @@ export default createStyleSheet({
139 139
      * spans from the top of the screen to the top of the filmstrip located at
140 140
      * the bottom of the screen.
141 141
      */
142
-    toolbarContainerNarrow: {
142
+    toolboxNarrow: {
143 143
         flexDirection: 'column',
144 144
         flexGrow: 1
145 145
     },
146 146
 
147 147
     /**
148 148
      * The style of the root/top-level {@link Container} of {@link Toolbox}
149
-     * which contains {@link Toolbar}s. This is wide layout version which
150
-     * spans from the top to the bottom of the screen and is located to
151
-     * the right of the filmstrip which is displayed as a column on the left
152
-     * side of the screen.
149
+     * which contains {@link Toolbar}s. This is wide layout version which spans
150
+     * from the top to the bottom of the screen and is located to the right of
151
+     * the filmstrip which is displayed as a column on the left side of the
152
+     * screen.
153 153
      */
154
-    toolbarContainerWide: {
154
+    toolboxWide: {
155 155
         bottom: 0,
156 156
         left: 0,
157 157
         position: 'absolute',

Loading…
Cancel
Save