Advertisement
toinou079

mobile

Oct 19th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react';
  2. import { StyleSheet, Text, View, Button, Alert, Image } from 'react-native';
  3. import { Speech, Audio, Location, Permissions } from 'expo';
  4.  
  5. export default class App extends React.Component {
  6.  
  7.  
  8.  
  9.         _onPressAvancer = () => {
  10.         fetch("http://192.168.1.145:2017/commande/1/5", {
  11.          method: "GET",
  12.         })
  13.         .then((response) => response.json())
  14.         .then((responseJson) => {
  15.             console.log(responseJson);
  16.         })
  17.         .catch((error) => {
  18.             console.error(error);
  19.         });
  20.     }
  21.         _onPressReculer = () => {
  22.         fetch("http://192.168.1.145:2017/commande/2/5", {
  23.          method: "GET",
  24.         })
  25.         .then((response) => response.json())
  26.         .then((responseJson) => {
  27.             console.log(responseJson);
  28.         })
  29.         .catch((error) => {
  30.             console.error(error);
  31.         });
  32.  
  33.     }
  34.         _onPressStop = () => {
  35.         fetch("http://192.168.1.145:2017/commande/0/0", {
  36.          method: "GET",
  37.         })
  38.         .then((response) => response.json())
  39.         .then((responseJson) => {
  40.             console.log(responseJson);
  41.         })
  42.         .catch((error) => {
  43.             console.error(error);
  44.         });
  45.  
  46.     }
  47.         _onPressGauche = () => {
  48.         fetch("http://192.168.1.145:2017/commande/3/0", {
  49.          method: "GET",
  50.         })
  51.         .then((response) => response.json())
  52.         .then((responseJson) => {
  53.             console.log(responseJson);
  54.         })
  55.         .catch((error) => {
  56.             console.error(error);
  57.         });
  58.  
  59.     }
  60.         _onPressDroite = () => {
  61.         fetch("http://192.168.1.145:2017/commande/4/0", {
  62.          method: "GET",
  63.         })
  64.         .then((response) => response.json())
  65.         .then((responseJson) => {
  66.             console.log(responseJson);
  67.         })
  68.         .catch((error) => {
  69.             console.error(error);
  70.         });
  71.  
  72.     }
  73.  
  74.  
  75.   render() {
  76.  
  77.  
  78.     return (
  79.       <View style={styles.container}>
  80.         <Button
  81.             onPress={ this._onPressAvancer }
  82.             title="Avancer"
  83.          />
  84.         <Button
  85.             onPress={ this._onPressReculer }
  86.             title="Reculer"
  87.          />
  88.         <Button
  89.             onPress={ this._onPressStop }
  90.             title="Stop"
  91.          />
  92.         <Button
  93.             onPress={ this._onPressStop }
  94.             title="TournerGauche"
  95.          />
  96.         <Button
  97.             onPress={ this._onPressStop }
  98.             title="TournerDroite"
  99.          />
  100.  
  101.  
  102.       </View>
  103.     );
  104.   }
  105. }
  106.  
  107. const styles = StyleSheet.create({
  108.   container: {
  109.     flex: 1,
  110.     backgroundColor: '#ccccb3',
  111.     alignItems: 'center',
  112.     justifyContent: 'center',
  113.   },
  114. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement