瀏覽代碼

[RN] Add display name to on-stage participant

master
Bettenbuk Zoltan 6 年之前
父節點
當前提交
63ff0c27a9

+ 3
- 0
react/features/conference/components/Conference.native.js 查看文件

@@ -27,6 +27,7 @@ import { Captions } from '../../subtitles';
27 27
 import { setToolboxVisible, Toolbox } from '../../toolbox';
28 28
 import { shouldDisplayTileView } from '../../video-layout';
29 29
 
30
+import DisplayNameLabel from './DisplayNameLabel';
30 31
 import styles from './styles';
31 32
 
32 33
 /**
@@ -283,6 +284,8 @@ class Conference extends Component<Props> {
283 284
 
284 285
                     <Captions onPress = { this._onClick } />
285 286
 
287
+                    <DisplayNameLabel />
288
+
286 289
                     {/*
287 290
                       * The Toolbox is in a stacking layer bellow the Filmstrip.
288 291
                       */}

+ 79
- 0
react/features/conference/components/DisplayNameLabel.native.js 查看文件

@@ -0,0 +1,79 @@
1
+// @flow
2
+
3
+import React, { Component } from 'react';
4
+import { Text, View } from 'react-native';
5
+import { connect } from 'react-redux';
6
+
7
+import {
8
+    getLocalParticipant,
9
+    getParticipantDisplayName,
10
+    shouldRenderParticipantVideo
11
+} from '../../base/participants';
12
+
13
+import { shouldDisplayTileView } from '../../video-layout';
14
+
15
+import styles from './styles';
16
+
17
+type Props = {
18
+
19
+    /**
20
+     * The name of the participant to render.
21
+     */
22
+    _participantName: string,
23
+
24
+    /**
25
+     * True of the label needs to be rendered. False otherwise.
26
+     */
27
+    _render: boolean
28
+}
29
+
30
+/**
31
+ * Renders a label with the display name of the on-stage participant.
32
+ */
33
+class DisplayNameLabel extends Component<Props> {
34
+    /**
35
+     * Implements {@code Component#render}.
36
+     *
37
+     * @inheritdoc
38
+     */
39
+    render() {
40
+        if (!this.props._render) {
41
+            return null;
42
+        }
43
+
44
+        return (
45
+            <View style = { styles.displayNameBackdrop }>
46
+                <Text style = { styles.displayNameText }>
47
+                    { this.props._participantName }
48
+                </Text>
49
+            </View>
50
+        );
51
+    }
52
+}
53
+
54
+/**
55
+ * Maps part of the Redux state to the props of this component.
56
+ *
57
+ * @param {Object} state - The Redux state.
58
+ * @returns {{
59
+ * }}
60
+ */
61
+function _mapStateToProps(state: Object) {
62
+    const largeVideoParticipantId = state['features/large-video'].participantId;
63
+    const localParticipant = getLocalParticipant(state);
64
+
65
+    // Currently we only render the display name if it's not the local
66
+    // participant, we're not in tile view and there is no video rendered for
67
+    // the on-stage participant.
68
+    const _render = localParticipant.id !== largeVideoParticipantId
69
+        && !shouldDisplayTileView(state)
70
+        && !shouldRenderParticipantVideo(state, largeVideoParticipantId);
71
+
72
+    return {
73
+        _participantName:
74
+            getParticipantDisplayName(state, largeVideoParticipantId),
75
+        _render
76
+    };
77
+}
78
+
79
+export default connect(_mapStateToProps)(DisplayNameLabel);

+ 0
- 0
react/features/conference/components/DisplayNameLabel.web.js 查看文件


+ 14
- 0
react/features/conference/components/styles.js 查看文件

@@ -18,6 +18,20 @@ export default createStyleSheet({
18 18
         flex: 1
19 19
     }),
20 20
 
21
+    displayNameBackdrop: {
22
+        alignSelf: 'center',
23
+        backgroundColor: 'rgba(28, 32, 37, 0.6)',
24
+        borderRadius: 4,
25
+        margin: 16,
26
+        paddingHorizontal: 16,
27
+        paddingVertical: 4
28
+    },
29
+
30
+    displayNameText: {
31
+        color: ColorPalette.white,
32
+        fontSize: 14
33
+    },
34
+
21 35
     /**
22 36
      * The style of the {@link View} which expands over the whole
23 37
      * {@link Conference} area and splits it between the {@link Filmstrip} and

Loading…
取消
儲存