Browse Source

Coding style: comments, sorting order

master
Lyubo Marinov 7 years ago
parent
commit
ccbf3efa38

+ 2
- 1
react/features/conference/components/Conference.native.js View File

129
                 this._onHardwareBackPress);
129
                 this._onHardwareBackPress);
130
         }
130
         }
131
 
131
 
132
-        // Show the toolbox if we are the only participant.
132
+        // Show the toolbox if we are the only participant; otherwise, the whole
133
+        // UI looks too unpopulated the LargeVideo visible.
133
         const { _participantCount, _setToolboxVisible } = this.props;
134
         const { _participantCount, _setToolboxVisible } = this.props;
134
 
135
 
135
         _participantCount === 1 && _setToolboxVisible(true);
136
         _participantCount === 1 && _setToolboxVisible(true);

+ 87
- 68
react/features/toolbox/components/native/Toolbox.js View File

22
 import VideoMuteButton from '../VideoMuteButton';
22
 import VideoMuteButton from '../VideoMuteButton';
23
 
23
 
24
 /**
24
 /**
25
- * The number of buttons to render in {@link Toolbox}.
25
+ * The number of buttons other than {@link HangupButton} to render in
26
+ * {@link Toolbox}.
26
  *
27
  *
27
  * @private
28
  * @private
28
  * @type number
29
  * @type number
84
         this._onLayout = this._onLayout.bind(this);
85
         this._onLayout = this._onLayout.bind(this);
85
     }
86
     }
86
 
87
 
87
-    /**
88
-     * Renders the toolbar. It will only be rendered if the {@code Toolbox} is
89
-     * visible and we have already calculated the available width. This avoids
90
-     * a weird effect in which the toolbar is displayed and then changes size.
91
-     *
92
-     * @returns {ReactElement}
93
-     */
94
-    _renderToolbar() {
95
-        const { _visible } = this.props;
96
-        const { width } = this.state;
97
-
98
-        if (!_visible || !width) {
99
-            return null;
100
-        }
101
-
102
-        let buttonStyles = toolbarButtonStyles;
103
-        let toggledButtonStyles = toolbarToggledButtonStyles;
104
-
105
-        const buttonSize = this._calculateButtonSize();
106
-
107
-        if (buttonSize > 0) {
108
-            const extraButtonStyle = {
109
-                borderRadius: buttonSize / 2,
110
-                height: buttonSize,
111
-                width: buttonSize
112
-            };
113
-
114
-            buttonStyles = {
115
-                ...buttonStyles,
116
-                style: [ buttonStyles.style, extraButtonStyle ]
117
-            };
118
-            toggledButtonStyles = {
119
-                ...toggledButtonStyles,
120
-                style: [ toggledButtonStyles.style, extraButtonStyle ]
121
-            };
122
-        }
123
-
124
-        return (
125
-            <View
126
-                pointerEvents = 'box-none'
127
-                style = { styles.toolbar }>
128
-                <InviteButton styles = { buttonStyles } />
129
-                <AudioMuteButton
130
-                    styles = { buttonStyles }
131
-                    toggledStyles = { toggledButtonStyles } />
132
-                <HangupButton styles = { hangupButtonStyles } />
133
-                <VideoMuteButton
134
-                    styles = { buttonStyles }
135
-                    toggledStyles = { toggledButtonStyles } />
136
-                <OverflowMenuButton
137
-                    styles = { buttonStyles }
138
-                    toggledStyles = { toggledButtonStyles } />
139
-            </View>
140
-        );
141
-    }
142
-
143
     /**
88
     /**
144
      * Implements React's {@link Component#render()}.
89
      * Implements React's {@link Component#render()}.
145
      *
90
      *
151
             = isNarrowAspectRatio(this)
96
             = isNarrowAspectRatio(this)
152
                 ? styles.toolboxNarrow
97
                 ? styles.toolboxNarrow
153
                 : styles.toolboxWide;
98
                 : styles.toolboxWide;
154
-        const { _visible } = this.props;
155
 
99
 
156
         return (
100
         return (
157
             <Container
101
             <Container
158
                 onLayout = { this._onLayout }
102
                 onLayout = { this._onLayout }
159
                 style = { toolboxStyle }
103
                 style = { toolboxStyle }
160
-                visible = { _visible }>
104
+                visible = { this.props._visible }>
161
                 { this._renderToolbar() }
105
                 { this._renderToolbar() }
162
             </Container>
106
             </Container>
163
         );
107
         );
173
      */
117
      */
174
     _calculateButtonSize() {
118
     _calculateButtonSize() {
175
         const { width } = this.state;
119
         const { width } = this.state;
176
-        const hangupButtonSize = styles.hangupButton.width;
177
 
120
 
121
+        if (width <= 0) {
122
+            // We don't know how much space is allocated to the toolbar yet.
123
+            return width;
124
+        }
125
+
126
+        const hangupButtonSize = styles.hangupButton.width;
127
+        const { style } = toolbarButtonStyles;
178
         let buttonSize
128
         let buttonSize
179
             = (width
129
             = (width
130
+
131
+                    // Account for HangupButton without its margin which is not
132
+                    // included in _BUTTON_COUNT:
180
                     - hangupButtonSize
133
                     - hangupButtonSize
181
-                    - (_BUTTON_COUNT
182
-                        * styles.toolbarButton.marginHorizontal * 2))
134
+
135
+                    // Account for the horizontal margins of all buttons:
136
+                    - ((_BUTTON_COUNT + 1) * style.marginHorizontal * 2))
183
                 / _BUTTON_COUNT;
137
                 / _BUTTON_COUNT;
184
 
138
 
185
-        // Make sure it's an even number.
186
-        buttonSize = 2 * Math.round(buttonSize / 2);
139
+        // Well, don't return a non-positive button size.
140
+        if (buttonSize <= 0) {
141
+            buttonSize = style.width;
142
+        }
143
+
144
+        // The button should be at most _BUTTON_SIZE_FACTOR of the hangup
145
+        // button's size.
146
+        buttonSize
147
+            = Math.min(buttonSize, hangupButtonSize * _BUTTON_SIZE_FACTOR);
187
 
148
 
188
-        // The button should be at most 80% of the hangup button's size.
189
-        return Math.min(
190
-            buttonSize,
191
-            hangupButtonSize * _BUTTON_SIZE_FACTOR);
149
+        // Make sure it's an even number.
150
+        return 2 * Math.round(buttonSize / 2);
192
     }
151
     }
193
 
152
 
194
     _onLayout: (Object) => void;
153
     _onLayout: (Object) => void;
204
     _onLayout({ nativeEvent: { layout: { width } } }) {
163
     _onLayout({ nativeEvent: { layout: { width } } }) {
205
         this.setState({ width });
164
         this.setState({ width });
206
     }
165
     }
166
+
167
+    /**
168
+     * Renders the toolbar. In order to avoid a weird visual effect in which the
169
+     * toolbar is (visually) rendered and then visibly changes its size, it is
170
+     * rendered only after we've figured out the width available to the toolbar.
171
+     *
172
+     * @returns {React$Node}
173
+     */
174
+    _renderToolbar() {
175
+        const buttonSize = this._calculateButtonSize();
176
+        let buttonStyles = toolbarButtonStyles;
177
+        let toggledButtonStyles = toolbarToggledButtonStyles;
178
+
179
+        if (buttonSize > 0) {
180
+            const extraButtonStyle = {
181
+                borderRadius: buttonSize / 2,
182
+                height: buttonSize,
183
+                width: buttonSize
184
+            };
185
+
186
+            // XXX The following width equality checks attempt to minimize
187
+            // unnecessary objects and possibly re-renders.
188
+            if (buttonStyles.style.width !== extraButtonStyle.width) {
189
+                buttonStyles = {
190
+                    ...buttonStyles,
191
+                    style: [ buttonStyles.style, extraButtonStyle ]
192
+                };
193
+            }
194
+            if (toggledButtonStyles.style.width !== extraButtonStyle.width) {
195
+                toggledButtonStyles = {
196
+                    ...toggledButtonStyles,
197
+                    style: [ toggledButtonStyles.style, extraButtonStyle ]
198
+                };
199
+            }
200
+        } else {
201
+            // XXX In order to avoid a weird visual effect in which the toolbar
202
+            // is (visually) rendered and then visibly changes its size, it is
203
+            // rendered only after we've figured out the width available to the
204
+            // toolbar.
205
+            return null;
206
+        }
207
+
208
+        return (
209
+            <View
210
+                pointerEvents = 'box-none'
211
+                style = { styles.toolbar }>
212
+                <InviteButton styles = { buttonStyles } />
213
+                <AudioMuteButton
214
+                    styles = { buttonStyles }
215
+                    toggledStyles = { toggledButtonStyles } />
216
+                <HangupButton styles = { hangupButtonStyles } />
217
+                <VideoMuteButton
218
+                    styles = { buttonStyles }
219
+                    toggledStyles = { toggledButtonStyles } />
220
+                <OverflowMenuButton
221
+                    styles = { buttonStyles }
222
+                    toggledStyles = { toggledButtonStyles } />
223
+            </View>
224
+        );
225
+    }
207
 }
226
 }
208
 
227
 
209
 /**
228
 /**

+ 4
- 1
react/features/toolbox/components/native/styles.js View File

15
     flexDirection: 'row',
15
     flexDirection: 'row',
16
     height: 40,
16
     height: 40,
17
     justifyContent: 'center',
17
     justifyContent: 'center',
18
+
19
+    // XXX We probably tested BoxModel.margin and discovered it to be too small
20
+    // for our taste.
18
     marginHorizontal: 7,
21
     marginHorizontal: 7,
19
     opacity: 0.7,
22
     opacity: 0.7,
20
     width: 40
23
     width: 40
181
         flex: 1,
184
         flex: 1,
182
         fontSize: 16,
185
         fontSize: 16,
183
         marginLeft: 32,
186
         marginLeft: 32,
184
-        opacity: 0.87
187
+        opacity: 0.90
185
     }
188
     }
186
 });
189
 });
187
 
190
 

Loading…
Cancel
Save