stream-chat-react-native-core
Version:
The official React Native and Expo components for Stream Chat, a service for building chat applications
77 lines • 3.83 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.UnsupportedAttachment = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _ComponentsContext = require("../../contexts/componentsContext/ComponentsContext");
var _MessageContext = require("../../contexts/messageContext/MessageContext");
var _ThemeContext = require("../../contexts/themeContext/ThemeContext");
var _TranslationContext = require("../../contexts/translationContext/TranslationContext");
var _theme = require("../../theme");
var _jsxRuntime = require("react/jsx-runtime");
var _jsxFileName = "/home/runner/work/stream-chat-react-native/stream-chat-react-native/package/src/components/Attachment/UnsupportedAttachment.tsx";
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
var UnsupportedAttachment = props => {
var _useComponentsContext = (0, _ComponentsContext.useComponentsContext)(),
FileAttachmentIcon = _useComponentsContext.FileAttachmentIcon;
var _useMessageContext = (0, _MessageContext.useMessageContext)(),
isMyMessage = _useMessageContext.isMyMessage;
var attachment = props.attachment,
attachmentIconSize = props.attachmentIconSize;
var styles = useStyles({
isMyMessage
});
var _useTheme = (0, _ThemeContext.useTheme)(),
_useTheme$theme$messa = _useTheme.theme.messageItemView.unsupportedAttachment,
container = _useTheme$theme$messa.container,
details = _useTheme$theme$messa.details,
title = _useTheme$theme$messa.title;
var _useTranslationContex = (0, _TranslationContext.useTranslationContext)(),
t = _useTranslationContex.t;
return (0, _jsxRuntime.jsxs)(_reactNative.View, {
style: [styles.container, container],
children: [(0, _jsxRuntime.jsx)(FileAttachmentIcon, {
mimeType: attachment.mime_type,
size: attachmentIconSize
}), (0, _jsxRuntime.jsx)(_reactNative.View, {
style: [styles.details, details],
children: (0, _jsxRuntime.jsx)(_reactNative.Text, {
numberOfLines: 2,
style: [styles.title, title],
children: attachment.title ?? t('Unsupported Attachment')
})
})]
});
};
exports.UnsupportedAttachment = UnsupportedAttachment;
UnsupportedAttachment.displayName = 'UnsupportedAttachment{messageItemView{file}}';
var useStyles = ({
isMyMessage
}) => {
var _useTheme2 = (0, _ThemeContext.useTheme)(),
semantics = _useTheme2.theme.semantics;
return (0, _react.useMemo)(() => {
return _reactNative.StyleSheet.create({
container: {
alignItems: 'center',
flexDirection: 'row',
padding: _theme.primitives.spacingSm,
gap: _theme.primitives.spacingSm,
width: 256,
backgroundColor: isMyMessage ? semantics.chatBgAttachmentOutgoing : semantics.chatBgAttachmentIncoming
},
details: {
flexShrink: 1,
gap: _theme.primitives.spacingXxs
},
title: {
color: semantics.textPrimary,
fontSize: _theme.primitives.typographyFontSizeSm,
fontWeight: _theme.primitives.typographyFontWeightSemiBold,
lineHeight: _theme.primitives.typographyLineHeightTight
}
});
}, [semantics, isMyMessage]);
};
//# sourceMappingURL=UnsupportedAttachment.js.map