function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import React, { useEffect, useState } from 'react';
import { Dimensions, FlatList, Image, Text, TouchableOpacity, View } from "react-native";
import stickerStore from "../../screens/chat/StickerStore";
import FastImage from 'react-native-fast-image';
function ImageLoading(props) {
  const [loaded, setLoaded] = useState(false);
  return /*#__PURE__*/React.createElement(FastImage, _extends({}, props, {
    style: {
      ...props.style,
      ...{
        backgroundColor: loaded ? 'transparent' : '#f8f8f8',
        overflow: 'hidden',
        borderRadius: loaded ? 0 : 10
      }
    },
    onLoadEnd: () => setLoaded(true)
  }));
}
export default function EmojiKeyboard(props) {
  useEffect(() => {
    stickerStore.getStickers();
  });
  const renderItem = _ref => {
    let {
      item,
      index
    } = _ref;
    return /*#__PURE__*/React.createElement(TouchableOpacity, {
      onPress: () => {
        if (props.onSelected) {
          props.onSelected(item);
        }
      },
      style: {
        flex: 1,
        maxWidth: Dimensions.get('window').width / 4,
        paddingVertical: 9,
        alignItems: 'center',
        justifyContent: 'center'
      }
    }, /*#__PURE__*/React.createElement(ImageLoading, {
      source: stickerStore.getStickerImage(item.attachment_id),
      style: {
        width: 68,
        height: 68,
        resizeMode: 'contain'
      }
    }));
  };
  const renderCategory = _ref2 => {
    let {
      item,
      index
    } = _ref2;
    return /*#__PURE__*/React.createElement(FlatList, {
      removeClippedSubviews: true,
      data: item.stickers,
      numColumns: 4,
      keyExtractor: (item, index) => index + '',
      renderItem: renderItem
    });
  };
  return /*#__PURE__*/React.createElement(FlatList, {
    style: {
      maxHeight: 300,
      backgroundColor: 'white'
    },
    removeClippedSubviews: true,
    data: stickerStore.data,
    keyExtractor: (item, index) => index + '',
    renderItem: renderCategory
  });
}
//# sourceMappingURL=index.js.map