diff options
Diffstat (limited to 'src/components/ContextMenu/Backdrop.tsx')
-rw-r--r-- | src/components/ContextMenu/Backdrop.tsx | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/components/ContextMenu/Backdrop.tsx b/src/components/ContextMenu/Backdrop.tsx new file mode 100644 index 000000000..857be7c44 --- /dev/null +++ b/src/components/ContextMenu/Backdrop.tsx @@ -0,0 +1,45 @@ +import {Pressable} from 'react-native' +import Animated, { + Extrapolation, + interpolate, + SharedValue, + useAnimatedStyle, +} from 'react-native-reanimated' +import {msg} from '@lingui/macro' +import {useLingui} from '@lingui/react' + +import {atoms as a, useTheme} from '#/alf' + +export function Backdrop({ + animation, + intensity = 50, + onPress, +}: { + animation: SharedValue<number> + intensity?: number + onPress?: () => void +}) { + const t = useTheme() + const {_} = useLingui() + + const animatedStyle = useAnimatedStyle(() => ({ + opacity: interpolate( + animation.get(), + [0, 1], + [0, intensity / 100], + 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> + ) +} |