mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1import {ComponentProps} from 'react'
2import {StyleSheet, TextInput as RNTextInput, View} from 'react-native'
3import {IconProp} from '@fortawesome/fontawesome-svg-core'
4import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
5
6import {usePalette} from '#/lib/hooks/usePalette'
7import {useTheme} from '#/lib/ThemeContext'
8
9interface Props extends Omit<ComponentProps<typeof RNTextInput>, 'onChange'> {
10 testID?: string
11 icon: IconProp
12 onChange: (v: string) => void
13}
14
15export function TextInput({testID, icon, onChange, ...props}: Props) {
16 const theme = useTheme()
17 const pal = usePalette('default')
18 return (
19 <View style={[pal.border, styles.container]}>
20 <FontAwesomeIcon icon={icon} style={[pal.textLight, styles.icon]} />
21 <RNTextInput
22 testID={testID}
23 style={[pal.text, styles.textInput]}
24 placeholderTextColor={pal.colors.textLight}
25 autoCapitalize="none"
26 autoCorrect={false}
27 keyboardAppearance={theme.colorScheme}
28 onChangeText={v => onChange(v)}
29 {...props}
30 />
31 </View>
32 )
33}
34
35const styles = StyleSheet.create({
36 container: {
37 borderWidth: 1,
38 borderRadius: 6,
39 flexDirection: 'row',
40 alignItems: 'center',
41 paddingHorizontal: 4,
42 },
43 icon: {
44 marginLeft: 10,
45 },
46 textInput: {
47 flex: 1,
48 width: '100%',
49 paddingVertical: 10,
50 paddingHorizontal: 10,
51 fontSize: 17,
52 letterSpacing: 0.25,
53 fontWeight: '400',
54 borderRadius: 10,
55 },
56})