import React, {forwardRef, useState} from 'react'; import { View, TextInput, TextInputProps, GestureResponderEvent, Pressable, } from 'react-native'; import {scale} from 'react-native-size-matters'; import EyeSlashIcon from '../../assets/icons/icEyeSlash.svg'; import OpenEyeIcon from '../../assets/icons/icOpenEye.svg'; import {COLORS} from '../../utilities/constants'; import {Body3, ErrorText} from '../TextComponents'; import TextInputAccessoryView from '../TextInputAccessoryView'; import styles from './styles'; interface TextInputWithLabelProps extends TextInputProps { containerStyle?: any; containerMarginTop?: number; containerMarginHorizontal?: number; labelStyle?: any; label: string; errorMessage: string | undefined; inputAccessoryViewID?: string; inputAccessoryViewLabel?: string; onInputAccessoryViewPress?: | ((event: GestureResponderEvent) => void) | undefined; } const TextInputWithLabel = forwardRef( (props, ref) => { const [isSecureTextEntryEnabled, setIsSecureTextEntryEnabled] = useState(!!props.secureTextEntry); return ( {props.label} {props.secureTextEntry && ( setIsSecureTextEntryEnabled(!isSecureTextEntryEnabled) } style={styles.secureTextEntry}> {isSecureTextEntryEnabled ? : } )} {props?.errorMessage && ( {props.errorMessage} )} {props.inputAccessoryViewID ? ( ) : null} ); }, ); export default TextInputWithLabel;