import React, { useState } from 'react'; import { View, TextInput, Text, StyleSheet, TouchableOpacity, Platform, type TextInputProps, } from 'react-native'; import { Ionicons } from '@expo/vector-icons'; import { AppColors, BorderRadius, FontSizes, Spacing } from '@/constants/theme'; interface InputProps extends TextInputProps { label?: string; error?: string; leftIcon?: keyof typeof Ionicons.glyphMap; rightIcon?: keyof typeof Ionicons.glyphMap; onRightIconPress?: () => void; } export function Input({ label, error, leftIcon, rightIcon, onRightIconPress, secureTextEntry, style, ...props }: InputProps) { const [isPasswordVisible, setIsPasswordVisible] = useState(false); const isPassword = secureTextEntry !== undefined; const handleTogglePassword = () => { setIsPasswordVisible(!isPasswordVisible); }; return ( {label && {label}} {leftIcon && ( )} {isPassword && ( )} {!isPassword && rightIcon && ( )} {error && {error}} ); } const styles = StyleSheet.create({ container: { marginBottom: Spacing.md, }, label: { fontSize: FontSizes.sm, fontWeight: '500', color: AppColors.textPrimary, marginBottom: Spacing.xs, }, inputContainer: { flexDirection: 'row', alignItems: 'center', backgroundColor: AppColors.surface, borderRadius: BorderRadius.lg, borderWidth: 1, borderColor: AppColors.border, }, inputError: { borderColor: AppColors.error, }, input: { flex: 1, paddingVertical: Spacing.sm + 4, paddingHorizontal: Spacing.md, fontSize: FontSizes.base, color: AppColors.textPrimary, // Fix for Android password field text visibility ...(Platform.OS === 'android' && { fontFamily: 'Roboto', includeFontPadding: false, }), }, inputWithLeftIcon: { paddingLeft: 0, }, inputWithRightIcon: { paddingRight: 0, }, leftIcon: { marginLeft: Spacing.md, marginRight: Spacing.sm, }, rightIconButton: { padding: Spacing.md, }, errorText: { fontSize: FontSizes.xs, color: AppColors.error, marginTop: Spacing.xs, }, });