UNPKG

stream-chat-react-native-core

Version:

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

51 lines 2.87 kB
Object.defineProperty(exports, "__esModule", { value: true }); exports.LoadingDot = void 0; var _react = _interopRequireWildcard(require("react")); var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated")); var _ThemeContext = require("../../contexts/themeContext/ThemeContext"); var _jsxRuntime = require("react/jsx-runtime"); var _jsxFileName = "/home/runner/work/stream-chat-react-native/stream-chat-react-native/package/src/components/Indicators/LoadingDot.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 LoadingDot = props => { var _props$diameter = props.diameter, diameter = _props$diameter === void 0 ? 5 : _props$diameter, _props$duration = props.duration, duration = _props$duration === void 0 ? 1500 : _props$duration, _props$offset = props.offset, offset = _props$offset === void 0 ? 0 : _props$offset, style = props.style; var halfDuration = duration / 2; var startingOffset = halfDuration - offset; var _useTheme = (0, _ThemeContext.useTheme)(), _useTheme$theme = _useTheme.theme, loadingDot = _useTheme$theme.loadingDots.loadingDot, semantics = _useTheme$theme.semantics; var opacity = (0, _reactNativeReanimated.useSharedValue)(startingOffset / halfDuration); (0, _react.useEffect)(() => { opacity.value = (0, _reactNativeReanimated.withSequence)((0, _reactNativeReanimated.withTiming)(0, { duration: startingOffset, easing: _reactNativeReanimated.Easing.linear }), (0, _reactNativeReanimated.withRepeat)((0, _reactNativeReanimated.withSequence)((0, _reactNativeReanimated.withTiming)(1, { duration: halfDuration, easing: _reactNativeReanimated.Easing.linear }), (0, _reactNativeReanimated.withTiming)(0, { duration: halfDuration, easing: _reactNativeReanimated.Easing.linear })), -1)); }, []); var dotStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({ opacity: opacity.value }), []); return (0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, { style: [{ backgroundColor: semantics.chatTextTypingIndicator, borderRadius: diameter / 2, height: diameter, width: diameter }, style, dotStyle, loadingDot] }); }; exports.LoadingDot = LoadingDot; //# sourceMappingURL=LoadingDot.js.map