Pārlūkot izejas kodu

[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 gadus atpakaļ
vecāks
revīzija
e7aff1d8e1

+ 1
- 1
react/features/base/dialog/components/Dialog.native.js Parādīt failu

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

+ 1
- 1
react/features/base/dialog/components/SimpleBottomSheet.native.js Parādīt failu

12
 
12
 
13
 import { Icon } from '../../font-icons';
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
  * Underlay color for the buttons on the sheet.
18
  * Underlay color for the buttons on the sheet.

+ 6
- 6
react/features/base/dialog/components/styles.js Parādīt failu

1
 import { ColorPalette, createStyleSheet } from '../../styles';
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
      * The style of the {@code Text} in a {@code Dialog} button.
8
      * The style of the {@code Text} in a {@code Dialog} button.
9
      */
9
      */
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
      * Style for the container of the sheet.
30
      * Style for the container of the sheet.
31
      */
31
      */

+ 40
- 33
react/features/mobile/audio-mode/components/AudioRoutePickerDialog.js Parādīt failu

7
 
7
 
8
 import { hideDialog, SimpleBottomSheet } from '../../../base/dialog';
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
  * Maps each device type to a display name and icon.
32
  * Maps each device type to a display name and icon.
14
- * TODO: internationalization.
33
+ * TODO i18n
15
  */
34
  */
16
 const deviceInfoMap = {
35
 const deviceInfoMap = {
17
     BLUETOOTH: {
36
     BLUETOOTH: {
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
  * audio devices.
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
  * Implements a React {@code Component} which prompts the user when a password
66
  * Implements a React {@code Component} which prompts the user when a password
68
  */
68
  */
69
 class AudioRoutePickerDialog extends Component<Props, State> {
69
 class AudioRoutePickerDialog extends Component<Props, State> {
70
     state = {
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
         devices: []
75
         devices: []
73
     };
76
     };
74
 
77
 
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
      * @inheritdoc
95
      * @inheritdoc
93
      */
96
      */
107
             }
110
             }
108
 
111
 
109
             if (audioDevices) {
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
      * @returns {void}
124
      * @returns {void}
120
      */
125
      */
121
     _hide() {
126
     _hide() {
122
-        this.props.dispatch(hideDialog(DialogType));
127
+        this.props.dispatch(hideDialog(AudioRoutePickerDialog_));
123
     }
128
     }
124
 
129
 
125
     _onCancel: () => void;
130
     _onCancel: () => void;
156
      * @returns {ReactElement}
161
      * @returns {ReactElement}
157
      */
162
      */
158
     render() {
163
     render() {
159
-        if (!this.state.devices.length) {
164
+        const { devices } = this.state;
165
+
166
+        if (!devices.length) {
160
             return null;
167
             return null;
161
         }
168
         }
162
 
169
 
164
             <SimpleBottomSheet
171
             <SimpleBottomSheet
165
                 onCancel = { this._onCancel }
172
                 onCancel = { this._onCancel }
166
                 onSubmit = { this._onSubmit }
173
                 onSubmit = { this._onSubmit }
167
-                options = { this.state.devices } />
174
+                options = { devices } />
168
         );
175
         );
169
     }
176
     }
170
 }
177
 }
172
 // Only export the dialog if we have support for getting / setting audio devices
179
 // Only export the dialog if we have support for getting / setting audio devices
173
 // in AudioMode.
180
 // in AudioMode.
174
 if (AudioMode.getAudioDevices && AudioMode.setAudioDevice) {
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 Parādīt failu

3
 import React, { Component } from 'react';
3
 import React, { Component } from 'react';
4
 import {
4
 import {
5
     findNodeHandle,
5
     findNodeHandle,
6
-    requireNativeComponent,
7
     NativeModules,
6
     NativeModules,
7
+    requireNativeComponent,
8
     View
8
     View
9
 } from 'react-native';
9
 } from 'react-native';
10
 import { connect } from 'react-redux';
10
 import { connect } from 'react-redux';
15
 import ToolbarButton from './ToolbarButton';
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
  * on iOS.
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
  * programmatically.
27
  * programmatically.
30
  */
28
  */
31
 const HIDE_VIEW_STYLE = { display: 'none' };
29
 const HIDE_VIEW_STYLE = { display: 'none' };
33
 type Props = {
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
     dispatch: Function,
37
     dispatch: Function,
39
 
38
 
48
     iconStyle: Object,
47
     iconStyle: Object,
49
 
48
 
50
     /**
49
     /**
51
-     * {@code AudioRouteButton} styles.
50
+     * The style(s) of {@code AudioRouteButton}.
52
      */
51
      */
53
     style: Array<*> | Object,
52
     style: Array<*> | Object,
54
 
53
 
55
     /**
54
     /**
56
-     * The color underlying the button.
55
+     * The color underlaying the button.
57
      */
56
      */
58
     underlayColor: string
57
     underlayColor: string
59
 };
58
 };
64
 class AudioRouteButton extends Component<Props> {
63
 class AudioRouteButton extends Component<Props> {
65
     _volumeComponent: ?Object;
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
      * Initializes a new {@code AudioRouteButton} instance.
67
      * Initializes a new {@code AudioRouteButton} instance.
79
      *
68
      *
108
      */
97
      */
109
     _onClick() {
98
     _onClick() {
110
         if (MPVolumeView) {
99
         if (MPVolumeView) {
111
-            const handle = findNodeHandle(this._volumeComponent);
112
-
113
-            NativeModules.MPVolumeViewManager.show(handle);
100
+            NativeModules.MPVolumeViewManager.show(
101
+                findNodeHandle(this._volumeComponent));
114
         } else if (AudioRoutePickerDialog) {
102
         } else if (AudioRoutePickerDialog) {
115
             this.props.dispatch(openDialog(AudioRoutePickerDialog));
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
      * Implements React's {@link Component#render()}.
108
      * Implements React's {@link Component#render()}.
134
      *
109
      *
155
             </View>
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 Parādīt failu

47
         return React.createElement(TouchableHighlight, props, children);
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
      * @inheritdoc
53
      * @inheritdoc
53
      */
54
      */
54
     _renderIcon() {
55
     _renderIcon() {

+ 14
- 14
react/features/toolbox/components/Toolbox.native.js Parādīt failu

282
             <View
282
             <View
283
                 key = 'secondaryToolbar'
283
                 key = 'secondaryToolbar'
284
                 style = { styles.secondaryToolbar }>
284
                 style = { styles.secondaryToolbar }>
285
+                {
286
+                    AudioRouteButton
287
+                        && <AudioRouteButton
288
+                            iconName = { 'volume' }
289
+                            iconStyle = { iconStyle }
290
+                            style = { style }
291
+                            underlayColor = { underlayColor } />
292
+                }
285
                 <ToolbarButton
293
                 <ToolbarButton
286
                     disabled = { audioOnly || videoMuted }
294
                     disabled = { audioOnly || videoMuted }
287
                     iconName = 'switch-camera'
295
                     iconName = 'switch-camera'
290
                     style = { style }
298
                     style = { style }
291
                     underlayColor = { underlayColor } />
299
                     underlayColor = { underlayColor } />
292
                 <ToolbarButton
300
                 <ToolbarButton
293
-                    iconName = {
294
-                        this.props._locked ? 'security-locked' : 'security'
295
-                    }
301
+                    iconName = { audioOnly ? 'visibility-off' : 'visibility' }
296
                     iconStyle = { iconStyle }
302
                     iconStyle = { iconStyle }
297
-                    onClick = { this.props._onRoomLock }
303
+                    onClick = { this.props._onToggleAudioOnly }
298
                     style = { style }
304
                     style = { style }
299
                     underlayColor = { underlayColor } />
305
                     underlayColor = { underlayColor } />
300
                 <ToolbarButton
306
                 <ToolbarButton
301
-                    iconName = { audioOnly ? 'visibility-off' : 'visibility' }
307
+                    iconName = {
308
+                        this.props._locked ? 'security-locked' : 'security'
309
+                    }
302
                     iconStyle = { iconStyle }
310
                     iconStyle = { iconStyle }
303
-                    onClick = { this.props._onToggleAudioOnly }
311
+                    onClick = { this.props._onRoomLock }
304
                     style = { style }
312
                     style = { style }
305
                     underlayColor = { underlayColor } />
313
                     underlayColor = { underlayColor } />
306
                 {
314
                 {
312
                             style = { style }
320
                             style = { style }
313
                             underlayColor = { underlayColor } />
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
             </View>
323
             </View>
324
         );
324
         );
325
 
325
 

Notiek ielāde…
Atcelt
Saglabāt