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
55 changes: 55 additions & 0 deletions src/components/TextInput/TextInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import React from 'react';
import {
StyleSheet,
Text,
TextInput as ReactTextInput,
View,
} from 'react-native';

import { useTheme } from '@/hooks';

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

const TextInput = ({ label, secureTextEntry, onSubmit }: Props) => {
const { themedStyles } = useTheme();
return (
<View style={styles.container}>
<Text style={{ ...styles.label, color: themedStyles.text }}>{label}</Text>
<ReactTextInput
style={{
...styles.input,
backgroundColor: themedStyles.inputBackground,
color: themedStyles.text,
borderColor: themedStyles.inputBorder,
}}
secureTextEntry={secureTextEntry}
onSubmitEditing={(value) => 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 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';
7 changes: 7 additions & 0 deletions src/screens/Components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { globalStyles } from 'style';

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

Expand All @@ -16,12 +17,18 @@ const Home = ({ navigation }: Props) => {

return (
<View style={styles.container}>
<Text>Components screen</Text>
<Text>{t('Hello')}</Text>
<PrimaryButton
text="Wróć do Home Screen"
onPress={() => navigation.navigate('Home')}
/>
<PrimaryButton text="primary button" onPress={() => {}} />
<TextInput
label="Email"
placeholder="Enter your email"
onSubmit={(text) => console.log(text)}
/>
<SwitchTheme />
<ConversationTile
image={{
Expand Down
4 changes: 4 additions & 0 deletions style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ export const darkColors = {
background: '#2F2F2F',
text: '#FFFFFF',
textSecondary: '#FFFFFF',
inputBackground: '#2d2d2d',
inputBorder: '#c7c4d6',
};

export const lightColors = {
background: '#FFFFFF',
text: '#010000',
textSecondary: '#73828A',
inputBackground: '#f0f0f0',
inputBorder: '#c7c4d6',
};
Loading