Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from 'react';
- import { StyleSheet, Text, View, Button, Alert, Image } from 'react-native';
- import { Speech, Audio, Location, Permissions } from 'expo';
- export default class App extends React.Component {
- _onPressAvancer = () => {
- fetch("http://192.168.1.145:2017/commande/1/5", {
- method: "GET",
- })
- .then((response) => response.json())
- .then((responseJson) => {
- console.log(responseJson);
- })
- .catch((error) => {
- console.error(error);
- });
- }
- _onPressReculer = () => {
- fetch("http://192.168.1.145:2017/commande/2/5", {
- method: "GET",
- })
- .then((response) => response.json())
- .then((responseJson) => {
- console.log(responseJson);
- })
- .catch((error) => {
- console.error(error);
- });
- }
- _onPressStop = () => {
- fetch("http://192.168.1.145:2017/commande/0/0", {
- method: "GET",
- })
- .then((response) => response.json())
- .then((responseJson) => {
- console.log(responseJson);
- })
- .catch((error) => {
- console.error(error);
- });
- }
- _onPressGauche = () => {
- fetch("http://192.168.1.145:2017/commande/3/0", {
- method: "GET",
- })
- .then((response) => response.json())
- .then((responseJson) => {
- console.log(responseJson);
- })
- .catch((error) => {
- console.error(error);
- });
- }
- _onPressDroite = () => {
- fetch("http://192.168.1.145:2017/commande/4/0", {
- method: "GET",
- })
- .then((response) => response.json())
- .then((responseJson) => {
- console.log(responseJson);
- })
- .catch((error) => {
- console.error(error);
- });
- }
- render() {
- return (
- <View style={styles.container}>
- <Button
- onPress={ this._onPressAvancer }
- title="Avancer"
- />
- <Button
- onPress={ this._onPressReculer }
- title="Reculer"
- />
- <Button
- onPress={ this._onPressStop }
- title="Stop"
- />
- <Button
- onPress={ this._onPressStop }
- title="TournerGauche"
- />
- <Button
- onPress={ this._onPressStop }
- title="TournerDroite"
- />
- </View>
- );
- }
- }
- const styles = StyleSheet.create({
- container: {
- flex: 1,
- backgroundColor: '#ccccb3',
- alignItems: 'center',
- justifyContent: 'center',
- },
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement