stream-chat-react-native-core
Version:
The official React Native and Expo components for Stream Chat, a service for building chat applications
43 lines • 2.59 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.StreamBottomSheetModalFlatList = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactNativeGestureHandler = require("react-native-gesture-handler");
var _reactNativeReanimated = require("react-native-reanimated");
var _BottomSheetContext = require("../../contexts/bottomSheetContext/BottomSheetContext");
var _hooks = require("../../hooks");
var _jsxRuntime = require("react/jsx-runtime");
var _jsxFileName = "/home/runner/work/stream-chat-react-native/stream-chat-react-native/package/src/components/UIComponents/StreamBottomSheetModalFlatList.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 StreamBottomSheetModalFlatList = ({
scrollEnabled: scrollEnabledProp,
...props
}) => {
var _useBottomSheetContex = (0, _BottomSheetContext.useBottomSheetContext)(),
currentSnapIndex = _useBottomSheetContex.currentSnapIndex,
topSnapIndex = _useBottomSheetContex.topSnapIndex;
var listRef = (0, _react.useRef)(null);
var setNativeScrollEnabled = (0, _hooks.useStableCallback)(value => {
var _listRef$current;
return (_listRef$current = listRef.current) == null ? void 0 : _listRef$current.setNativeProps({
scrollEnabled: value
});
});
(0, _reactNativeReanimated.useAnimatedReaction)(() => ({
currentSnapIndex: currentSnapIndex.value,
topSnapIndex: topSnapIndex.value
}), (value, prev) => {
if (scrollEnabledProp !== undefined || prev && value.currentSnapIndex === prev.currentSnapIndex && value.topSnapIndex === prev.topSnapIndex) {
return;
}
(0, _reactNativeReanimated.runOnJS)(setNativeScrollEnabled)(value.currentSnapIndex === value.topSnapIndex);
}, [currentSnapIndex, topSnapIndex]);
return (0, _jsxRuntime.jsx)(_reactNativeGestureHandler.FlatList, {
ref: listRef,
...props,
scrollEnabled: false
});
};
exports.StreamBottomSheetModalFlatList = StreamBottomSheetModalFlatList;
//# sourceMappingURL=StreamBottomSheetModalFlatList.js.map