import React, { useContext, useState } from 'react'; import { TouchableOpacity } from 'react-native'; import FastImage from '@rocket.chat/react-native-fast-image'; import styles from '../styles'; import { CustomIcon } from '../../../lib/Icons'; import { themes } from '../../../constants/colors'; import MessageboxContext from '../Context'; import ActivityIndicator from '../../ActivityIndicator'; interface IMessageBoxCommandsPreviewItem { item: { type: string; id: string; value: string; }; theme?: string; } const Item = ({ item, theme }: IMessageBoxCommandsPreviewItem) => { const context = useContext(MessageboxContext); const { onPressCommandPreview } = context; const [loading, setLoading] = useState(true); return ( onPressCommandPreview(item)} testID={`command-preview-item${item.id}`}> {item.type === 'image' ? ( setLoading(true)} onLoad={() => setLoading(false)}> {loading ? : null} ) : ( )} ); }; export default Item;