您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ContextMenuLobbyParticipantReject.js 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // @flow
  2. import React, { useCallback } from 'react';
  3. import { useTranslation } from 'react-i18next';
  4. import { TouchableOpacity, View } from 'react-native';
  5. import { Text } from 'react-native-paper';
  6. import { useDispatch, useSelector } from 'react-redux';
  7. import { Avatar } from '../../../base/avatar';
  8. import { hideDialog } from '../../../base/dialog';
  9. import BottomSheet from '../../../base/dialog/components/native/BottomSheet';
  10. import {
  11. Icon, IconClose
  12. } from '../../../base/icons';
  13. import { setKnockingParticipantApproval } from '../../../lobby/actions.native';
  14. import { getKnockingParticipantsById } from '../../../lobby/functions';
  15. import styles from './styles';
  16. type Props = {
  17. /**
  18. * Participant reference
  19. */
  20. participant: Object
  21. };
  22. const ContextMenuLobbyParticipantReject = ({ participant: p }: Props) => {
  23. const dispatch = useDispatch();
  24. const knockParticipantsIDArr = useSelector(getKnockingParticipantsById);
  25. const knockParticipantIsAvailable = knockParticipantsIDArr.find(knockPartId => knockPartId === p.id);
  26. const cancel = useCallback(() => dispatch(hideDialog()), [ dispatch ]);
  27. const displayName = p.name;
  28. const reject = useCallback(() => dispatch(setKnockingParticipantApproval(p.id, false), [ dispatch ]));
  29. const { t } = useTranslation();
  30. // eslint-disable-next-line react/no-multi-comp
  31. const renderMenuHeader = () => (
  32. <View
  33. style = { styles.contextMenuItemSectionAvatar }>
  34. <Avatar
  35. className = 'participant-avatar'
  36. participantId = { p.id }
  37. size = { 24 } />
  38. <Text style = { styles.contextMenuItemName }>
  39. { displayName }
  40. </Text>
  41. </View>
  42. );
  43. return (
  44. <BottomSheet
  45. addScrollViewPadding = { false }
  46. onCancel = { cancel }
  47. /* eslint-disable-next-line react/jsx-no-bind */
  48. renderHeader = { renderMenuHeader }
  49. showSlidingView = { Boolean(knockParticipantIsAvailable) }
  50. style = { styles.contextMenuMore }>
  51. <TouchableOpacity
  52. onPress = { reject }
  53. style = { styles.contextMenuItem }>
  54. <Icon
  55. size = { 24 }
  56. src = { IconClose } />
  57. <Text style = { styles.contextMenuItemText }>{ t('lobby.reject') }</Text>
  58. </TouchableOpacity>
  59. </BottomSheet>
  60. );
  61. };
  62. export default ContextMenuLobbyParticipantReject;