UNPKG

stream-chat-react-native-core

Version:

The official React Native and Expo components for Stream Chat, a service for building chat applications

46 lines 1.39 kB
Object.defineProperty(exports, "__esModule", { value: true }); exports.buildThumbnailGrid = buildThumbnailGrid; var _buildThumbnail = require("./buildThumbnail"); function buildThumbnailGrid({ grid, images, invertedDirections = false, resizableCDNHosts, sizeConfig }) { var gridHeight = sizeConfig.gridHeight, gridWidth = sizeConfig.gridWidth; var imageIndex = 0; var thumbnailGrid = []; var numOfColumns = grid.length; grid.forEach((rows, colIndex) => { var totalFlexValue = rows.reduce((acc, curr) => acc + curr, 0); rows.forEach(flexValue => { var tHeight = invertedDirections ? gridHeight / numOfColumns : gridHeight * (flexValue / totalFlexValue); var tWidth = invertedDirections ? gridWidth * (flexValue / totalFlexValue) : gridWidth / numOfColumns; var currentImage = images[imageIndex]; var thumbnail = (0, _buildThumbnail.buildThumbnail)({ flex: flexValue, height: tHeight, image: currentImage, resizableCDNHosts, resizeMode: 'cover', width: tWidth }); if (!thumbnailGrid[colIndex]) { thumbnailGrid[colIndex] = []; } thumbnailGrid[colIndex].push(thumbnail); imageIndex++; }); }); return { height: gridHeight, invertedDirections, thumbnailGrid, width: gridWidth }; } //# sourceMappingURL=buildThumbnailGrid.js.map