Преглед изворни кода

[RN] Group the secondary toobar buttons

Rearrange the ToolbarButtons in the secondary Toolbar in order to mostly
group the media-related ones such as the AudioRouteButton, the
switchCamera button, and the audio-only mode button.
master
Lyubo Marinov пре 8 година
родитељ
комит
e7aff1d8e1

+ 1
- 1
react/features/base/dialog/components/Dialog.native.js Прегледај датотеку

@@ -9,7 +9,7 @@ import { LoadingIndicator } from '../../react';
9 9
 import { set } from '../../redux';
10 10
 
11 11
 import AbstractDialog from './AbstractDialog';
12
-import styles from './styles';
12
+import { dialog as styles } from './styles';
13 13
 
14 14
 /**
15 15
  * The value of the style property {@link _TAG_KEY} which identifies the

+ 1
- 1
react/features/base/dialog/components/SimpleBottomSheet.native.js Прегледај датотеку

@@ -12,7 +12,7 @@ import { connect } from 'react-redux';
12 12
 
13 13
 import { Icon } from '../../font-icons';
14 14
 
15
-import { bottomSheet as styles } from './styles';
15
+import { simpleBottomSheet as styles } from './styles';
16 16
 
17 17
 /**
18 18
  * Underlay color for the buttons on the sheet.

+ 6
- 6
react/features/base/dialog/components/styles.js Прегледај датотеку

@@ -1,9 +1,9 @@
1 1
 import { ColorPalette, createStyleSheet } from '../../styles';
2 2
 
3 3
 /**
4
- * The React {@code Component} styles of the feature base/dialog.
4
+ * The React {@code Component} styles of {@code Dialog}.
5 5
  */
6
-export default createStyleSheet({
6
+export const dialog = createStyleSheet({
7 7
     /**
8 8
      * The style of the {@code Text} in a {@code Dialog} button.
9 9
      */
@@ -21,11 +21,11 @@ export default createStyleSheet({
21 21
 });
22 22
 
23 23
 /**
24
- *  The React {@code Component} styles for {@code SimpleBottomSheet}.
25
- *  These styles have been implemented as per the Material Design guidelines:
26
- *  https://material.io/guidelines/components/bottom-sheets.html
24
+ * The React {@code Component} styles of {@code SimpleBottomSheet}. These have
25
+ * been implemented as per the Material Design guidelines:
26
+ * {@link https://material.io/guidelines/components/bottom-sheets.html}.
27 27
  */
28
-export const bottomSheet = createStyleSheet({
28
+export const simpleBottomSheet = createStyleSheet({
29 29
     /**
30 30
      * Style for the container of the sheet.
31 31
      */

+ 40
- 33
react/features/mobile/audio-mode/components/AudioRoutePickerDialog.js Прегледај датотеку

@@ -7,11 +7,30 @@ import { connect } from 'react-redux';
7 7
 
8 8
 import { hideDialog, SimpleBottomSheet } from '../../../base/dialog';
9 9
 
10
-const AudioMode = NativeModules.AudioMode;
10
+/**
11
+ * {@code PasswordRequiredPrompt}'s React {@code Component} prop types.
12
+ */
13
+type Props = {
14
+
15
+    /**
16
+     * Used for hiding the dialog when the selection was completed.
17
+     */
18
+    dispatch: Function
19
+};
20
+
21
+type State = {
22
+
23
+    /**
24
+     * Array of available devices.
25
+     */
26
+    devices: Array<string>
27
+};
28
+
29
+const { AudioMode } = NativeModules;
11 30
 
12 31
 /**
13 32
  * Maps each device type to a display name and icon.
14
- * TODO: internationalization.
33
+ * TODO i18n
15 34
  */
16 35
 const deviceInfoMap = {
17 36
     BLUETOOTH: {
@@ -37,30 +56,11 @@ const deviceInfoMap = {
37 56
 };
38 57
 
39 58
 /**
40
- * Variable to hold the reference to the exported component. This dialog is only
41
- * exported if the {@code AudioMode} module has the capability to get / set
59
+ * The exported React {@code Component}. {@code AudioRoutePickerDialog} is
60
+ * exported only if the {@code AudioMode} module has the capability to get / set
42 61
  * audio devices.
43 62
  */
44
-let DialogType;
45
-
46
-/**
47
- * {@code PasswordRequiredPrompt}'s React {@code Component} prop types.
48
- */
49
-type Props = {
50
-
51
-    /**
52
-     * Used for hiding the dialog when the selection was completed.
53
-     */
54
-    dispatch: Function
55
-};
56
-
57
-type State = {
58
-
59
-    /**
60
-     * Array of available devices.
61
-     */
62
-    devices: Array<string>
63
-};
63
+let AudioRoutePickerDialog_;
64 64
 
65 65
 /**
66 66
  * Implements a React {@code Component} which prompts the user when a password
@@ -68,7 +68,10 @@ type State = {
68 68
  */
69 69
 class AudioRoutePickerDialog extends Component<Props, State> {
70 70
     state = {
71
-        // Available audio devices, it will be set in componentWillMount.
71
+        /**
72
+         * Available audio devices, it will be set in
73
+         * {@link #componentWillMount()}.
74
+         */
72 75
         devices: []
73 76
     };
74 77
 
@@ -87,7 +90,7 @@ class AudioRoutePickerDialog extends Component<Props, State> {
87 90
     }
88 91
 
89 92
     /**
90
-     * Initializes the device list by querying the {@code AudioMode} module.
93
+     * Initializes the device list by querying {@code AudioMode}.
91 94
      *
92 95
      * @inheritdoc
93 96
      */
@@ -107,8 +110,10 @@ class AudioRoutePickerDialog extends Component<Props, State> {
107 110
             }
108 111
 
109 112
             if (audioDevices) {
110
-                // Make sure devices is alphabetically sorted
111
-                this.setState({ devices: _.sortBy(audioDevices, 'text') });
113
+                // Make sure devices is alphabetically sorted.
114
+                this.setState({
115
+                    devices: _.sortBy(audioDevices, 'text')
116
+                });
112 117
             }
113 118
         });
114 119
     }
@@ -119,7 +124,7 @@ class AudioRoutePickerDialog extends Component<Props, State> {
119 124
      * @returns {void}
120 125
      */
121 126
     _hide() {
122
-        this.props.dispatch(hideDialog(DialogType));
127
+        this.props.dispatch(hideDialog(AudioRoutePickerDialog_));
123 128
     }
124 129
 
125 130
     _onCancel: () => void;
@@ -156,7 +161,9 @@ class AudioRoutePickerDialog extends Component<Props, State> {
156 161
      * @returns {ReactElement}
157 162
      */
158 163
     render() {
159
-        if (!this.state.devices.length) {
164
+        const { devices } = this.state;
165
+
166
+        if (!devices.length) {
160 167
             return null;
161 168
         }
162 169
 
@@ -164,7 +171,7 @@ class AudioRoutePickerDialog extends Component<Props, State> {
164 171
             <SimpleBottomSheet
165 172
                 onCancel = { this._onCancel }
166 173
                 onSubmit = { this._onSubmit }
167
-                options = { this.state.devices } />
174
+                options = { devices } />
168 175
         );
169 176
     }
170 177
 }
@@ -172,7 +179,7 @@ class AudioRoutePickerDialog extends Component<Props, State> {
172 179
 // Only export the dialog if we have support for getting / setting audio devices
173 180
 // in AudioMode.
174 181
 if (AudioMode.getAudioDevices && AudioMode.setAudioDevice) {
175
-    DialogType = connect()(AudioRoutePickerDialog);
182
+    AudioRoutePickerDialog_ = connect()(AudioRoutePickerDialog);
176 183
 }
177 184
 
178
-export default DialogType;
185
+export default AudioRoutePickerDialog_;

+ 28
- 38
react/features/toolbox/components/AudioRouteButton.js Прегледај датотеку

@@ -3,8 +3,8 @@
3 3
 import React, { Component } from 'react';
4 4
 import {
5 5
     findNodeHandle,
6
-    requireNativeComponent,
7 6
     NativeModules,
7
+    requireNativeComponent,
8 8
     View
9 9
 } from 'react-native';
10 10
 import { connect } from 'react-redux';
@@ -15,17 +15,15 @@ import { AudioRoutePickerDialog } from '../../mobile/audio-mode';
15 15
 import ToolbarButton from './ToolbarButton';
16 16
 
17 17
 /**
18
- * Define the {@code MPVolumeView} React component. It will only be available
18
+ * The {@code MPVolumeView} React {@code Component}. It will only be available
19 19
  * on iOS.
20 20
  */
21
-let MPVolumeView;
22
-
23
-if (NativeModules.MPVolumeViewManager) {
24
-    MPVolumeView = requireNativeComponent('MPVolumeView', null);
25
-}
21
+const MPVolumeView
22
+    = NativeModules.MPVolumeViewManager
23
+        && requireNativeComponent('MPVolumeView', null);
26 24
 
27 25
 /**
28
- * Style required to hide the {@code MPVolumeView} view, since it's displayed
26
+ * The style required to hide the {@code MPVolumeView}, since it's displayed
29 27
  * programmatically.
30 28
  */
31 29
 const HIDE_VIEW_STYLE = { display: 'none' };
@@ -33,7 +31,8 @@ const HIDE_VIEW_STYLE = { display: 'none' };
33 31
 type Props = {
34 32
 
35 33
     /**
36
-     * Used to show the {@code AudioRoutePickerDialog}.
34
+     * The redux {@code dispatch} function used to open/show the
35
+     * {@code AudioRoutePickerDialog}.
37 36
      */
38 37
     dispatch: Function,
39 38
 
@@ -48,12 +47,12 @@ type Props = {
48 47
     iconStyle: Object,
49 48
 
50 49
     /**
51
-     * {@code AudioRouteButton} styles.
50
+     * The style(s) of {@code AudioRouteButton}.
52 51
      */
53 52
     style: Array<*> | Object,
54 53
 
55 54
     /**
56
-     * The color underlying the button.
55
+     * The color underlaying the button.
57 56
      */
58 57
     underlayColor: string
59 58
 };
@@ -64,16 +63,6 @@ type Props = {
64 63
 class AudioRouteButton extends Component<Props> {
65 64
     _volumeComponent: ?Object;
66 65
 
67
-    /**
68
-     * Indicates if there is support for audio device selection via this button.
69
-     *
70
-     * @returns {boolean} - True if audio device selection is supported, false
71
-     * otherwise.
72
-     */
73
-    static supported() {
74
-        return Boolean(MPVolumeView || AudioRoutePickerDialog);
75
-    }
76
-
77 66
     /**
78 67
      * Initializes a new {@code AudioRouteButton} instance.
79 68
      *
@@ -108,27 +97,13 @@ class AudioRouteButton extends Component<Props> {
108 97
      */
109 98
     _onClick() {
110 99
         if (MPVolumeView) {
111
-            const handle = findNodeHandle(this._volumeComponent);
112
-
113
-            NativeModules.MPVolumeViewManager.show(handle);
100
+            NativeModules.MPVolumeViewManager.show(
101
+                findNodeHandle(this._volumeComponent));
114 102
         } else if (AudioRoutePickerDialog) {
115 103
             this.props.dispatch(openDialog(AudioRoutePickerDialog));
116 104
         }
117 105
     }
118 106
 
119
-    _setVolumeComponent: (?Object) => void;
120
-
121
-    /**
122
-     * Sets the internal reference to the React Component wrapping the
123
-     * {@code MPVolumeView} component.
124
-     *
125
-     * @param {ReactComponent} component - React Component.
126
-     * @returns {void}
127
-     */
128
-    _setVolumeComponent(component) {
129
-        this._volumeComponent = component;
130
-    }
131
-
132 107
     /**
133 108
      * Implements React's {@link Component#render()}.
134 109
      *
@@ -155,6 +130,21 @@ class AudioRouteButton extends Component<Props> {
155 130
             </View>
156 131
         );
157 132
     }
133
+
134
+    _setVolumeComponent: (?Object) => void;
135
+
136
+    /**
137
+     * Sets the internal reference to the React Component wrapping the
138
+     * {@code MPVolumeView} component.
139
+     *
140
+     * @param {ReactComponent} component - React Component.
141
+     * @private
142
+     * @returns {void}
143
+     */
144
+    _setVolumeComponent(component) {
145
+        this._volumeComponent = component;
146
+    }
158 147
 }
159 148
 
160
-export default connect()(AudioRouteButton);
149
+export default (MPVolumeView || AudioRoutePickerDialog)
150
+  && connect()(AudioRouteButton);

+ 2
- 1
react/features/toolbox/components/ToolbarButton.native.js Прегледај датотеку

@@ -47,8 +47,9 @@ class ToolbarButton extends AbstractToolbarButton {
47 47
         return React.createElement(TouchableHighlight, props, children);
48 48
     }
49 49
 
50
-    // eslint-disable-next-line valid-jsdoc
51 50
     /**
51
+     * Renders the icon of this {@code ToolbarButton}.
52
+     *
52 53
      * @inheritdoc
53 54
      */
54 55
     _renderIcon() {

+ 14
- 14
react/features/toolbox/components/Toolbox.native.js Прегледај датотеку

@@ -282,6 +282,14 @@ class Toolbox extends Component {
282 282
             <View
283 283
                 key = 'secondaryToolbar'
284 284
                 style = { styles.secondaryToolbar }>
285
+                {
286
+                    AudioRouteButton
287
+                        && <AudioRouteButton
288
+                            iconName = { 'volume' }
289
+                            iconStyle = { iconStyle }
290
+                            style = { style }
291
+                            underlayColor = { underlayColor } />
292
+                }
285 293
                 <ToolbarButton
286 294
                     disabled = { audioOnly || videoMuted }
287 295
                     iconName = 'switch-camera'
@@ -290,17 +298,17 @@ class Toolbox extends Component {
290 298
                     style = { style }
291 299
                     underlayColor = { underlayColor } />
292 300
                 <ToolbarButton
293
-                    iconName = {
294
-                        this.props._locked ? 'security-locked' : 'security'
295
-                    }
301
+                    iconName = { audioOnly ? 'visibility-off' : 'visibility' }
296 302
                     iconStyle = { iconStyle }
297
-                    onClick = { this.props._onRoomLock }
303
+                    onClick = { this.props._onToggleAudioOnly }
298 304
                     style = { style }
299 305
                     underlayColor = { underlayColor } />
300 306
                 <ToolbarButton
301
-                    iconName = { audioOnly ? 'visibility-off' : 'visibility' }
307
+                    iconName = {
308
+                        this.props._locked ? 'security-locked' : 'security'
309
+                    }
302 310
                     iconStyle = { iconStyle }
303
-                    onClick = { this.props._onToggleAudioOnly }
311
+                    onClick = { this.props._onRoomLock }
304 312
                     style = { style }
305 313
                     underlayColor = { underlayColor } />
306 314
                 {
@@ -312,14 +320,6 @@ class Toolbox extends Component {
312 320
                             style = { style }
313 321
                             underlayColor = { underlayColor } />
314 322
                 }
315
-                {
316
-                    AudioRouteButton.supported()
317
-                        && <AudioRouteButton
318
-                            iconName = { 'volume' }
319
-                            iconStyle = { iconStyle }
320
-                            style = { style }
321
-                            underlayColor = { underlayColor } />
322
-                }
323 323
             </View>
324 324
         );
325 325
 

Loading…
Откажи
Сачувај