|
|
@@ -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);
|