// components/TextInputCustom.tsx import Ionicons from "@expo/vector-icons/Ionicons"; import React, { useState } from "react"; import { TextInput as RNTextInput, StyleProp, Text, TouchableOpacity, View, ViewStyle, } from "react-native"; import { textInputStyles } from "./textInputStyles"; type IconType = React.ReactNode | string; type Props = { iconLeft?: IconType; iconRight?: IconType; label?: string; required?: boolean; error?: string; secureTextEntry?: boolean; fontColor?: string; disabled?: boolean; borderRadius?: number; style?: StyleProp; } & Omit, "style">; export const TextInputCustom = ({ iconLeft, iconRight, label, required = false, error = "", secureTextEntry = false, fontColor = "#000", disabled = false, borderRadius = 8, style, ...rest }: Props) => { const [isPasswordVisible, setIsPasswordVisible] = useState(false); // Helper untuk render ikon const renderIcon = (icon: IconType) => { if (!icon) return null; return typeof icon === "string" ? ( {icon} ) : ( icon ); }; return ( {label && ( {label} {required && *} )} {iconLeft && ( {renderIcon(iconLeft)} )} {secureTextEntry && ( setIsPasswordVisible((prev) => !prev)} style={textInputStyles.icon} > )} {iconRight && ( {renderIcon(iconRight)} )} {error ? {error} : null} ); };