Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input component 86937xxay <new> #19

Merged
merged 10 commits into from
Apr 9, 2024
53 changes: 53 additions & 0 deletions src/components/Input/Input.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React from 'react';
import { StyleSheet, Text, TextInput, View } from 'react-native';

import { useTheme } from '@/hooks';

type Props = React.ComponentPropsWithRef<typeof TextInput> & {
wiktorrudzki marked this conversation as resolved.
Show resolved Hide resolved
label: string;
secureTextEntry?: boolean;
onSubmit: (text: string) => void;
};

const Input = ({ ...props }: Props) => {
Ereffe marked this conversation as resolved.
Show resolved Hide resolved
const { themedStyles } = useTheme();
return (
<View style={styles.container}>
<Text style={{ ...styles.label, color: themedStyles.text }}>
{props.label}
</Text>
<TextInput
style={{
...styles.input,
backgroundColor: themedStyles.inputBackground,
color: themedStyles.text,
borderColor: themedStyles.inputBorder,
}}
defaultValue=""
wiktorrudzki marked this conversation as resolved.
Show resolved Hide resolved
secureTextEntry={props.secureTextEntry}
onSubmitEditing={(value) => props.onSubmit(value.nativeEvent.text)}
/>
</View>
);
};

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

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

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

type Props = NativeStackScreenProps<RootStackParamList, 'Components'>;
Expand All @@ -13,6 +14,11 @@ const Home = ({ navigation }: Props) => {
return (
<View style={styles.container}>
<Text>Components screen</Text>
<Input
wiktorrudzki marked this conversation as resolved.
Show resolved Hide resolved
label="Email"
placeholder="Enter your email"
onSubmit={(text) => console.log(text)}
/>
<PrimaryButton
title="Wróć do Home Screen"
onPress={() => navigation.navigate('Home')}
Expand Down
6 changes: 6 additions & 0 deletions style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@ export const globalStyles = StyleSheet.create({

export const darkColors = {
primary: 'blue',
inputBackground: '#2d2d2d',
text: 'white',
inputBorder: '#c7c4d6',
};

export const lightColors = {
primary: 'green',
inputBackground: '#f0f0f0',
Text: 'black',
inputBorder: '#c7c4d6',
};
Loading