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.

ReactionMenuDialog.js 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. // @flow
  2. import React, { PureComponent } from 'react';
  3. import { SafeAreaView, TouchableWithoutFeedback, View } from 'react-native';
  4. import { ColorSchemeRegistry } from '../../../base/color-scheme';
  5. import { hideDialog, isDialogOpen } from '../../../base/dialog';
  6. import { getParticipantCount } from '../../../base/participants';
  7. import { connect } from '../../../base/redux';
  8. import type { StyleType } from '../../../base/styles';
  9. import ReactionMenu from './ReactionMenu';
  10. /**
  11. * The type of the React {@code Component} props of {@link ReactionMenuDialog}.
  12. */
  13. type Props = {
  14. /**
  15. * The color-schemed stylesheet of the feature.
  16. */
  17. _styles: StyleType,
  18. /**
  19. * True if the dialog is currently visible, false otherwise.
  20. */
  21. _isOpen: boolean,
  22. /**
  23. * The width of the screen.
  24. */
  25. _width: number,
  26. /**
  27. * The height of the screen.
  28. */
  29. _height: number,
  30. /**
  31. * Number of conference participants.
  32. */
  33. _participantCount: number,
  34. /**
  35. * Used for hiding the dialog when the selection was completed.
  36. */
  37. dispatch: Function
  38. };
  39. /**
  40. * The exported React {@code Component}. We need it to execute
  41. * {@link hideDialog}.
  42. *
  43. * XXX It does not break our coding style rule to not utilize globals for state,
  44. * because it is merely another name for {@code export}'s {@code default}.
  45. */
  46. let ReactionMenu_; // eslint-disable-line prefer-const
  47. /**
  48. * Implements a React {@code Component} with some extra actions in addition to
  49. * those in the toolbar.
  50. */
  51. class ReactionMenuDialog extends PureComponent<Props> {
  52. /**
  53. * Initializes a new {@code ReactionMenuDialog} instance.
  54. *
  55. * @inheritdoc
  56. */
  57. constructor(props: Props) {
  58. super(props);
  59. // Bind event handlers so they are only bound once per instance.
  60. this._onCancel = this._onCancel.bind(this);
  61. }
  62. /**
  63. * Implements React's {@link Component#render()}.
  64. *
  65. * @inheritdoc
  66. * @returns {ReactElement}
  67. */
  68. render() {
  69. const { _styles, _width, _height, _participantCount } = this.props;
  70. return (
  71. <SafeAreaView style = { _styles }>
  72. <TouchableWithoutFeedback
  73. onPress = { this._onCancel }>
  74. <View style = { _styles }>
  75. <View
  76. style = {{
  77. left: (_width - 360) / 2,
  78. top: _height - (_participantCount > 1 ? 144 : 80) - 80
  79. }}>
  80. <ReactionMenu
  81. onCancel = { this._onCancel }
  82. overflowMenu = { false } />
  83. </View>
  84. </View>
  85. </TouchableWithoutFeedback>
  86. </SafeAreaView>
  87. );
  88. }
  89. _onCancel: () => boolean;
  90. /**
  91. * Hides this {@code ReactionMenuDialog}.
  92. *
  93. * @private
  94. * @returns {boolean}
  95. */
  96. _onCancel() {
  97. if (this.props._isOpen) {
  98. this.props.dispatch(hideDialog(ReactionMenu_));
  99. return true;
  100. }
  101. return false;
  102. }
  103. }
  104. /**
  105. * Function that maps parts of Redux state tree into component props.
  106. *
  107. * @param {Object} state - Redux state.
  108. * @private
  109. * @returns {Props}
  110. */
  111. function _mapStateToProps(state) {
  112. return {
  113. _isOpen: isDialogOpen(state, ReactionMenu_),
  114. _styles: ColorSchemeRegistry.get(state, 'Toolbox').reactionDialog,
  115. _width: state['features/base/responsive-ui'].clientWidth,
  116. _height: state['features/base/responsive-ui'].clientHeight,
  117. _participantCount: getParticipantCount(state)
  118. };
  119. }
  120. ReactionMenu_ = connect(_mapStateToProps)(ReactionMenuDialog);
  121. export default ReactionMenu_;