UNPKG

@cometchat/chat-uikit-react-native

Version:

Ready-to-use Chat UI Components for React Native

48 lines 1.72 kB
import React, { useCallback } from "react"; import { NativeModules, Pressable, Text, View } from "react-native"; import { useTheme } from "../../theme"; const WebView = NativeModules["WebViewManager"]; export const CometChatCollaborativeBubble = (props) => { const theme = useTheme(); // Opens the URL via onPress callback if provided; otherwise uses WebView. const openLink = () => { if (props.url !== "") { if (props.onPress) { props.onPress(props.url); } else { console.log("opening URL,", props.url); WebView.openUrl(props.url); } } }; // Returns the button text if available. const getButtonText = useCallback(() => { return props.buttonText && props.buttonText.trim().length > 0 ? props.buttonText : ""; }, [props.buttonText]); return (<View> {props.image} <View style={{ flexDirection: "row", paddingVertical: theme.spacing.padding.p2, gap: theme.spacing.spacing.s1, }}> {props.icon} <View style={{ flex: 1 }}> <Text numberOfLines={2} ellipsizeMode="tail" style={props.titleStyle}> {props.title} </Text> <Text numberOfLines={2} ellipsizeMode="tail" style={props.subtitleStyle}> {props.subtitle} </Text> </View> </View> <View style={props.dividerStyle}/> <Pressable style={props.buttonViewStyle}> <Text onPress={openLink} style={props.buttonTextStyle}> {getButtonText()} </Text> </Pressable> </View>); }; //# sourceMappingURL=CometChatCollaborativeBubble.js.map