Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

DisplayNameLabel.tsx 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import * as React from 'react';
  2. import { Text, View } from 'react-native';
  3. import { IReduxState } from '../../../app/types';
  4. import {
  5. getParticipantById,
  6. getParticipantDisplayName,
  7. isScreenShareParticipant
  8. } from '../../../base/participants/functions';
  9. import { connect } from '../../../base/redux/functions';
  10. // @ts-ignore
  11. import styles from './styles';
  12. interface IProps {
  13. /**
  14. * The name of the participant to render.
  15. */
  16. _participantName: string;
  17. /**
  18. * True of the label needs to be rendered. False otherwise.
  19. */
  20. _render: boolean;
  21. /**
  22. * Whether or not the name is in a container.
  23. */
  24. contained?: boolean;
  25. /**
  26. * The ID of the participant to render the label for.
  27. */
  28. participantId: string;
  29. }
  30. /**
  31. * Renders a label with the display name of the on-stage participant.
  32. */
  33. class DisplayNameLabel extends React.Component<IProps> {
  34. /**
  35. * Implements {@code Component#render}.
  36. *
  37. * @inheritdoc
  38. */
  39. render() {
  40. if (!this.props._render) {
  41. return null;
  42. }
  43. return (
  44. <View style = { this.props.contained ? styles.displayNamePadding : styles.displayNameBackdrop }>
  45. <Text
  46. numberOfLines = { 1 }
  47. style = { styles.displayNameText }>
  48. { this.props._participantName }
  49. </Text>
  50. </View>
  51. );
  52. }
  53. }
  54. /**
  55. * Maps part of the Redux state to the props of this component.
  56. *
  57. * @param {any} state - The Redux state.
  58. * @param {IProps} ownProps - The own props of the component.
  59. * @returns {IProps}
  60. */
  61. function _mapStateToProps(state: IReduxState, ownProps: Partial<IProps>) {
  62. const participant = getParticipantById(state, ownProps.participantId ?? '');
  63. return {
  64. _participantName: getParticipantDisplayName(state, ownProps.participantId ?? ''),
  65. _render: participant && (!participant?.local || ownProps.contained)
  66. && (!participant?.fakeParticipant || isScreenShareParticipant(participant))
  67. };
  68. }
  69. export default connect(_mapStateToProps)(DisplayNameLabel);