import * as React from 'react'; import { TextInput as RNTextInput, View } from 'react-native'; import { useColors } from '../../hook'; import { useI18nContext } from '../../i18n'; import { usePaletteContext, useThemeContext } from '../../theme'; import { IconButton, Text1Button } from '../../ui/Button'; import { Icon } from '../../ui/Image'; import { TextInput } from '../../ui/TextInput'; import { timeoutTask } from '../../utils'; /** * Search Component properties. */ export type SearchProps = { /** * Cancel button click event. */ onCancel?: () => void; /** * Text change event. */ onChangeText?: ((text: string) => void) | undefined; /** * Text value. */ value?: string | undefined; /** * Back button click event. */ onBack?: () => void; }; /** * Search Component. */ export function Search(props: SearchProps) { const { onCancel, onChangeText, value, onBack } = props; const inputRef = React.useRef>(null); const { tr } = useI18nContext(); const { style, cornerRadius } = useThemeContext(); const { input } = cornerRadius; const { colors } = usePaletteContext(); const { getColor } = useColors({ cursor: { light: colors.primary[5], dark: colors.primary[6], }, h: { light: colors.neutral[6], dark: colors.neutral[4], }, }); React.useEffect(() => { // !!! node_modules/@react-navigation/native-stack/src/types.tsx `animationDuration` timeoutTask(500, () => inputRef.current?.focus()); }, []); return ( {onBack ? ( ) : null} {onCancel ? ( ) : null} ); }