@attio/react-native-bottom-sheet-toolbox
Version:
39 lines (38 loc) • 1.48 kB
JavaScript
;
import * as React from "react";
import Animated, { useAnimatedStyle, useSharedValue } from "react-native-reanimated";
import { useBottomSheetToolboxInternalContext } from "../../context";
import { jsx as _jsx } from "react/jsx-runtime";
export function BottomSheetListWrapper({
children,
contentHeightSharedValue
}) {
const containerYSharedValue = useSharedValue(null);
const {
wrapperHeightSharedValue,
footerHeightSharedValue
} = useBottomSheetToolboxInternalContext();
const flashListContainerStyle = 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__*/_jsx(Animated.View, {
style: flashListContainerStyle,
onLayout: onLayout,
children: children
});
}
//# sourceMappingURL=bottom-sheet-list-wrapper.js.map