import { ActivityIndicator, Pressable, Text, View } from 'react-native'; import { useColors, useMotionActive, useThemedStyles } from '../../../theme'; import { normalizeNonBlankText } from '../shared/accessibilityName'; import { useMenuMousePress } from './useMenuMousePress'; import { makeStyles } from './styles'; import type { ActionMenuItemProps } from './types'; export function ActionMenuItem({ action, onPress, confirmation = false, }: ActionMenuItemProps) { const styles = useThemedStyles(makeStyles); const colors = useColors(); const motionActive = useMotionActive(); const label = normalizeNonBlankText(action.label); const busy = action.loading === true; const disabled = action.disabled === true || busy || !label; const { mousePressed, ...mouseHandlers } = useMenuMousePress(disabled); const danger = action.tone === 'danger'; const color = danger ? colors.error : colors.foreground; return ( [ styles.popoverRow, confirmation && styles.popoverConfirmButton, confirmation && danger && styles.popoverConfirmDanger, (pressed || mousePressed) && (confirmation ? styles.popoverConfirmPressed : styles.popoverRowPressed), disabled && styles.popoverRowDisabled, ]} > {action.icon || busy ? ( {busy ? ( ) : action.icon ? ( ) : null} ) : null} {action.label} ); }