-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
104 lines (93 loc) · 2.52 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
104
import { StatusBar } from 'expo-status-bar';
import React, { useState } from 'react';
import { StyleSheet, Text, View, TextInput, TouchableOpacity } from 'react-native';
import { LoginSelector } from './e2e/components/selectors';
export default function App() {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [error, setError] = useState(false)
const [status, setStatus] = useState('')
const handleLogin = () => {
setError(false)
if (!email) {
setError(true)
setStatus('Please enter an email')
return
}
if (!password) {
setError(true)
setStatus('Please enter a password')
return
}
setStatus('Successful login!')
}
return (
<View style={styles.container}>
<Text style={styles.heading} testID={LoginSelector.heading}>Welcome to our app!</Text>
<View style={styles.inputView}>
<TextInput
testID={LoginSelector.emailInput}
style={styles.textInput}
placeholder="Enter email"
placeholderTextColor="#003f5c"
secureTextEntry={false}
onChangeText={(email) => setEmail(email)}
/>
</View>
<View style={styles.inputView}>
<TextInput
testID={LoginSelector.passwordInput}
style={styles.textInput}
placeholder="Enter password"
placeholderTextColor="#003f5c"
secureTextEntry={true}
onChangeText={(password) => setPassword(password)}
/>
</View>
<TouchableOpacity style={styles.loginBtn} onPress={() => handleLogin()} testID={LoginSelector.loginButton}>
<Text>LOGIN</Text>
</TouchableOpacity>
<Text style={{...styles.status, color: error ? 'red' : 'green'}} testID={LoginSelector.statusText}>{status}</Text>
<StatusBar style="auto" />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
inputView: {
backgroundColor: "#e0e4e0",
borderRadius: 15,
width: "70%",
height: 40,
marginBottom: 20,
alignItems: "center",
},
textInput: {
width: '100%',
height: 50,
flex: 1,
padding: 5,
marginLeft: 20,
},
heading: {
fontSize: 40,
marginBottom: 48
},
status: {
marginTop: 24
},
loginBtn: {
width: "80%",
borderRadius: 15,
height: 40,
alignItems: "center",
justifyContent: "center",
marginTop: 40,
backgroundColor: "#18ccbe",
}
});