Browse Source

feat(transcriptions): add ClosedCaptionButton.native

j8
paweldomas 7 years ago
parent
commit
e2771b53bb

+ 3
- 1
lang/main.json View File

@@ -483,7 +483,9 @@
483 483
         "failedToStart": "Transcribing failed to start",
484 484
         "tr": "TR",
485 485
         "labelToolTip": "The meeting is being transcribed",
486
-        "ccButtonTooltip": "Start / Stop showing subtitles"
486
+        "ccButtonTooltip": "Start / Stop showing subtitles",
487
+        "start": "Start showing subtitles",
488
+        "stop": "Stop showing subtitles"
487 489
     },
488 490
     "liveStreaming":
489 491
     {

+ 88
- 0
react/features/subtitles/components/AbstractClosedCaptionButton.js View File

@@ -0,0 +1,88 @@
1
+// @flow
2
+
3
+import { createToolbarEvent, sendAnalytics } from '../../analytics';
4
+import { AbstractButton, type AbstractButtonProps } from '../../base/toolbox';
5
+
6
+import { toggleRequestingSubtitles } from '../actions';
7
+
8
+export type AbstractProps = AbstractButtonProps & {
9
+
10
+    /**
11
+     * Invoked to obtain translated strings.
12
+     */
13
+    t: Function,
14
+
15
+    /**
16
+     * Invoked to Dispatch an Action to the redux store.
17
+     */
18
+    dispatch: Function,
19
+
20
+    /**
21
+     * Whether the local participant is currently requesting subtitles.
22
+     */
23
+    _requestingSubtitles: Boolean
24
+};
25
+
26
+/**
27
+ * The button component which starts/stops the transcription.
28
+ */
29
+export class AbstractClosedCaptionButton
30
+    extends AbstractButton<AbstractProps, *> {
31
+    /**
32
+     * Handles clicking / pressing the button.
33
+     *
34
+     * @override
35
+     * @protected
36
+     * @returns {void}
37
+     */
38
+    _handleClick() {
39
+        const { _requestingSubtitles, dispatch } = this.props;
40
+
41
+        sendAnalytics(createToolbarEvent('transcribing.ccButton',
42
+            {
43
+                'requesting_subtitles': Boolean(_requestingSubtitles)
44
+            }));
45
+
46
+        dispatch(toggleRequestingSubtitles());
47
+    }
48
+
49
+    /**
50
+     * Indicates whether this button is disabled or not.
51
+     *
52
+     * @override
53
+     * @protected
54
+     * @returns {boolean}
55
+     */
56
+    _isDisabled() {
57
+        return false;
58
+    }
59
+
60
+    /**
61
+     * Indicates whether this button is in toggled state or not.
62
+     *
63
+     * @override
64
+     * @protected
65
+     * @returns {boolean}
66
+     */
67
+    _isToggled() {
68
+        return this.props._requestingSubtitles;
69
+    }
70
+}
71
+
72
+/**
73
+ * Maps (parts of) the redux state to the associated props for the
74
+ * {@code AbstractClosedCaptionButton} component.
75
+ *
76
+ * @param {Object} state - The redux state.
77
+ * @private
78
+ * @returns {{
79
+ *     __requestingSubtitles: boolean
80
+ * }}
81
+ */
82
+export function _abstractMapStateToProps(state: Object) {
83
+    const { _requestingSubtitles } = state['features/subtitles'];
84
+
85
+    return {
86
+        _requestingSubtitles
87
+    };
88
+}

+ 26
- 0
react/features/subtitles/components/ClosedCaptionButton.native.js View File

@@ -0,0 +1,26 @@
1
+// @flow
2
+
3
+import { connect } from 'react-redux';
4
+
5
+import { translate } from '../../base/i18n';
6
+
7
+import {
8
+    AbstractClosedCaptionButton,
9
+    _abstractMapStateToProps
10
+} from './AbstractClosedCaptionButton';
11
+
12
+/**
13
+ * A button which starts/stops the transcriptions.
14
+ */
15
+class ClosedCaptionButton
16
+    extends AbstractClosedCaptionButton {
17
+
18
+    accessibilityLabel = 'toolbar.accessibilityLabel.cc';
19
+    iconName = 'closed_caption';
20
+    label = 'transcribing.start';
21
+    toggledIconName = 'closed_caption';
22
+    toggledLabel = 'transcribing.stop';
23
+}
24
+
25
+export default translate(connect(_abstractMapStateToProps)(
26
+    ClosedCaptionButton));

+ 14
- 104
react/features/subtitles/components/ClosedCaptionButton.web.js View File

@@ -1,115 +1,25 @@
1 1
 // @flow
2 2
 
3
-import React, { Component } from 'react';
4 3
 import { connect } from 'react-redux';
5
-import { translate } from '../../base/i18n/index';
6
-
7
-import { ToolbarButton } from '../../toolbox/';
8
-
9
-import { toggleRequestingSubtitles } from '../actions';
10
-import { createToolbarEvent, sendAnalytics } from '../../analytics';
11
-
12
-
13
-/**
14
- * The type of the React {@code Component} props of {@link TranscribingLabel}.
15
- */
16
-type Props = {
17
-
18
-    /**
19
-     * Invoked to obtain translated strings.
20
-     */
21
-    t: Function,
22
-
23
-    /**
24
-     * Invoked to Dispatch an Action to the redux store.
25
-     */
26
-    dispatch: Function,
27
-
28
-    /**
29
-     * Whether the local participant is currently requesting subtitles.
30
-     */
31
-    _requestingSubtitles: Boolean
32
-};
33
-
34
-/**
35
- * React Component for displaying a label when a transcriber is in the
36
- * conference.
37
- *
38
- * @extends Component
39
- */
40
-class ClosedCaptionButton extends Component<Props> {
41
-
42
-    /**
43
-     * Initializes a new {@code ClosedCaptionButton} instance.
44
-     *
45
-     * @param {Props} props - The read-only properties with which the new
46
-     * instance is to be initialized.
47
-     */
48
-    constructor(props: Props) {
49
-        super(props);
50
-
51
-        // Bind event handler so it is only bound once for every instance.
52
-        this._onToggleButton = this._onToggleButton.bind(this);
53
-    }
54
-
55
-    /**
56
-     * Implements React's {@link Component#render()}.
57
-     *
58
-     * @inheritdoc
59
-     * @returns {ReactElement}
60
-     */
61
-    render() {
62
-        const { _requestingSubtitles, t } = this.props;
63
-        const iconClass = `icon-closed_caption ${_requestingSubtitles
64
-            ? 'toggled' : ''}`;
65
-
66
-        return (
67
-            <ToolbarButton
68
-                accessibilityLabel
69
-                    = { t('toolbar.accessibilityLabel.cc') }
70
-                iconName = { iconClass }
71
-                onClick = { this._onToggleButton }
72
-                tooltip = { t('transcribing.ccButtonTooltip') } />
73
-        );
74
-    }
75 4
 
76
-    _onToggleButton: () => void;
77
-
78
-    /**
79
-     * Dispatch actions for starting or stopping transcription, based on
80
-     * current state.
81
-     *
82
-     * @private
83
-     * @returns {void}
84
-     */
85
-    _onToggleButton() {
86
-        const { _requestingSubtitles, dispatch } = this.props;
87
-
88
-        sendAnalytics(createToolbarEvent('transcribing.ccButton',
89
-            {
90
-                'requesting_subtitles': Boolean(_requestingSubtitles)
91
-            }));
92
-
93
-        dispatch(toggleRequestingSubtitles());
94
-    }
5
+import { translate } from '../../base/i18n/index';
95 6
 
96
-}
7
+import {
8
+    AbstractClosedCaptionButton,
9
+    _abstractMapStateToProps
10
+} from './AbstractClosedCaptionButton';
97 11
 
98 12
 /**
99
- * Maps (parts of) the Redux state to the associated props for the
100
- * {@code ClosedCaptionButton} component.
101
- *
102
- * @param {Object} state - The Redux state.
103
- * @private
104
- * @returns {{
105
- * }}
13
+ * A button which starts/stops the transcriptions.
106 14
  */
107
-function _mapStateToProps(state) {
108
-    const { _requestingSubtitles } = state['features/subtitles'];
15
+class ClosedCaptionButton
16
+    extends AbstractClosedCaptionButton {
109 17
 
110
-    return {
111
-        _requestingSubtitles
112
-    };
18
+    accessibilityLabel = 'toolbar.accessibilityLabel.cc';
19
+    iconName = 'icon-closed_caption';
20
+    toggledIconName = 'icon-closed_caption toggled';
21
+    tooltip = 'transcribing.ccButtonTooltip';
113 22
 }
114 23
 
115
-export default translate(connect(_mapStateToProps)(ClosedCaptionButton));
24
+export default translate(connect(_abstractMapStateToProps)(
25
+    ClosedCaptionButton));

+ 2
- 0
react/features/toolbox/components/native/OverflowMenu.js View File

@@ -8,6 +8,7 @@ import { AudioRouteButton } from '../../../mobile/audio-mode';
8 8
 import { PictureInPictureButton } from '../../../mobile/picture-in-picture';
9 9
 import { LiveStreamButton, RecordButton } from '../../../recording';
10 10
 import { RoomLockButton } from '../../../room-lock';
11
+import { ClosedCaptionButton } from '../../../subtitles';
11 12
 
12 13
 import AudioOnlyButton from './AudioOnlyButton';
13 14
 import { overflowMenuItemStyles } from './styles';
@@ -69,6 +70,7 @@ class OverflowMenu extends Component<Props> {
69 70
                 <ToggleCameraButton { ...buttonProps } />
70 71
                 <AudioOnlyButton { ...buttonProps } />
71 72
                 <RoomLockButton { ...buttonProps } />
73
+                <ClosedCaptionButton { ...buttonProps } />
72 74
                 <RecordButton { ...buttonProps } />
73 75
                 <LiveStreamButton { ...buttonProps } />
74 76
                 <PictureInPictureButton { ...buttonProps } />

Loading…
Cancel
Save