import React, { useContext } from 'react'; import { Pressable, Text, View } from 'react-native'; import Animated, { useAnimatedStyle } from 'react-native-reanimated'; import { ContextualContext } from './ContextualContext'; export interface ContextualMenuProps { actions: { key: string; label: string; action: () => void; color?: string }[]; } export function ContextualMenu(props: ContextualMenuProps) { const { actions } = props; const { anim, closeContext } = useContext(ContextualContext); const viewAnimStyle = useAnimatedStyle( () => ({ opacity: anim.value }), [anim] ); return ( {actions.map((action, i) => ( { action.action(); closeContext(); }} style={{ paddingHorizontal: 12, paddingVertical: 8, borderBottomColor: '#D3D3D3', borderBottomWidth: i >= actions.length - 1 ? 0 : 1, }} > {action.label} ))} ); }