Something went wrong. Try again.
Mirror — see github.com/blacksky-algorithms/blacksky.community
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586import {Pressable} from 'react-native'import Animated, { Extrapolation, interpolate, type SharedValue, useAnimatedProps, useAnimatedStyle,} from 'react-native-reanimated'import {BlurView} from 'expo-blur'import {msg} from '@lingui/core/macro'import {useLingui} from '@lingui/react'
import {atoms as a, useTheme} from '#/alf'import {useContextMenuContext} from './context'
const AnimatedBlurView = Animated.createAnimatedComponent(BlurView)
type Props = { animation: SharedValue<number> intensity?: number onPress?: () => void}
export function Backdrop(props: Props) { const {mode} = useContextMenuContext() switch (mode) { case 'full': return <BlurredBackdrop {...props} /> case 'auxiliary-only': return <OpacityBackdrop {...props} /> }}
function BlurredBackdrop({animation, intensity = 50, onPress}: Props) { const {_} = useLingui()
const animatedProps = useAnimatedProps(() => ({ intensity: interpolate( animation.get(), [0, 1], [0, intensity], Extrapolation.CLAMP, ), }))
return ( <AnimatedBlurView animatedProps={animatedProps} style={[a.absolute, a.inset_0]} tint="systemMaterialDark"> <Pressable style={a.flex_1} accessibilityLabel={_(msg`Close menu`)} accessibilityHint={_(msg`Tap to close context menu`)} onPress={onPress} /> </AnimatedBlurView> )}
function OpacityBackdrop({animation, onPress}: Props) { const t = useTheme() const {_} = useLingui()
const animatedStyle = useAnimatedStyle(() => ({ opacity: interpolate( animation.get(), [0, 1], [0, 0.05], Extrapolation.CLAMP, ), }))
return ( <Animated.View style={[a.absolute, a.inset_0, t.atoms.bg_contrast_975, animatedStyle]}> <Pressable style={a.flex_1} accessibilityLabel={_(msg`Close menu`)} accessibilityHint={_(msg`Tap to close context menu`)} onPress={onPress} /> </Animated.View> )}