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.

ContextMenuLobbyParticipantReject.js 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // @flow
  2. import React, { useCallback } from 'react';
  3. import { useTranslation } from 'react-i18next';
  4. import { TouchableOpacity, View } from 'react-native';
  5. import { Divider, 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. return (
  31. <BottomSheet
  32. addScrollViewPadding = { false }
  33. onCancel = { cancel }
  34. showSlidingView = { Boolean(knockParticipantIsAvailable) }
  35. style = { styles.contextMenuMore }>
  36. <View
  37. style = { styles.contextMenuItemSectionAvatar }>
  38. <Avatar
  39. className = 'participant-avatar'
  40. participantId = { p.id }
  41. size = { 20 } />
  42. <View style = { styles.contextMenuItemAvatarText }>
  43. <Text style = { styles.contextMenuItemName }>
  44. { displayName }
  45. </Text>
  46. </View>
  47. </View>
  48. <Divider style = { styles.divider } />
  49. <TouchableOpacity
  50. onPress = { reject }
  51. style = { styles.contextMenuItem }>
  52. <Icon
  53. size = { 20 }
  54. src = { IconClose } />
  55. <Text style = { styles.contextMenuItemText }>{ t('lobby.reject') }</Text>
  56. </TouchableOpacity>
  57. </BottomSheet>
  58. );
  59. };
  60. export default ContextMenuLobbyParticipantReject;