stream-chat-react-native-core
Version:
The official React Native and Expo components for Stream Chat, a service for building chat applications
88 lines • 3.61 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.LoadingIndicator = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _ThemeContext = require("../../contexts/themeContext/ThemeContext");
var _TranslationContext = require("../../contexts/translationContext/TranslationContext");
var _theme = require("../../theme");
var _Spinner = require("../UIComponents/Spinner");
var _jsxRuntime = require("react/jsx-runtime");
var _jsxFileName = "/home/runner/work/stream-chat-react-native/stream-chat-react-native/package/src/components/Indicators/LoadingIndicator.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 LoadingIndicatorWrapper = ({
text
}) => {
var styles = useStyles();
return (0, _jsxRuntime.jsxs)(_reactNative.View, {
accessibilityLiveRegion: "polite",
accessibilityRole: "progressbar",
style: styles.container,
children: [(0, _jsxRuntime.jsx)(_Spinner.Spinner, {
height: 20,
width: 20
}), text ? (0, _jsxRuntime.jsx)(_reactNative.Text, {
style: styles.loadingText,
testID: "loading",
children: text
}) : null]
});
};
var LoadingIndicator = props => {
var listType = props.listType,
loadingText = props.loadingText;
var _useTranslationContex = (0, _TranslationContext.useTranslationContext)(),
t = _useTranslationContex.t;
if (loadingText) {
return (0, _jsxRuntime.jsx)(LoadingIndicatorWrapper, {
text: loadingText
});
}
switch (listType) {
case 'channel':
return (0, _jsxRuntime.jsx)(LoadingIndicatorWrapper, {
text: t('Loading channels...')
});
case 'message':
return (0, _jsxRuntime.jsx)(LoadingIndicatorWrapper, {
text: t('Loading messages...')
});
case 'threads':
return (0, _jsxRuntime.jsx)(LoadingIndicatorWrapper, {
text: undefined
});
default:
return (0, _jsxRuntime.jsx)(LoadingIndicatorWrapper, {
text: t('Loading...')
});
}
};
exports.LoadingIndicator = LoadingIndicator;
LoadingIndicator.displayName = 'LoadingIndicator{loadingIndicator}';
var useStyles = () => {
var _useTheme = (0, _ThemeContext.useTheme)(),
_useTheme$theme = _useTheme.theme,
_useTheme$theme$loadi = _useTheme$theme.loadingIndicator,
container = _useTheme$theme$loadi.container,
loadingText = _useTheme$theme$loadi.loadingText,
semantics = _useTheme$theme.semantics;
return (0, _react.useMemo)(() => {
return _reactNative.StyleSheet.create({
container: {
alignItems: 'center',
flex: 1,
justifyContent: 'center',
...container
},
loadingText: {
fontSize: _theme.primitives.typographyFontSizeMd,
fontWeight: _theme.primitives.typographyFontWeightSemiBold,
marginTop: _theme.primitives.spacingSm,
color: semantics.textPrimary,
...loadingText
}
});
}, [container, loadingText, semantics]);
};
//# sourceMappingURL=LoadingIndicator.js.map