UNPKG

stream-chat-react-native-core

Version:

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

56 lines 1.8 kB
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.SvgAwareImage = void 0; var _react = _interopRequireDefault(require("react")); var _reactNative = require("react-native"); var _reactNativeSvg = require("react-native-svg"); var _useIsSvg = require("../../hooks/useIsSvg"); var _jsxRuntime = require("react/jsx-runtime"); var _jsxFileName = "/home/runner/work/stream-chat-react-native/stream-chat-react-native/package/src/components/UIComponents/SvgAwareImage.tsx"; var getSourceUri = source => { if (!source || typeof source !== 'object' || Array.isArray(source) || !('uri' in source)) { return undefined; } return source.uri; }; var SvgAwareImage = props => { var uri = getSourceUri(props.source); var isSvg = (0, _useIsSvg.useIsSvg)(uri); if (!isSvg || !uri) { return (0, _jsxRuntime.jsx)(_reactNative.Image, { ...props }); } var accessibilityLabel = props.accessibilityLabel, onError = props.onError, onLoad = props.onLoad, onLoadEnd = props.onLoadEnd, style = props.style, testID = props.testID; return (0, _jsxRuntime.jsx)(_reactNative.View, { accessibilityLabel: accessibilityLabel, style: style, testID: testID, children: (0, _jsxRuntime.jsx)(_reactNativeSvg.SvgUri, { height: "100%", onError: error => { onError == null || onError({ nativeEvent: { error } }); onLoadEnd == null || onLoadEnd(); }, onLoad: () => { onLoad == null || onLoad({}); onLoadEnd == null || onLoadEnd(); }, uri: uri, width: "100%" }) }); }; exports.SvgAwareImage = SvgAwareImage; //# sourceMappingURL=SvgAwareImage.js.map