-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ios.js
109 lines (102 loc) · 2.35 KB
/
index.ios.js
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
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict';
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
Text,
Image,
TouchableHighlight,
View
} = React;
var t = require('tcomb-form-native');
var Form = t.form.Form;
var Emergency = t.struct({
email: t.Str,
detail: t.Str
});
var options = {
fields: {
detail: {
multiline: true
}
}
};
var emergencyJS = React.createClass({
render: function() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to Emergency JS!
</Text>
<Text style={styles.instructions}>
Let us know your JavaScript emergency and someone from the team will be in touch shortly!
</Text>
<Form
ref="form"
type={Emergency}
options={options}
/>
<TouchableHighlight style={styles.button} onPress={this.onPress} underlayColor='#99d9f4'>
<Text style={styles.buttonText}>Save</Text>
</TouchableHighlight>
</View>
);
},
onPress: function() {
var form = this.refs.form.getValue();
if (form) {
fetch('https://hooks.slack.com/services/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', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"channel": "#emergency",
"username": form.email,
"text": form.detail,
"icon_emoji": ":oncoming_police_car:"
})
})
alert('Request Sent! We\'ll be in touch shortly...');
} else {
alert('Please enter your email address and your emergency detail.');
}
}
});
var styles = StyleSheet.create({
container: {
justifyContent: 'center',
marginTop: 50,
padding: 20,
backgroundColor: '#F6DE1E'
},
instructions: {
margin: 10
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
buttonText: {
fontSize: 18,
color: 'white',
alignSelf: 'center'
},
button: {
height: 36,
backgroundColor: '#FC321C',
borderColor: '#FC321C',
borderWidth: 1,
borderRadius: 3,
marginBottom: 10,
alignSelf: 'stretch',
justifyContent: 'center'
}
});
AppRegistry.registerComponent('emergencyJS', () => emergencyJS);