UNPKG

react-native-paper

Version:
38 lines (34 loc) 826 B
import type { GestureResponderEvent } from 'react-native'; export const handlePress = ({ onPress, value, onValueChange, event, }: { onPress?: (e: GestureResponderEvent) => void; value: string; onValueChange?: (value: string) => void; event: GestureResponderEvent; }) => { if (onPress && onValueChange) { console.warn( `onPress in the scope of RadioButtonGroup will not be executed, use onValueChange instead` ); } onValueChange ? onValueChange(value) : onPress?.(event); }; export const isChecked = ({ value, status, contextValue, }: { value: string; status?: 'checked' | 'unchecked'; contextValue?: string; }) => { if (contextValue !== undefined && contextValue !== null) { return contextValue === value ? 'checked' : 'unchecked'; } else { return status; } };