import React, {useMemo} from 'react' import {TouchableWithoutFeedback} from 'react-native' import {BottomSheetBackdropProps} from '@gorhom/bottom-sheet' import Animated, { Extrapolate, interpolate, useAnimatedStyle, } from 'react-native-reanimated' import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' export function createCustomBackdrop( onClose?: (() => void) | undefined, ): React.FC { const CustomBackdrop = ({animatedIndex, style}: BottomSheetBackdropProps) => { const {_} = useLingui() // animated variables const opacity = useAnimatedStyle(() => ({ opacity: interpolate( animatedIndex.value, // current snap index [-1, 0], // input range [0, 0.5], // output range Extrapolate.CLAMP, ), })) const containerStyle = useMemo( () => [style, {backgroundColor: '#000'}, opacity], [style, opacity], ) return ( { if (onClose !== undefined) { onClose() } }}> ) } return CustomBackdrop }