Skip to content

Commit

Permalink
Changed name of the component to TextInput
Browse files Browse the repository at this point in the history
  • Loading branch information
Ereffe committed Mar 21, 2024
1 parent d26e98c commit 5f48b46
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/components/Input/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
import React from 'react';
import { StyleSheet, Text, TextInput, View } from 'react-native';
import {
StyleSheet,
Text,
TextInput as ReactTextInput,
View,
} from 'react-native';

import { useTheme } from '@/hooks';

type Props = React.ComponentPropsWithRef<typeof TextInput> & {
type Props = React.ComponentPropsWithRef<typeof ReactTextInput> & {
label: string;
secureTextEntry?: boolean;
onSubmit: (text: string) => void;
};

const Input = ({ ...props }: Props) => {
const TextInput = ({ ...props }: Props) => {
const { themedStyles } = useTheme();
return (
<View style={styles.container}>
<Text style={{ ...styles.label, color: themedStyles.text }}>
{props.label}
</Text>
<TextInput
<ReactTextInput
style={{
...styles.input,
backgroundColor: themedStyles.inputBackground,
color: themedStyles.text,
borderColor: themedStyles.inputBorder,
}}
defaultValue=""
secureTextEntry={props.secureTextEntry}
onSubmitEditing={(value) => props.onSubmit(value.nativeEvent.text)}
/>
Expand All @@ -50,4 +54,4 @@ const styles = StyleSheet.create({
},
});

export default Input;
export default TextInput;
1 change: 1 addition & 0 deletions src/components/TextInput/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as TextInput } from './TextInput';
4 changes: 2 additions & 2 deletions src/screens/Components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { globalStyles } from 'style';

import { SwitchTheme } from '@/components';
import { PrimaryButton } from '@/components/Button';
import { Input } from '@/components/Input';
import { TextInput } from '@/components/TextInput';
import { RootStackParamList } from '@/types/param';

type Props = NativeStackScreenProps<RootStackParamList, 'Components'>;
Expand All @@ -14,7 +14,7 @@ const Home = ({ navigation }: Props) => {
return (
<View style={styles.container}>
<Text>Components screen</Text>
<Input
<TextInput
label="Email"
placeholder="Enter your email"
onSubmit={(text) => console.log(text)}
Expand Down

0 comments on commit 5f48b46

Please sign in to comment.