forked from mrzachnugent/react-native-reusables
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtextarea.tsx
47 lines (43 loc) · 1.25 KB
/
textarea.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import React from 'react';
import { ScrollView, TextInput, View } from 'react-native';
import { Label, LabelText } from '~/components/universal-ui/label';
import { Textarea } from '~/components/universal-ui/textarea';
export default function InputScreen() {
const inputRef = React.useRef<TextInput>(null);
const [value, setValue] = React.useState<string>('');
function handleOnLabelPress() {
if (!inputRef.current) {
return;
}
if (inputRef.current.isFocused()) {
inputRef.current?.blur();
} else {
inputRef.current?.focus();
}
}
function onChangeText(text: string) {
setValue(text);
}
return (
<ScrollView contentContainerClassName='flex-1 justify-center items-center p-6'>
<View className='web:max-w-xs w-full'>
<Label onPress={handleOnLabelPress}>
<LabelText
className='pb-2 native:pb-1 pl-0.5'
nativeID='textareaLabel'
>
Label
</LabelText>
</Label>
<Textarea
ref={inputRef}
placeholder='Write some stuff...'
value={value}
onChangeText={onChangeText}
aria-labelledbyledBy='textareaLabel'
/>
<View className='h-20' />
</View>
</ScrollView>
);
}