浏览代码

[RN] Add button to toggle raised hand

j8
Bettenbuk Zoltan 6 年前
父节点
当前提交
2dc59b9ea0

+ 2
- 0
react/features/toolbox/components/native/OverflowMenu.js 查看文件

@@ -18,6 +18,7 @@ import { ClosedCaptionButton } from '../../../subtitles';
18 18
 import { TileViewButton } from '../../../video-layout';
19 19
 
20 20
 import AudioOnlyButton from './AudioOnlyButton';
21
+import RaiseHandButton from './RaiseHandButton';
21 22
 import ToggleCameraButton from './ToggleCameraButton';
22 23
 
23 24
 declare var __DEV__;
@@ -95,6 +96,7 @@ class OverflowMenu extends Component<Props> {
95 96
                 <LiveStreamButton { ...buttonProps } />
96 97
                 <TileViewButton { ...buttonProps } />
97 98
                 <InviteButton { ...buttonProps } />
99
+                <RaiseHandButton { ...buttonProps } />
98 100
             </BottomSheet>
99 101
         );
100 102
     }

+ 113
- 0
react/features/toolbox/components/native/RaiseHandButton.js 查看文件

@@ -0,0 +1,113 @@
1
+// @flow
2
+
3
+import { type Dispatch } from 'redux';
4
+
5
+import {
6
+    createToolbarEvent,
7
+    sendAnalytics
8
+} from '../../../analytics';
9
+import { translate } from '../../../base/i18n';
10
+import {
11
+    getLocalParticipant,
12
+    participantUpdated
13
+} from '../../../base/participants';
14
+import { connect } from '../../../base/redux';
15
+import { AbstractButton } from '../../../base/toolbox';
16
+import type { AbstractButtonProps } from '../../../base/toolbox';
17
+
18
+/**
19
+ * The type of the React {@code Component} props of {@link RaiseHandButton}.
20
+ */
21
+type Props = AbstractButtonProps & {
22
+
23
+    /**
24
+     * The local participant.
25
+     */
26
+    _localParticipant: Object,
27
+
28
+    /**
29
+     * Whether the participant raused their hand or not.
30
+     */
31
+    _raisedHand: boolean,
32
+
33
+    /**
34
+     * The redux {@code dispatch} function.
35
+     */
36
+    dispatch: Dispatch<any>
37
+};
38
+
39
+/**
40
+ * An implementation of a button to raise or lower hand.
41
+ */
42
+class RaiseHandButton extends AbstractButton<Props, *> {
43
+    accessibilityLabel = 'toolbar.accessibilityLabel.raiseHand';
44
+    iconName = 'raised-hand';
45
+    label = 'toolbar.raiseYourHand';
46
+    toggledIconName = 'raised-hand';
47
+    toggledLabel = 'toolbar.lowerYourHand';
48
+
49
+    /**
50
+     * Handles clicking / pressing the button.
51
+     *
52
+     * @override
53
+     * @protected
54
+     * @returns {void}
55
+     */
56
+    _handleClick() {
57
+        this._toggleRaisedHand();
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._raisedHand;
69
+    }
70
+
71
+    /**
72
+     * Toggles the rased hand status of the local participant.
73
+     *
74
+     * @returns {void}
75
+     */
76
+    _toggleRaisedHand() {
77
+        const enable = !this.props._raisedHand;
78
+
79
+        sendAnalytics(createToolbarEvent('raise.hand', { enable }));
80
+
81
+        this.props.dispatch(participantUpdated({
82
+            // XXX Only the local participant is allowed to update without
83
+            // stating the JitsiConference instance (i.e. participant property
84
+            // `conference` for a remote participant) because the local
85
+            // participant is uniquely identified by the very fact that there is
86
+            // only one local participant.
87
+
88
+            id: this.props._localParticipant.id,
89
+            local: true,
90
+            raisedHand: enable
91
+        }));
92
+    }
93
+}
94
+
95
+/**
96
+ * Maps part of the Redux state to the props of this component.
97
+ *
98
+ * @param {Object} state - The Redux state.
99
+ * @private
100
+ * @returns {{
101
+ *     _raisedHand: boolean
102
+ * }}
103
+ */
104
+function _mapStateToProps(state): Object {
105
+    const _localParticipant = getLocalParticipant(state);
106
+
107
+    return {
108
+        _localParticipant,
109
+        _raisedHand: _localParticipant.raisedHand
110
+    };
111
+}
112
+
113
+export default translate(connect(_mapStateToProps)(RaiseHandButton));

正在加载...
取消
保存