/* eslint-disable @typescript-eslint/no-shadow */ import React, { useEffect, useState } from 'react'; import { Image, TextInput, TouchableOpacity, View, TouchableWithoutFeedback, StyleSheet, } from 'react-native'; import type { CTextInput } from './model'; import { styles } from './styles'; const ic_close = require('../../assets/close.png'); const TextInputComponent: CTextInput = (props) => { const { fontFamily, style, value, placeholderTextColor = '#000', placeholder = '', showIcon, inputStyle, iconStyle, onChangeText = (_value: string) => {}, renderLeftIcon, renderRightIcon, } = props; const [text, setText] = useState(''); useEffect(() => { if (value) { setText(value); } }, [value]); const onChange = (text: string) => { setText(text); onChangeText(text); }; const _renderRightIcon = () => { if (showIcon) { if (renderRightIcon) { return renderRightIcon(); } if (text.length > 0) { return ( onChange('')}> ); } return null; } return null; }; const font = () => { if (fontFamily) { return { fontFamily: fontFamily, }; } else { return {}; } }; return ( {renderLeftIcon?.()} {_renderRightIcon()} ); }; export default TextInputComponent;