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.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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 it's a lonely meeting (participant count excluding fakes is 1).
  18. */
  19. _isLonelyMeeting: boolean,
  20. /**
  21. * Color schemed styles of the component.
  22. */
  23. _styles: StyleType,
  24. /**
  25. * The Redux Dispatch function.
  26. */
  27. dispatch: Function,
  28. /**
  29. * Function to be used to translate i18n labels.
  30. */
  31. t: Function
  32. };
  33. /**
  34. * Implements the UI elements to be displayed in the lonely meeting experience.
  35. */
  36. class LonelyMeetingExperience extends PureComponent<Props> {
  37. /**
  38. * Instantiates a new component.
  39. *
  40. * @inheritdoc
  41. */
  42. constructor(props: Props) {
  43. super(props);
  44. this._onPress = this._onPress.bind(this);
  45. }
  46. /**
  47. * Implements {@code PureComponent#render}.
  48. *
  49. * @inheritdoc
  50. */
  51. render() {
  52. const { _isLonelyMeeting, _styles, t } = this.props;
  53. if (!_isLonelyMeeting) {
  54. return null;
  55. }
  56. return (
  57. <View style = { styles.lonelyMeetingContainer }>
  58. <Text
  59. style = { [
  60. styles.lonelyMessage,
  61. _styles.lonelyMessage
  62. ] }>
  63. { t('lonelyMeetingExperience.youAreAlone') }
  64. </Text>
  65. <TouchableOpacity
  66. onPress = { this._onPress }
  67. style = { [
  68. styles.lonelyButton,
  69. _styles.lonelyButton
  70. ] }>
  71. <Icon
  72. size = { 24 }
  73. src = { IconAddPeople }
  74. style = { styles.lonelyButtonComponents } />
  75. <Text
  76. style = { [
  77. styles.lonelyButtonComponents,
  78. _styles.lonelyMessage
  79. ] }>
  80. { t('lonelyMeetingExperience.button') }
  81. </Text>
  82. </TouchableOpacity>
  83. </View>
  84. );
  85. }
  86. _onPress: () => void;
  87. /**
  88. * Callback for the onPress function of the button.
  89. *
  90. * @returns {void}
  91. */
  92. _onPress() {
  93. this.props.dispatch(doInvitePeople());
  94. }
  95. }
  96. /**
  97. * Maps parts of the Redux state to the props of this Component.
  98. *
  99. * @param {Object} state - The redux state.
  100. * @private
  101. * @returns {Props}
  102. */
  103. function _mapStateToProps(state): $Shape<Props> {
  104. return {
  105. _isLonelyMeeting: getParticipantCount(state) === 1,
  106. _styles: ColorSchemeRegistry.get(state, 'Conference')
  107. };
  108. }
  109. export default connect(_mapStateToProps)(translate(LonelyMeetingExperience));