You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LonelyMeetingExperience.js 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. // @flow
  2. import React, { PureComponent } from 'react';
  3. import { Text, TouchableOpacity, View } from 'react-native';
  4. import { ColorSchemeRegistry } from '../../../base/color-scheme';
  5. import { connect } from '../../../base/redux';
  6. import { StyleType } from '../../../base/styles';
  7. import { translate } from '../../../base/i18n';
  8. import { getParticipantCount } from '../../../base/participants';
  9. import { doInvitePeople } from '../../../invite/actions.native';
  10. import styles from './styles';
  11. import { Icon, IconAddPeople } from '../../../base/icons';
  12. /**
  13. * Props type of the component.
  14. */
  15. type Props = {
  16. /**
  17. * True if the invite functions (dial out, invite, share...etc) are disabled.
  18. */
  19. _isInviteFunctionsDiabled: boolean,
  20. /**
  21. * True if it's a lonely meeting (participant count excluding fakes is 1).
  22. */
  23. _isLonelyMeeting: boolean,
  24. /**
  25. * Color schemed styles of the component.
  26. */
  27. _styles: StyleType,
  28. /**
  29. * The Redux Dispatch function.
  30. */
  31. dispatch: Function,
  32. /**
  33. * Function to be used to translate i18n labels.
  34. */
  35. t: Function
  36. };
  37. /**
  38. * Implements the UI elements to be displayed in the lonely meeting experience.
  39. */
  40. class LonelyMeetingExperience extends PureComponent<Props> {
  41. /**
  42. * Instantiates a new component.
  43. *
  44. * @inheritdoc
  45. */
  46. constructor(props: Props) {
  47. super(props);
  48. this._onPress = this._onPress.bind(this);
  49. }
  50. /**
  51. * Implements {@code PureComponent#render}.
  52. *
  53. * @inheritdoc
  54. */
  55. render() {
  56. const { _isInviteFunctionsDiabled, _isLonelyMeeting, _styles, t } = this.props;
  57. if (!_isLonelyMeeting) {
  58. return null;
  59. }
  60. return (
  61. <View style = { styles.lonelyMeetingContainer }>
  62. <Text
  63. style = { [
  64. styles.lonelyMessage,
  65. _styles.lonelyMessage
  66. ] }>
  67. { t('lonelyMeetingExperience.youAreAlone') }
  68. </Text>
  69. { !_isInviteFunctionsDiabled && (
  70. <TouchableOpacity
  71. onPress = { this._onPress }
  72. style = { [
  73. styles.lonelyButton,
  74. _styles.lonelyButton
  75. ] }>
  76. <Icon
  77. size = { 24 }
  78. src = { IconAddPeople }
  79. style = { styles.lonelyButtonComponents } />
  80. <Text
  81. style = { [
  82. styles.lonelyButtonComponents,
  83. _styles.lonelyMessage
  84. ] }>
  85. { t('lonelyMeetingExperience.button') }
  86. </Text>
  87. </TouchableOpacity>
  88. ) }
  89. </View>
  90. );
  91. }
  92. _onPress: () => void;
  93. /**
  94. * Callback for the onPress function of the button.
  95. *
  96. * @returns {void}
  97. */
  98. _onPress() {
  99. this.props.dispatch(doInvitePeople());
  100. }
  101. }
  102. /**
  103. * Maps parts of the Redux state to the props of this Component.
  104. *
  105. * @param {Object} state - The redux state.
  106. * @private
  107. * @returns {Props}
  108. */
  109. function _mapStateToProps(state): $Shape<Props> {
  110. const { disableInviteFunctions } = state['features/base/config'];
  111. return {
  112. _isInviteFunctionsDiabled: disableInviteFunctions,
  113. _isLonelyMeeting: getParticipantCount(state) === 1,
  114. _styles: ColorSchemeRegistry.get(state, 'Conference')
  115. };
  116. }
  117. export default connect(_mapStateToProps)(translate(LonelyMeetingExperience));