-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
103 lines (95 loc) · 1.96 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import React from 'react';
import { StatusBar } from 'expo-status-bar';
import {
Button,
StyleSheet,
Text,
TextInput,
TextInputProps,
TouchableOpacity,
View,
ViewProps,
ViewStyle,
} from 'react-native';
export default function App() {
type Props = {
title: string;
onPress: () => void;
bgColor?: string;
textColor?: string;
};
const CustomButton = (props: Props) => {
const { bgColor = '#000', onPress, textColor = '#fff', title } = props;
return (
<TouchableOpacity
onPress={onPress}
style={[
styles.btn,
{
backgroundColor: bgColor,
},
]}>
<Text style={{ color: textColor }}>{title}</Text>
</TouchableOpacity>
);
};
type CustomTextInpuntProps = TextInputProps & {
email?: boolean;
password?: boolean;
};
const CustomTextInput = (props: CustomTextInpuntProps) => {
const defaultStyle: ViewStyle = {
backgroundColor: '#efefef',
padding: 10,
borderRadius: 5,
height: 50,
width: '80%',
};
return (
<TextInput
{...props}
style={[defaultStyle, props.style]}
secureTextEntry={props.password ? true : false}
keyboardType={props.email ? 'email-address' : 'default'}
placeholder={
props.email
? 'Email'
: props.password
? 'Password'
: 'Default placeholder'
}
/>
);
};
return (
<View style={styles.container}>
<CustomButton
title='Login'
onPress={() => console.log('login')}
bgColor='#efefef'
textColor='#000'
/>
<CustomButton title='LogOut' onPress={() => console.log('LogOut')} />
<CustomButton title='Pay' onPress={() => console.log('Pay')} />
<CustomTextInput email />
<CustomTextInput password />
<CustomTextInput />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
btn: {
padding: 10,
borderRadius: 5,
width: 150,
height: 50,
justifyContent: 'center',
alignItems: 'center',
},
});