UNPKG

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

Version:
67 lines (66 loc) 3.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BottomSheetOverlayFooter = BottomSheetOverlayFooter; var _reactNative = require("react-native"); var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated")); var _context = require("../context"); var _hooks = require("../hooks"); 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); } const styles = _reactNative.StyleSheet.create({ container: { bottom: 0, opacity: 0, position: "absolute", width: "100%" } }); function BottomSheetOverlayFooter({ children, footerHeightSharedValue: outerFooterHeightSharedValue, bottomInsetSharedValue: outerBottomInsetSharedValue, style, keyboardAwareSafeAreaBottomInsetFallback = 0, ...hookArgs }) { const { isReadySharedValue, footerHeightSharedValue } = (0, _context.useBottomSheetToolboxInternalContext)(); const { height: layoutFooterHeightSharedValue, onLayout: onFooterLayout } = (0, _hooks.useLayoutSharedValue)(null); const KeyboardAwareSafeAreaBottomInsetSharedValue = (0, _hooks.useKeyboardAwareSafeAreaBottomInset)(keyboardAwareSafeAreaBottomInsetFallback); const bottomInsetSharedValue = (0, _reactNativeReanimated.useDerivedValue)(() => outerBottomInsetSharedValue === undefined ? KeyboardAwareSafeAreaBottomInsetSharedValue.get() : outerBottomInsetSharedValue?.get() ?? 0, [outerBottomInsetSharedValue, KeyboardAwareSafeAreaBottomInsetSharedValue]); (0, _reactNativeReanimated.useAnimatedReaction)(() => { const result = outerFooterHeightSharedValue === undefined ? layoutFooterHeightSharedValue.get() : outerFooterHeightSharedValue.get(); if (result === null) return null; return result + bottomInsetSharedValue.get(); }, value => { footerHeightSharedValue.set(value); }, [outerFooterHeightSharedValue, layoutFooterHeightSharedValue]); const bottomSharedValue = (0, _hooks.useFooterBottomPositionSharedValue)(hookArgs); const animatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => { const bottom = bottomSharedValue.get(); if (bottom === null || !isReadySharedValue.get()) return {}; const bottomInset = bottomInsetSharedValue.get(); return { opacity: 1, paddingBottom: bottomInset, transform: [{ translateY: -bottom }] }; }, [isReadySharedValue, bottomSharedValue]); return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, { style: [styles.container, style, animatedStyle], children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, { onLayout: onFooterLayout, children: children }) }); } //# sourceMappingURL=bottom-sheet-overlay-footer.js.map