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

GifsMenu.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { GiphyContent, GiphyGridView, GiphyMediaType } from '@giphy/react-native-sdk';
  2. import React, { useCallback, useState } from 'react';
  3. import { useTranslation } from 'react-i18next';
  4. import { useDispatch } from 'react-redux';
  5. import { createGifSentEvent, sendAnalytics } from '../../../analytics';
  6. import JitsiScreen from '../../../base/modal/components/JitsiScreen';
  7. import { sendMessage } from '../../../chat/actions.any';
  8. import { goBack } from '../../../mobile/navigation/components/conference/ConferenceNavigationContainerRef';
  9. import ClearableInput from '../../../participants-pane/components/native/ClearableInput';
  10. import { formatGifUrlMessage, getGifUrl } from '../../functions';
  11. import GifsMenuFooter from './GifsMenuFooter';
  12. import styles from './styles';
  13. const GifsMenu = () => {
  14. const [ searchQuery, setSearchQuery ] = useState('');
  15. const dispatch = useDispatch();
  16. const { t } = useTranslation();
  17. const content = searchQuery === ''
  18. ? GiphyContent.trending({ mediaType: GiphyMediaType.Gif })
  19. : GiphyContent.search({
  20. searchQuery,
  21. mediaType: GiphyMediaType.Gif
  22. });
  23. const sendGif = useCallback(e => {
  24. const url = getGifUrl(e.nativeEvent.media);
  25. sendAnalytics(createGifSentEvent());
  26. dispatch(sendMessage(formatGifUrlMessage(url), true));
  27. goBack();
  28. }, []);
  29. return (
  30. <JitsiScreen
  31. footerComponent = { GifsMenuFooter }
  32. style = { styles.container }>
  33. <ClearableInput
  34. customStyles = { styles.clearableInput }
  35. onChange = { setSearchQuery }
  36. placeholder = { t('giphy.search') }
  37. value = { searchQuery } />
  38. <GiphyGridView
  39. cellPadding = { 5 }
  40. content = { content }
  41. onMediaSelect = { sendGif }
  42. style = { styles.grid } />
  43. </JitsiScreen>
  44. );
  45. };
  46. export default GifsMenu;