diff --git a/components/qna/input.tsx b/components/qna/input.tsx index e669265..49bc2fb 100644 --- a/components/qna/input.tsx +++ b/components/qna/input.tsx @@ -1,8 +1,8 @@ import { useRef, useState } from 'react'; -import { TextInput, View } from 'react-native'; +import { KeyboardAvoidingView, TextInput, View } from 'react-native'; +import { useSafeAreaInsets } from 'react-native-safe-area-context'; import { extendedColors } from '../../theme/extendedColors'; -import { useKeyboardOffset } from '../../utils/keyboard.utils'; import { StyledButton } from '../common/styled-button'; interface InputProps { @@ -15,43 +15,49 @@ const MIN_CHARACTERS_TO_SEND = 5; export function Input({ placeholder, onSubmit, disabled = false }: InputProps) { const ref = useRef(null); + const insets = useSafeAreaInsets(); const [value, setValue] = useState(''); - const keyboardOffset = useKeyboardOffset(); + const onSend = () => { if (value.length < MIN_CHARACTERS_TO_SEND) return; ref.current?.clear(); onSubmit(value); setValue(''); }; + const isDisabled = value.length < MIN_CHARACTERS_TO_SEND || disabled; + return ( - - setValue(e.nativeEvent.text)} - onSubmitEditing={onSend} - editable={!disabled} - /> - - + + setValue(e.nativeEvent.text)} + onSubmitEditing={onSend} + editable={!disabled} + /> + + + ); }