-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathApp.js
More file actions
165 lines (154 loc) · 5.1 KB
/
Copy pathApp.js
File metadata and controls
165 lines (154 loc) · 5.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
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
import React from 'react';
// import { StyleSheet, Text, View } from 'react-native';
import { Container, Form, Item, Label, Input, Header, Title, Content, Footer, FooterTab, Button, Left, Right, Body, Icon, Text, Picker } from 'native-base';
import Expo from "expo";
import { Alert } from 'react-native';
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {
loading: true,
teamNameValue: '',
projectNameValue: '',
challengeValue: '',
projectDescriptionValue: '',
urlValue: '',
pickerState: 'key0',
};
}
async componentWillMount() {
await Expo.Font.loadAsync({
Roboto: require('native-base/Fonts/Roboto.ttf'),
Roboto_medium: require('native-base/Fonts/Roboto_medium.ttf'),
Ionicons: require("@expo/vector-icons/fonts/Ionicons.ttf"),
});
this.setState({ loading: false });
}
onValueChange2(value) {
this.setState({
pickerState: value,
});
}
restPost() {
console.log("PickerState" + this.state.pickerState);
if (this.state.pickerState == 'key0') {
this.setState({ challengeValue: "SGInnovate Deep Tech Challenge" });
} else if (this.state.pickerState == 'key1') {
this.setState({ challengeValue: "IoT for Smart Homes Challenge" });
} else if (this.state.pickerState == 'key2') {
this.setState({ challengeValue: "Smart Homes for the Elderly" });
}
console.log("Challenge Value" + this.state.challengeValue);
var data =
'teamName=' +
this.state.teamNameValue +
'&name=' +
this.state.projectNameValue +
'&description=' +
this.state.projectDescriptionValue +
'&youtubeUrl=' +
this.state.urlValue +
'&challenge=' +
this.state.challengeValue;
const parseString = require('react-native-xml2js').parseString;
fetch(
'http://hackomania.geekshacking.com/Admin/public/webservices/Hackomania/Hackomania.asmx/updateProject',
{
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: data,
}
)
.then(response => response.text())
.then((response) => {
parseString(response, function (err, result) {
var i = response.search("success");
console.log(i);
console.log(response.charAt(i + 9));
console.log(response);
if (response.charAt(i + 9) == 1) {
Alert.alert("Project Successfully Uploaded!");
} else {
Alert.alert("Please try again");
}
});
})
.catch(error => {
Alert.alert(error);
});
}
render() {
if (this.state.loading) {
return <Expo.AppLoading />;
}
return (
<Container>
<Header>
<Left>
<Button onclick="sideMenu()" transparent>
<Icon name="menu" />
</Button>
</Left>
<Body>
<Title>HackOMania!</Title>
</Body>
<Right />
</Header>
<Content>
<Form style={{ paddingBottom: 25 }}>
<Item floatingLabel>
<Label>Team Name</Label>
<Input
onChangeText={teamNameValue => this.setState({ teamNameValue })}
/>
</Item>
<Item floatingLabel>
<Label>Project Name</Label>
<Input
onChangeText={projectNameValue =>
this.setState({ projectNameValue })}
/>
</Item>
<Item floatingLabel>
<Label>Project Description</Label>
<Input
onChangeText={projectDescriptionValue =>
this.setState({ projectDescriptionValue })}
/>
</Item>
<Item floatingLabel>
<Label>Enter Project Video URL</Label>
<Input onChangeText={urlValue => this.setState({ urlValue })} />
</Item>
<Label style={{ alignSelf: 'center', paddingTop: 15 }}>Challenge Being Addressed</Label>
<Picker
style={{ alignItems: 'center' }}
mode="dropdown"
placeholder="Tap to Choose Challenge"
selectedValue={this.state.pickerState}
onValueChange={this.onValueChange2.bind(this)}
>
<Picker.Item label="SGInnovate Deep Tech Challenge" value="key0" />
<Picker.Item label="IoT for Smart Homes Challenge" value="key1" />
<Picker.Item label="Smart Homes for the Elderly" value="key2" />
</Picker>
</Form>
<Button block onPress={this.restPost.bind(this)} primary style={{ width: '90%', alignSelf: 'center' }}>
<Text> Submit Project </Text>
</Button>
</Content>
</Container >
);
}
}
/*
<Item floatingLabel>
<Label>Which Challenge does your project address? </Label>
<Input
onChangeText={challengeValue =>
this.setState({ challengeValue })}
/>
</Item>
*/