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