Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

ReactionMenuDialog.tsx 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. import React, { ComponentType, PureComponent } from 'react';
  2. import { SafeAreaView, TouchableWithoutFeedback, View } from 'react-native';
  3. import { connect } from 'react-redux';
  4. import { IReduxState, IStore } from '../../../app/types';
  5. import ColorSchemeRegistry from '../../../base/color-scheme/ColorSchemeRegistry';
  6. import { hideDialog } from '../../../base/dialog/actions';
  7. import { isDialogOpen } from '../../../base/dialog/functions';
  8. import { getParticipantCount } from '../../../base/participants/functions';
  9. import { StyleType } from '../../../base/styles/functions.native';
  10. import ReactionMenu from './ReactionMenu';
  11. /**
  12. * The type of the React {@code Component} props of {@link ReactionMenuDialog}.
  13. */
  14. interface IProps {
  15. /**
  16. * The height of the screen.
  17. */
  18. _height: number;
  19. /**
  20. * True if the dialog is currently visible, false otherwise.
  21. */
  22. _isOpen: boolean;
  23. /**
  24. * Number of conference participants.
  25. */
  26. _participantCount: number;
  27. /**
  28. * The color-schemed stylesheet of the feature.
  29. */
  30. _styles: StyleType;
  31. /**
  32. * The width of the screen.
  33. */
  34. _width: number;
  35. /**
  36. * Used for hiding the dialog when the selection was completed.
  37. */
  38. dispatch: IStore['dispatch'];
  39. }
  40. /**
  41. * The exported React {@code Component}. We need it to execute
  42. * {@link hideDialog}.
  43. *
  44. * XXX It does not break our coding style rule to not utilize globals for state,
  45. * because it is merely another name for {@code export}'s {@code default}.
  46. */
  47. let ReactionMenu_: ComponentType<any>; // eslint-disable-line prefer-const
  48. /**
  49. * Implements a React {@code Component} with some extra actions in addition to
  50. * those in the toolbar.
  51. */
  52. class ReactionMenuDialog extends PureComponent<IProps> {
  53. /**
  54. * Initializes a new {@code ReactionMenuDialog} instance.
  55. *
  56. * @inheritdoc
  57. */
  58. constructor(props: IProps) {
  59. super(props);
  60. // Bind event handlers so they are only bound once per instance.
  61. this._onCancel = this._onCancel.bind(this);
  62. }
  63. /**
  64. * Implements React's {@link Component#render()}.
  65. *
  66. * @inheritdoc
  67. * @returns {ReactElement}
  68. */
  69. render() {
  70. const { _styles, _width, _height, _participantCount } = this.props;
  71. return (
  72. <SafeAreaView style = { _styles }>
  73. <TouchableWithoutFeedback
  74. onPress = { this._onCancel }>
  75. <View style = { _styles }>
  76. <View
  77. style = {{
  78. left: (_width - 360) / 2,
  79. top: _height - (_participantCount > 1 ? 144 : 80) - 80
  80. }}>
  81. <ReactionMenu
  82. onCancel = { this._onCancel }
  83. overflowMenu = { false } />
  84. </View>
  85. </View>
  86. </TouchableWithoutFeedback>
  87. </SafeAreaView>
  88. );
  89. }
  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 {IProps}
  110. */
  111. function _mapStateToProps(state: IReduxState) {
  112. return {
  113. _isOpen: isDialogOpen(state, ReactionMenu_), // @ts-ignore
  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_;