From 712d8465a7645559ca2638d5eda6444534f5eeb0 Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Fri, 28 Apr 2023 20:56:03 -0400 Subject: [PATCH] fix small images style (#7310) --- app/components/files/file.tsx | 150 +++++++++++++++------------- app/components/files/image_file.tsx | 8 +- 2 files changed, 86 insertions(+), 72 deletions(-) diff --git a/app/components/files/file.tsx b/app/components/files/file.tsx index 7f5f83304..426228602 100644 --- a/app/components/files/file.tsx +++ b/app/components/files/file.tsx @@ -99,95 +99,109 @@ const File = ({ onOptionsPress?.(file); }, [file, onOptionsPress]); - const optionsButton = ( - - ); - - const fileInfo = ( - - ); - - const renderImageFileOverlay = ( - - ); - - const renderImageFile = ( - - - - {Boolean(nonVisibleImagesCount) && renderImageFileOverlay} - - - ); - - const renderVideoFile = ( - - - - {Boolean(nonVisibleImagesCount) && renderImageFileOverlay} - - - ); - - const renderDocumentFile = ( - - - - ); - const renderCardWithImage = (fileIcon: JSX.Element) => { + const fileInfo = ( + + ); + return ( {fileIcon} {fileInfo} - {onOptionsPress && optionsButton} + {onOptionsPress && + + } ); }; let fileComponent; if (isVideo(file) && publicLinkEnabled) { + const renderVideoFile = ( + + + + {Boolean(nonVisibleImagesCount) && + + } + + + ); + fileComponent = asCard ? renderCardWithImage(renderVideoFile) : renderVideoFile; } else if (isImage(file)) { + const renderImageFile = ( + + + + {Boolean(nonVisibleImagesCount) && + + } + + + ); + fileComponent = asCard ? renderCardWithImage(renderImageFile) : renderImageFile; } else if (isDocument(file)) { + const renderDocumentFile = ( + + + + ); + + const fileInfo = ( + + ); + fileComponent = ( {renderDocumentFile} {fileInfo} - {onOptionsPress && optionsButton} + {onOptionsPress && + + } ); } else { diff --git a/app/components/files/image_file.tsx b/app/components/files/image_file.tsx index 263863dc4..f935fcc6e 100644 --- a/app/components/files/image_file.tsx +++ b/app/components/files/image_file.tsx @@ -63,15 +63,14 @@ const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => ({ borderRadius: 5, }, smallImageOverlay: { - ...StyleSheet.absoluteFillObject, justifyContent: 'center', alignItems: 'center', borderRadius: 4, + position: 'absolute', }, singleSmallImageWrapper: { height: SMALL_IMAGE_MAX_HEIGHT, width: SMALL_IMAGE_MAX_WIDTH, - overflow: 'hidden', }, })); @@ -118,7 +117,8 @@ const ImageFile = ({ return props; }; - if (file.height <= SMALL_IMAGE_MAX_HEIGHT || file.width <= SMALL_IMAGE_MAX_WIDTH) { + const imageDimensions = getImageDimensions(); + if (imageDimensions && (imageDimensions.height <= SMALL_IMAGE_MAX_HEIGHT || imageDimensions.width <= SMALL_IMAGE_MAX_WIDTH)) { let wrapperStyle: StyleProp = style.fileImageWrapper; if (isSingleImage) { wrapperStyle = style.singleSmallImageWrapper; @@ -169,7 +169,6 @@ const ImageFile = ({ ); } - const imageDimensions = getImageDimensions(); image = ( ); } + return (