Login.js
3.42 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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import React, { Component } from 'react';
import { StyleSheet, Text, View, TextInput, Image} from 'react-native';
import LoginButton from './component/LoginButton';
import {add_data} from'./component/DBhelper.js';
export default class Login extends Component {
constructor(props) {
super(props);
this.state = {
ID: '',
}
}
static navigationOptions = {
title: 'Login',
};
getdata() {
return fetch('http://testloadbalancer-1847561458.ap-northeast-2.elb.amazonaws.com/app/get_data/pi1')
.then((response) => response.json())
.then((responseJson) => {
add_data(responseJson);
})
.catch((error) => {
console.error(error);
});
}
navigate(){
}
render() {
return (
<View style={styles.container}>
<View style={styles.header}>
<Text
style={{textAlign : 'center', fontSize : 50, marginTop:50}}>FW IoT</Text>
</View>
<View style={styles.logo}>
<Image
style = {styles.img}
source={require('./assets/logo.png')}/>
</View>
<View style={styles.input_div}>
<View
style={StyleSheet.inputPart}>
<Text
style={{textAlign:'center',fontSize : 40, marginTop :20}}>Food Waste IoT</Text>
<Text
style={{textAlign:'center',fontSize : 15, marginTop :20}}>기기 등록</Text>
<TextInput
style={styles.input}
placeholder="ID"
placeholderTextColor="#66b3ff"
value={this.state.text}
onChangeText={(text) => {this.setState({ID:text})}}
/>
<LoginButton
//onPress={()=>{this.getdata}}
onPress={() =>{ this.props.navigation.navigate('MainScreen', { ID: this.state.ID });}}
//onPress={() =>{ this.getdata().then(()=>{this.props.navigation.navigate('MainScreen', { ID: this.state.ID })}) }}
/>
</View>
</View>
<View style={styles.footer}>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
input: {
height: 50,
width: 250,
fontSize: 20,
alignSelf: 'center',
borderColor: "#0066cc",
borderWidth: 1,
backgroundColor:"white",
borderRadius: 10,
marginTop : 20,
},
input_title: {
textAlign:'center',
fontSize : 40,
marginTop :20,
},
container: {
flex: 1,
backgroundColor: 'white',
},
header: {
flex: 2,
backgroundColor: 'white',
},
logo: {
flex: 4,
justifyContent: "center",
alignItems: "center",
},
input_div :{
flex: 4,
backgroundColor: "rgba(230,230,230,0.5)",
borderRadius : 20,
margin:20,
},
footer:{
flex : 1,
},
img:{
width:200,
resizeMode: 'contain',
alignSelf :'center',
marginStart : 30,
},
});