|
@@ -0,0 +1,75 @@
|
|
1
|
+// @flow
|
|
2
|
+
|
|
3
|
+import { translate } from '../../../base/i18n';
|
|
4
|
+import { IconCameraRefresh } from '../../../base/icons';
|
|
5
|
+import { connect } from '../../../base/redux';
|
|
6
|
+import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
|
|
7
|
+import { isLocalCameraTrackMuted, isToggleCameraEnabled, toggleCamera } from '../../../base/tracks';
|
|
8
|
+
|
|
9
|
+/**
|
|
10
|
+ * The type of the React {@code Component} props of {@link ToggleCameraButton}.
|
|
11
|
+ */
|
|
12
|
+type Props = AbstractButtonProps & {
|
|
13
|
+
|
|
14
|
+ /**
|
|
15
|
+ * Whether the current conference is in audio only mode or not.
|
|
16
|
+ */
|
|
17
|
+ _audioOnly: boolean,
|
|
18
|
+
|
|
19
|
+ /**
|
|
20
|
+ * Whether video is currently muted or not.
|
|
21
|
+ */
|
|
22
|
+ _videoMuted: boolean,
|
|
23
|
+
|
|
24
|
+ /**
|
|
25
|
+ * The Redux dispatch function.
|
|
26
|
+ */
|
|
27
|
+ dispatch: Function
|
|
28
|
+};
|
|
29
|
+
|
|
30
|
+/**
|
|
31
|
+ * An implementation of a button for toggling the camera facing mode.
|
|
32
|
+ */
|
|
33
|
+class ToggleCameraButton extends AbstractButton<Props, any> {
|
|
34
|
+ accessibilityLabel = 'toolbar.accessibilityLabel.toggleCamera';
|
|
35
|
+ icon = IconCameraRefresh;
|
|
36
|
+ label = 'toolbar.toggleCamera';
|
|
37
|
+
|
|
38
|
+ /**
|
|
39
|
+ * Handles clicking/pressing the button.
|
|
40
|
+ *
|
|
41
|
+ * @returns {void}
|
|
42
|
+ */
|
|
43
|
+ _handleClick() {
|
|
44
|
+ this.props.dispatch(toggleCamera());
|
|
45
|
+ }
|
|
46
|
+
|
|
47
|
+ /**
|
|
48
|
+ * Whether this button is disabled or not.
|
|
49
|
+ *
|
|
50
|
+ * @returns {boolean}
|
|
51
|
+ */
|
|
52
|
+ _isDisabled() {
|
|
53
|
+ return this.props._audioOnly || this.props._videoMuted;
|
|
54
|
+ }
|
|
55
|
+}
|
|
56
|
+
|
|
57
|
+/**
|
|
58
|
+ * Maps (parts of) the redux state to the associated props for the
|
|
59
|
+ * {@code ToggleCameraButton} component.
|
|
60
|
+ *
|
|
61
|
+ * @param {Object} state - The Redux state.
|
|
62
|
+ * @returns {Props}
|
|
63
|
+ */
|
|
64
|
+function mapStateToProps(state): Object {
|
|
65
|
+ const { enabled: audioOnly } = state['features/base/audio-only'];
|
|
66
|
+ const tracks = state['features/base/tracks'];
|
|
67
|
+
|
|
68
|
+ return {
|
|
69
|
+ _audioOnly: Boolean(audioOnly),
|
|
70
|
+ _videoMuted: isLocalCameraTrackMuted(tracks),
|
|
71
|
+ visible: isToggleCameraEnabled(state)
|
|
72
|
+ };
|
|
73
|
+}
|
|
74
|
+
|
|
75
|
+export default translate(connect(mapStateToProps)(ToggleCameraButton));
|