-
Notifications
You must be signed in to change notification settings - Fork 0
/
Button.js
49 lines (46 loc) · 1.17 KB
/
Button.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
import React, { Component } from 'react';
import { Button, StyleSheet, View } from 'react-native';
export default class ButtonBasics extends Component {
_onPressButton() {
var time = new Date().getTime();
var code = "challenge_code_" + time;
fetch('https://pk88u3qgl2.execute-api.us-east-1.amazonaws.com/test/v1/example/', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
code: code,
name: 'challenge description at time ' + time,
})
})
alert('Thanks! Challenge submitted. Waiting for someone to accept.')
}
render() {
return (
<View style={styles.container}>
<View style={styles.buttonContainer}>
<Button
onPress={this._onPressButton}
title="Send a Friendly Challenge"
/>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
},
buttonContainer: {
margin: 20
},
alternativeLayoutButtonContainer: {
margin: 20,
flexDirection: 'row',
justifyContent: 'space-between'
}
});