import {useTheme} from '../../theme/ThemeProvider'; import {Animated, Text, View} from 'react-native'; import {renderIcon} from '../../helpers/renderIcon'; import {useSlideAction} from '../../hooks'; import {slideStyles} from '../../theme'; import type {SlideActionProps} from '../../types'; const ACCESSIBILITY_ACTIONS = [{name: 'activate'}]; export const SlideAction = (props: SlideActionProps) => { const {colors} = useTheme(); const { accessibilityHint = 'Slide the thumb to the end to confirm', accessibilityLabel, height = 56, icon, iconColor = colors.secondary, iconCompletedColor = colors.success, iconOnCompleted, iconSize = 20, isCompleted, onCompleted, padding = 8, readonly, style, testID, text, textOnCompleted, textPosition = 'center', textStyle, thumbBorderColor, thumbBorderWidth, thumbColor = '#FFFFFF', thumbCompletedColor = '#FFFFFF', thumbWidth = 40, tintColor = colors.secondary, tintCompletedColor = colors.success, } = props; const { completed, handleAccessibilityAction, handleLayout, panResponder, showText, thumbLeft, } = useSlideAction(padding, thumbWidth, isCompleted, onCompleted); const responders = readonly ? {} : panResponder.panHandlers; const currentText = completed ? textOnCompleted : text; return ( {showText && ( {currentText} )} {renderIcon(completed ? (iconOnCompleted ?? icon) : icon, { size: iconSize, color: completed ? iconCompletedColor : iconColor, })} ); };