/* eslint-disable react-native/no-inline-styles */ import React, { useContext } from 'react'; import { Dimensions, Image, Text, View } from 'react-native'; import { getAttachmentUrl } from '../../utils/utils'; import AppContext from '../../context/Context'; const fullWidth = Dimensions.get('window'); const width = fullWidth.width / 2; const Attachment: React.FC = ({ images }) => { const value = useContext(AppContext); const { subDomain } = value; if (!images || images.length === 0) { return null; } const renderImage = ( mWidth: number | string | undefined, uri: string, index: number ) => { const url = getAttachmentUrl(uri, subDomain); return ( ); }; if (images.length === 1) { return {renderImage(width, images[0].url, 0)}; } if (images.length === 2) { return ( {renderImage(width / 2 - 2, images[0].url, 0)} {renderImage(width / 2 - 2, images[1].url, 1)} ); } if (images.length === 3) { return ( {renderImage(width / 3 - 2, images[0].url, 0)} {renderImage(width / 3 - 2, images[1].url, 1)} {renderImage(width / 3 - 2, images[2].url, 2)} ); } if (images.length === 4) { return ( {renderImage(width / 3 - 2, images[0].url, 0)} {renderImage(width / 3 - 2, images[1].url, 1)} {renderImage(width / 3 - 2, images[2].url, 2)} {renderImage(width / 3 - 2, images[3].url, 3)} ); } return ( {renderImage(width / 3 - 2, images[0].url, 0)} {renderImage(width / 3 - 2, images[1].url, 1)} {renderImage(width / 3 - 2, images[2].url, 2)} {renderImage(width / 3 - 2, images[3].url, 3)} {'+ ' + `${images.length - 4}`} ); }; export default Attachment;