|
|
|
@ -15,7 +15,10 @@ import {
@@ -15,7 +15,10 @@ import {
|
|
|
|
|
Button, |
|
|
|
|
Keyboard, |
|
|
|
|
Platform, |
|
|
|
|
findNodeHandle, |
|
|
|
|
} from 'react-native' |
|
|
|
|
import { LayoutChangeEvent } from 'react-native' |
|
|
|
|
import { useKeyboard } from '@/shared/hooks' |
|
|
|
|
|
|
|
|
|
interface IProps { |
|
|
|
|
value: string |
|
|
|
@ -30,11 +33,14 @@ interface IProps {
@@ -30,11 +33,14 @@ interface IProps {
|
|
|
|
|
wrapStyle?: ViewStyle |
|
|
|
|
inputStyle?: TextStyle |
|
|
|
|
disabled?: boolean |
|
|
|
|
onSizeChange?: (reactNode: any) => void |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export const FormTextarea = (props: IProps) => { |
|
|
|
|
const { styles } = useTheme(createStyles) |
|
|
|
|
|
|
|
|
|
const keyboard = useKeyboard() |
|
|
|
|
|
|
|
|
|
const INPUT_ACCESSORIES_VIEW_ID = useMemo( |
|
|
|
|
() => Math.random().toString(), |
|
|
|
|
[], |
|
|
|
@ -49,6 +55,10 @@ export const FormTextarea = (props: IProps) => {
@@ -49,6 +55,10 @@ export const FormTextarea = (props: IProps) => {
|
|
|
|
|
) : null} |
|
|
|
|
<View style={styles.inputWrapper}> |
|
|
|
|
<TextInput |
|
|
|
|
onLayout={(event: LayoutChangeEvent) => { |
|
|
|
|
if (!props.onSizeChange || keyboard[0] <= 0) return |
|
|
|
|
props.onSizeChange(findNodeHandle(event.target)) |
|
|
|
|
}} |
|
|
|
|
inputAccessoryViewID={INPUT_ACCESSORIES_VIEW_ID} |
|
|
|
|
editable={!props.disabled} |
|
|
|
|
style={[styles.input, props.inputStyle]} |
|
|
|
|