Skip to content

Commit

Permalink
Added input component
Browse files Browse the repository at this point in the history
  • Loading branch information
Ereffe authored and Ereffe committed Jan 12, 2024
1 parent d1d11b2 commit a5d22a7
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions src/components/CustomInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import React, { useState } from 'react';
import { StyleSheet, Text, TextInput, View } from 'react-native';

interface CustomInputProps {
label: string;
secureTextEntry?: boolean;
onSubmit: (text: string) => void;
}

const CustomInput: React.FC<CustomInputProps> = ({
label,
secureTextEntry,
onSubmit,
}) => {
const [text, setText] = useState('');

const handleSubmit = () => {
onSubmit(text);
};

return (
<View style={styles.container}>
<Text style={styles.label}>{label}</Text>
<TextInput
style={styles.input}
value={text}
secureTextEntry={secureTextEntry}
onChangeText={setText}
onSubmitEditing={handleSubmit}
/>
</View>
);
};

const styles = StyleSheet.create({
container: {
marginBottom: 10,
},
label: {
fontSize: 16,
marginBottom: 5,
fontFamily: '',
},
input: {
borderWidth: 1,
borderColor: '#c7c4d6',
borderRadius: 10,
width: 300,
height: 40,
padding: 10,
fontSize: 16,
},
});

export default CustomInput;

0 comments on commit a5d22a7

Please sign in to comment.