-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
79 lines (70 loc) · 2.1 KB
/
App.js
File metadata and controls
79 lines (70 loc) · 2.1 KB
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
import React, { Component } from 'react';
import { TouchableHighlight, StyleSheet, Text, TextInput, View } from 'react-native';
export default class App extends Component {
constructor() {
super()
this.state = {
username: '',
password: '',
isLogined: false
}
}
inputChangeHandler = (value, name) => {
this.setState({
[name]: value
})
}
login = () => {
if ((this.state.username == 'joao') && (this.state.password == '123456')) {
this.setState({ isLogined: true });
}
else {
this.setState({ isLogined: false });
}
}
render() {
return (
<View style={LOCAL_STYLES.wrapper} testID="app-root" accessibilityLabel="app-root">
<View style={LOCAL_STYLES.inputContainer}>
<TextInput name="username" accessibilityLabel="username" style={LOCAL_STYLES.input} onChangeText={(text) => this.inputChangeHandler(text, "username")} />
</View>
<View style={LOCAL_STYLES.inputContainer}>
<TextInput name="password" accessibilityLabel="password" secureTextEntry={true} style={LOCAL_STYLES.input} onChangeText={(text) => this.inputChangeHandler(text, "password")} />
</View>
<Text accessibilityLabel="loginstatus">{this.state.isLogined ? "success" : "invalid"}</Text>
<TouchableHighlight style={LOCAL_STYLES.buttonContainer} accessibilityLabel="login" onPress={this.login}>
<Text style={{ color: 'white' }}>Login</Text>
</TouchableHighlight>
</View>
);
}
}
const LOCAL_STYLES = StyleSheet.create({
wrapper: {
flex: 1,
alignItems: "center",
justifyContent: "center"
},
inputContainer: {
borderBottomColor: '#F5FCFF',
backgroundColor: '#FFFFFF',
borderRadius: 30,
borderBottomWidth: 1,
marginBottom: 20,
flexDirection: 'row',
alignItems: 'center',
width: '80%',
borderColor: 'gray',
borderWidth: 1
},
buttonContainer: {
height: 45,
width: 250,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
marginBottom: 20,
borderRadius: 30,
backgroundColor: "#00b5ec"
}
});