UNPKG

react-native-chating-ui-kit

Version:

CometChat React Native UI Kit is a collection of custom UI Components designed to build text , chat and calling features in your application. The UI Kit is developed to keep developers in mind and aims to reduce development efforts significantly

34 lines (33 loc) 1.4 kB
import React from "react"; import { TouchableOpacity, Image, NativeModules, Platform } from "react-native"; import { ImageBubbleStyle } from "./ImageBubbleStyle"; const { FileManager, ImageManager } = NativeModules; export const CometChatImageBubble = (props) => { const { thumbnailUrl, imageUrl, onPress, placeHolderImage, style } = props; const _style = new ImageBubbleStyle(style || {}); const { backgroundColor, border, borderRadius, height, width } = _style; const getFileName = (url) => { return (url.substring(url.lastIndexOf("/") + 1)); }; const openImage = () => { let url; if (typeof imageUrl == "object") { url = imageUrl.uri; } if (onPress) { onPress(imageUrl); } Platform.OS == 'ios' ? FileManager.openFile(url, `${getFileName(url)}_${new Date().getTime()}.png`, (s) => { }) : ImageManager.openImage(url, s => { }); }; return (<TouchableOpacity onPress={openImage} activeOpacity={1}> <Image resizeMode={Platform.OS == "android" ? "cover" : "contain"} loadingIndicatorSource={placeHolderImage} source={thumbnailUrl ?? imageUrl} style={{ height, width, backgroundColor, borderRadius, ...border }}/> </TouchableOpacity>); }; //# sourceMappingURL=CometChatImageBubble.js.map