Browse Source

Add App.js to Laura Branch

laura.gonzalez19 4 years ago
parent
commit
59abd4370f
1 changed files with 133 additions and 0 deletions
  1. 133
    0
      App.js

+ 133
- 0
App.js View File

@@ -0,0 +1,133 @@
1
+import React, { Component } from 'react';
2
+
3
+import { StyleSheet, TextInput, View, Alert, TouchableOpacity, Text } from 'react-native';
4
+
5
+export default class App extends Component {
6
+
7
+  constructor(props) {
8
+    super(props)
9
+
10
+    this.state = {
11
+      name_l: '',
12
+      name_u: '',
13
+      lid: '',
14
+	  uid: ''
15
+    }
16
+  }
17
+
18
+  insertList_Function = () => {
19
+
20
+    fetch('https://ada.uprrp.edu/~laura.gonzalez19/4030/insert_list.php', {
21
+      method: 'POST',
22
+      headers: {
23
+        'Accept': 'application/json',
24
+        'Content-Type': 'application/json',
25
+      },
26
+      body: JSON.stringify({
27
+
28
+        name_l: this.state.name_l,
29
+
30
+        name_u: this.state.name_u,
31
+
32
+        lid: this.state.lid,
33
+		
34
+		uid: this.state.uid,
35
+
36
+      })
37
+
38
+    }).then((response) => response.json())
39
+      .then((responseJson) => {
40
+        // Showing response message coming from server after inserting records.
41
+        Alert.alert(responseJson);
42
+      }).catch((error) => {
43
+        console.error(error);
44
+      });
45
+
46
+
47
+  }
48
+
49
+  render() {
50
+    return (
51
+
52
+      <View style={styles.MainContainer}>
53
+
54
+        <Text style={{ fontSize: 25, color: "#3414B3", textAlign: 'center', marginBottom: 15 }}>Draft: New List Form</Text>
55
+
56
+        <TextInput
57
+          placeholder="Who is using this list?"
58
+          onChangeText={data => this.setState({ name_u: data })}
59
+          underlineColorAndroid='transparent'
60
+          style={styles.TextInputStyleClass}
61
+        />
62
+		
63
+		 <TextInput
64
+          placeholder="Name the list!"
65
+          onChangeText={data => this.setState({ name_l: data })}
66
+          underlineColorAndroid='transparent'
67
+          style={styles.TextInputStyleClass}
68
+        />
69
+
70
+        <TextInput
71
+          placeholder="Enter UID(Hidden)"
72
+          onChangeText={data => this.setState({ uid: data })}
73
+          underlineColorAndroid='transparent'
74
+          style={styles.TextInputStyleClass}
75
+        />
76
+
77
+        <TextInput
78
+          placeholder="Enter LID(Hidden)"
79
+          onChangeText={data => this.setState({ lid: data })}
80
+          underlineColorAndroid='transparent'
81
+          style={styles.TextInputStyleClass}
82
+        />
83
+
84
+        <TouchableOpacity style={styles.button} onPress={this.insertList_Function} >
85
+
86
+          <Text style={styles.text}>+</Text>
87
+        </TouchableOpacity>
88
+		<Text style={{ fontSize: 15, color: "#3414B3", textAlign: 'center', marginTop: 20, marginBottom: 15 }}>Start adding your lists </Text>
89
+      </View>
90
+
91
+    );
92
+  }
93
+}
94
+
95
+const styles = StyleSheet.create({
96
+
97
+  MainContainer: {
98
+
99
+    justifyContent: 'center',
100
+    alignItems: 'center',
101
+    flex: 1,
102
+    margin: 10
103
+  },
104
+
105
+  TextInputStyleClass: {
106
+
107
+    textAlign: 'center',
108
+    marginBottom: 7,
109
+    height: 40,
110
+    width: '80%',
111
+    borderWidth: 1,
112
+    borderColor: '#3414B3',
113
+    borderRadius: 5,
114
+  },
115
+
116
+  button: {
117
+	height:'10%',
118
+    width: '20%',
119
+    paddingTop: 2,
120
+    paddingBottom: 2,
121
+    backgroundColor: '#3414B3',
122
+    borderRadius: 100,
123
+    marginTop: 20
124
+  },
125
+
126
+  text: {
127
+    color: '#fff',
128
+    fontSize: 40,
129
+    textAlign: 'center',
130
+    padding: 5
131
+  }
132
+
133
+});