import React from 'react'; import { View, ViewStyle } from 'react-native'; import { PdfProps, PdfViewer } from '../PdfViewer'; import { FileViewerProps } from './interfaces'; import { ImageViewerProps } from './ImagePreview/interface'; import ImagePreview from './ImagePreview'; import PdfThumbnail from './thumbnails/PdfThumbnail'; import ImageThumbnail from './thumbnails/ImageThumbnail'; const FileViewer: FileViewerProps = ({ type = 'all', ...rest }) => { const size = 'size' in rest ? rest.size : 108; const gap = 'gap' in rest ? rest.gap : 10; if (type === 'all' && 'sources' in rest) { const { sources, ...props } = rest; const containerStyle: ViewStyle = { flexDirection: 'row', gap, }; return ( {sources.map((source, index) => { if (source.type === 'image') { return ( ); } if (source.type === 'pdf') { return ( ); } return null; })} ); } if (type === 'image') { const children = (rest as ImageViewerProps).noThumbnails ? null : (rest as ImageViewerProps).children ?? (rest as ImageViewerProps).sources?.map((img, index) => { return ; }); return ( {children} ); } if (type === 'pdf') { return ; } return null; }; FileViewer.PdfThumbnail = PdfThumbnail; FileViewer.ImageThumbnail = ImageThumbnail; export default FileViewer;