import React, { FC, ReactNode, useState } from 'react'; import { TextInput, Text, View, InputModeOptions, NativeSyntheticEvent, TextInputFocusEventData, TouchableOpacity } from 'react-native'; import { styling } from './style'; import { Colors } from 'src/theme'; type Props = { placeholder?: string; onChange?: (text: string) => void; header?: string; isPrivate?: boolean; inputMode?: InputModeOptions; isFocused?: (boolean: boolean) => void; value?: string; active?: boolean; onBlur?: (e: NativeSyntheticEvent) => void; formikError?: string | boolean; icon?: ReactNode; multiline?: boolean; editable?: boolean; height?: number; backgroundColor?: string; clearIcon?: ReactNode; setValue?: (value: string) => void; }; export const Input: FC = ({ onChange, placeholder, header, isPrivate, inputMode, isFocused, onBlur, value, formikError, icon, multiline, editable, height, backgroundColor = Colors.FILL_LIGHT, clearIcon, setValue }) => { const [focused, setFocused] = useState(false); const styles = styling(focused); return ( {header ? {header} : null} {icon ? ( {icon} ) : null} { setFocused(true); if (isFocused) { isFocused(true); } }} onFocus={() => { if (inputMode !== 'none') { setFocused(true); if (isFocused) { isFocused(true); } } }} onBlur={(e) => { setFocused(false); if (onBlur) { onBlur(e); } }} style={[{ height: '100%', width: '100%', flex: 1 }, !icon ? { padding: 10 } : null]} /> {clearIcon && value && value?.length > 0 ? ( { setValue && setValue(''); }} > {clearIcon} ) : null} {formikError ? {formikError} : null} ); };