UNPKG

@attio/react-native-bottom-sheet-toolbox

Version:
44 lines (43 loc) 2.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BottomSheetListWrapper = BottomSheetListWrapper; var React = _interopRequireWildcard(require("react")); var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated")); var _context = require("../../context"); var _jsxRuntime = require("react/jsx-runtime"); 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 (const 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); } function BottomSheetListWrapper({ children, contentHeightSharedValue }) { const containerYSharedValue = (0, _reactNativeReanimated.useSharedValue)(null); const { wrapperHeightSharedValue, footerHeightSharedValue } = (0, _context.useBottomSheetToolboxInternalContext)(); const flashListContainerStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => { const wrapperHeight = wrapperHeightSharedValue.get(); const containerY = containerYSharedValue.get(); const contentHeight = contentHeightSharedValue.get(); const footerHeight = footerHeightSharedValue.get(); return { flexGrow: 1, height: contentHeight || undefined, minHeight: 10, // Prevent FlashList warning as we initialize maxHeight: wrapperHeight !== null && containerY !== null ? wrapperHeight - containerY - (footerHeight ?? 0) : undefined, width: "100%" }; }, [contentHeightSharedValue, wrapperHeightSharedValue, footerHeightSharedValue]); const onLayout = React.useCallback(evt => { containerYSharedValue.set(evt.nativeEvent.layout.y); }, []); return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, { style: flashListContainerStyle, onLayout: onLayout, children: children }); } //# sourceMappingURL=bottom-sheet-list-wrapper.js.map