stream-chat-react-native-core
Version:
The official React Native and Expo components for Stream Chat, a service for building chat applications
81 lines • 4.32 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ScrollToBottomButton = exports.SCROLL_TO_BOTTOM_WITH_COUNT_ACCESSIBILITY_LABEL_KEY = exports.SCROLL_TO_BOTTOM_ACCESSIBILITY_LABEL_KEY = void 0;
var _react = _interopRequireDefault(require("react"));
var _reactNative = require("react-native");
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
var _ComponentsContext = require("../../contexts/componentsContext/ComponentsContext");
var _ThemeContext = require("../../contexts/themeContext/ThemeContext");
var _theme = require("../../theme");
var _ui = require("../ui");
var _Button = require("../ui/Button");
var _jsxRuntime = require("react/jsx-runtime");
var _jsxFileName = "/home/runner/work/stream-chat-react-native/stream-chat-react-native/package/src/components/MessageList/ScrollToBottomButton.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 SCROLL_TO_BOTTOM_ACCESSIBILITY_LABEL_KEY = exports.SCROLL_TO_BOTTOM_ACCESSIBILITY_LABEL_KEY = 'a11y/Scroll to bottom';
var SCROLL_TO_BOTTOM_WITH_COUNT_ACCESSIBILITY_LABEL_KEY = exports.SCROLL_TO_BOTTOM_WITH_COUNT_ACCESSIBILITY_LABEL_KEY = 'a11y/Scroll to bottom, {{count}} new messages';
var ScrollToBottomButton = props => {
var onPress = props.onPress,
_props$showNotificati = props.showNotification,
showNotification = _props$showNotificati === void 0 ? true : _props$showNotificati,
unreadCount = props.unreadCount;
var _useTheme = (0, _ThemeContext.useTheme)(),
semantics = _useTheme.theme.semantics;
var _useComponentsContext = (0, _ComponentsContext.useComponentsContext)(),
icons = _useComponentsContext.icons;
var accessibilityLabelParams = _react.default.useMemo(() => unreadCount ? {
count: unreadCount
} : undefined, [unreadCount]);
if (!showNotification) {
return null;
}
return (0, _jsxRuntime.jsxs)(_reactNativeReanimated.default.View, {
entering: _reactNativeReanimated.ZoomIn.duration(200),
exiting: _reactNativeReanimated.ZoomOut.duration(200),
style: styles.container,
children: [(0, _jsxRuntime.jsx)(_reactNative.View, {
style: [styles.floatingButtonContainer, _theme.primitives.lightElevation1, {
backgroundColor: semantics.backgroundCoreElevation1
}],
children: (0, _jsxRuntime.jsx)(_Button.Button, {
accessibilityLabelKey: unreadCount ? SCROLL_TO_BOTTOM_WITH_COUNT_ACCESSIBILITY_LABEL_KEY : SCROLL_TO_BOTTOM_ACCESSIBILITY_LABEL_KEY,
accessibilityLabelParams: accessibilityLabelParams,
variant: "secondary",
type: "outline",
LeadingIcon: icons.Down,
onPress: onPress,
size: "md",
testID: "scroll-to-bottom-button",
iconOnly: true
})
}), (0, _jsxRuntime.jsx)(_reactNative.View, {
accessibilityElementsHidden: true,
importantForAccessibility: "no-hide-descendants",
style: styles.unreadCountNotificationContainer,
children: unreadCount ? (0, _jsxRuntime.jsx)(_ui.BadgeNotification, {
count: unreadCount,
size: "xs",
type: "primary",
testID: "unread-count"
}) : null
})]
}, 'scroll-to-bottom-button');
};
exports.ScrollToBottomButton = ScrollToBottomButton;
var styles = _reactNative.StyleSheet.create({
unreadCountNotificationContainer: {
position: 'absolute',
right: 0,
top: 0
},
floatingButtonContainer: {
borderRadius: _theme.primitives.radiusMax
},
container: {
padding: _theme.primitives.spacingXxs
}
});
ScrollToBottomButton.displayName = 'ScrollToBottomButton{messageList{scrollToBottomButton}}';
//# sourceMappingURL=ScrollToBottomButton.js.map