stream-chat-react-native-core
Version:
The official React Native and Expo components for Stream Chat, a service for building chat applications
96 lines • 3.52 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.AttachmentUploadIndicatorUI = exports.AttachmentUploadIndicator = void 0;
var _react = _interopRequireDefault(require("react"));
var _reactNative = require("react-native");
var _ComponentsContext = require("../../contexts/componentsContext/ComponentsContext");
var _ThemeContext = require("../../contexts/themeContext/ThemeContext");
var _usePendingAttachmentUpload = require("../../hooks/usePendingAttachmentUpload");
var _utils = require("../../utils/utils");
var _jsxRuntime = require("react/jsx-runtime");
var _jsxFileName = "/home/runner/work/stream-chat-react-native/stream-chat-react-native/package/src/components/Attachment/AttachmentUploadIndicator.tsx";
var AttachmentUploadIndicatorUI = ({
containerStyle,
localId,
size = 16,
strokeWidth = 2,
style,
testID,
variant = 'compact'
}) => {
var _useTheme = (0, _ThemeContext.useTheme)(),
semantics = _useTheme.theme.semantics;
var _useComponentsContext = (0, _ComponentsContext.useComponentsContext)(),
CircularProgressIndicator = _useComponentsContext.CircularProgressIndicator,
MediaUploadProgressOverlay = _useComponentsContext.MediaUploadProgressOverlay;
var pendingUpload = (0, _usePendingAttachmentUpload.usePendingAttachmentUpload)(localId);
var uploadProgress = pendingUpload.uploadProgress;
var shouldRender = pendingUpload.isUploading;
var resolvedSize = variant === 'overlay' && size === 16 ? 28 : size;
var resolvedStrokeWidth = variant === 'overlay' && strokeWidth === 2 ? 3 : strokeWidth;
if (!shouldRender) {
return null;
}
if (variant === 'overlay') {
return (0, _jsxRuntime.jsx)(MediaUploadProgressOverlay, {
progress: uploadProgress,
size: resolvedSize,
strokeWidth: resolvedStrokeWidth,
testID: testID
});
}
return (0, _jsxRuntime.jsx)(_reactNative.View, {
pointerEvents: "none",
style: containerStyle,
children: uploadProgress === undefined ? (0, _jsxRuntime.jsx)(_reactNative.View, {
pointerEvents: "none",
style: [styles.indeterminateWrap, {
height: size,
width: size
}, style],
testID: testID,
children: (0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
color: semantics.accentPrimary,
size: "small"
})
}) : (0, _jsxRuntime.jsx)(CircularProgressIndicator, {
backgroundColor: semantics.backgroundCoreElevation0,
filledColor: semantics.accentPrimary,
progress: uploadProgress,
size: resolvedSize,
strokeWidth: resolvedStrokeWidth,
style: style,
testID: testID,
unfilledColor: semantics.borderCoreDefault
})
});
};
exports.AttachmentUploadIndicatorUI = AttachmentUploadIndicatorUI;
var AttachmentUploadIndicator = ({
containerStyle,
localId,
sourceUrl,
variant,
...props
}) => {
var shouldTrackPendingUpload = !!localId && !!sourceUrl && (0, _utils.isLocalUrl)(sourceUrl);
if (!shouldTrackPendingUpload) {
return null;
}
return (0, _jsxRuntime.jsx)(AttachmentUploadIndicatorUI, {
...props,
containerStyle: containerStyle,
localId: localId,
variant: variant
});
};
exports.AttachmentUploadIndicator = AttachmentUploadIndicator;
var styles = _reactNative.StyleSheet.create({
indeterminateWrap: {
alignItems: 'center',
justifyContent: 'center'
}
});
//# sourceMappingURL=AttachmentUploadIndicator.js.map