Created
July 16, 2016 04:06
-
-
Save compilerexe/17cbc4e49b7ad5f7a69ec1631fcc5090 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, {Component,} from 'react'; | |
| import { | |
| AppRegistry, | |
| StyleSheet, | |
| Text, | |
| View, | |
| TouchableOpacity | |
| } from 'react-native'; | |
| class App extends Component { | |
| constructor() { | |
| super(); | |
| this.state = { | |
| buzzer: 'Buzzer' | |
| }; | |
| } | |
| detectON() { | |
| fetch('https://api.netpie.io/topic/HelloCMMC/gearname/thing2?auth=PK7fUciCu1ocVPE:r2LOK4ambsj5H2eEEkBZ3vhyc', { | |
| method: 'PUT', | |
| body: 'ON' | |
| }); | |
| } | |
| render() { | |
| return ( | |
| <View style={styles.container}> | |
| <View style={styles.header}> | |
| <Text style={styles.labelState}>{ this.state.buzzer } </Text> | |
| </View> | |
| <View style={styles.body}> | |
| <TouchableOpacity onPress={this.detectON.bind(this)}> | |
| <View style={styles.layoutButtonON}> | |
| <Text style={styles.labelButton}>ON</Text> | |
| </View> | |
| </TouchableOpacity> | |
| </View> | |
| </View> | |
| ); | |
| } | |
| } | |
| const styles = StyleSheet.create({ | |
| container: { | |
| flex: 1, | |
| flexDirection: 'column', | |
| backgroundColor: '#F5FCFF', | |
| }, | |
| header: { | |
| flex: 5, | |
| //backgroundColor: 'red', | |
| justifyContent: 'center', | |
| alignItems: 'center' | |
| }, | |
| body: { | |
| flex: 5, | |
| flexDirection: 'row', | |
| //backgroundColor: 'blue', | |
| justifyContent: 'space-around', | |
| alignItems: 'center' | |
| }, | |
| labelState: { | |
| fontSize: 40, | |
| fontWeight: '100' | |
| }, | |
| labelButton: { | |
| color: 'white', | |
| fontSize: 30, | |
| fontWeight: '100' | |
| }, | |
| layoutButtonON: { | |
| backgroundColor: 'cornflowerblue', | |
| paddingTop: 20, | |
| paddingLeft: 50, | |
| paddingRight: 50, | |
| paddingBottom: 20, | |
| borderRadius: 10 | |
| } | |
| }); | |
| AppRegistry.registerComponent('App', () => App); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment