Explorar el Código

added smooth-code-input again

Ricardo-gonzalez32 hace 2 años
padre
commit
3204a4a7ba

+ 32
- 0
MocionesIUPI/package-lock.json Ver fichero

@@ -10,6 +10,7 @@
10 10
       "dependencies": {
11 11
         "@apollo/client": "^3.7.2",
12 12
         "@expo/webpack-config": "^0.17.2",
13
+        "deprecated-react-native-prop-types": "^2.2.0",
13 14
         "expo": "~47.0.6",
14 15
         "expo-status-bar": "~1.4.2",
15 16
         "graphql": "^15.8.0",
@@ -21,6 +22,7 @@
21 22
         "react-native-paper": "^3.12.0",
22 23
         "react-native-safe-area-context": "4.4.1",
23 24
         "react-native-screens": "~3.18.0",
25
+        "react-native-smooth-pincode-input": "^1.0.9",
24 26
         "react-native-svg": "^13.4.0",
25 27
         "react-native-vector-icons": "^9.2.0",
26 28
         "react-native-web": "~0.18.9",
@@ -8900,6 +8902,16 @@
8900 8902
         "node": ">= 0.6"
8901 8903
       }
8902 8904
     },
8905
+    "node_modules/deprecated-react-native-prop-types": {
8906
+      "version": "2.2.0",
8907
+      "resolved": "https://registry.npmjs.org/deprecated-react-native-prop-types/-/deprecated-react-native-prop-types-2.2.0.tgz",
8908
+      "integrity": "sha512-SiessglRbgelU8sHCrGRImdlNKfVGSp0n6+K304d0rCdHGU8wladJkPmufxE2AkjN2jy71sgekNd9IvdZp9jZg==",
8909
+      "dependencies": {
8910
+        "@react-native/normalize-color": "*",
8911
+        "invariant": "*",
8912
+        "prop-types": "*"
8913
+      }
8914
+    },
8903 8915
     "node_modules/des.js": {
8904 8916
       "version": "1.0.1",
8905 8917
       "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.1.tgz",
@@ -16863,6 +16875,14 @@
16863 16875
         "react": "18.1.0"
16864 16876
       }
16865 16877
     },
16878
+    "node_modules/react-native-animatable": {
16879
+      "version": "1.3.3",
16880
+      "resolved": "https://registry.npmjs.org/react-native-animatable/-/react-native-animatable-1.3.3.tgz",
16881
+      "integrity": "sha512-2ckIxZQAsvWn25Ho+DK3d1mXIgj7tITkrS4pYDvx96WyOttSvzzFeQnM2od0+FUMzILbdHDsDEqZvnz1DYNQ1w==",
16882
+      "dependencies": {
16883
+        "prop-types": "^15.7.2"
16884
+      }
16885
+    },
16866 16886
     "node_modules/react-native-codegen": {
16867 16887
       "version": "0.70.6",
16868 16888
       "resolved": "https://registry.npmjs.org/react-native-codegen/-/react-native-codegen-0.70.6.tgz",
@@ -16986,6 +17006,18 @@
16986 17006
         "react-native": "*"
16987 17007
       }
16988 17008
     },
17009
+    "node_modules/react-native-smooth-pincode-input": {
17010
+      "version": "1.0.9",
17011
+      "resolved": "https://registry.npmjs.org/react-native-smooth-pincode-input/-/react-native-smooth-pincode-input-1.0.9.tgz",
17012
+      "integrity": "sha512-4V4tyUGJaze55FHuJW/gYVOD3fc4Pd7cTIrv7liTRIXR49y09C2O3XqJUdgNR+UwTgLrTt/8L2lvEuEVUk3kig==",
17013
+      "dependencies": {
17014
+        "prop-types": "^15.5.10",
17015
+        "react-native-animatable": "^1.3.0"
17016
+      },
17017
+      "peerDependencies": {
17018
+        "react-native": "*"
17019
+      }
17020
+    },
16989 17021
     "node_modules/react-native-svg": {
16990 17022
       "version": "13.4.0",
16991 17023
       "resolved": "https://registry.npmjs.org/react-native-svg/-/react-native-svg-13.4.0.tgz",

+ 2
- 0
MocionesIUPI/package.json Ver fichero

@@ -11,6 +11,7 @@
11 11
   "dependencies": {
12 12
     "@apollo/client": "^3.7.2",
13 13
     "@expo/webpack-config": "^0.17.2",
14
+    "deprecated-react-native-prop-types": "^2.2.0",
14 15
     "expo": "~47.0.6",
15 16
     "expo-status-bar": "~1.4.2",
16 17
     "graphql": "^15.8.0",
@@ -22,6 +23,7 @@
22 23
     "react-native-paper": "^3.12.0",
23 24
     "react-native-safe-area-context": "4.4.1",
24 25
     "react-native-screens": "~3.18.0",
26
+    "react-native-smooth-pincode-input": "^1.0.9",
25 27
     "react-native-svg": "^13.4.0",
26 28
     "react-native-vector-icons": "^9.2.0",
27 29
     "react-native-web": "~0.18.9",

+ 7
- 3
MocionesIUPI/screens/HomeScreen.js Ver fichero

@@ -4,12 +4,13 @@ import { StyleSheet, View, Text, Button } from 'react-native';
4 4
 import { globalStyles } from "../styles/global";
5 5
 
6 6
 export default App = ({ navigation }) => {
7
-    const [PIN, setPIN] = useState([]); // this is looking for 'PIN' and it's content
7
+  {/*
8
+  const [PIN, setPIN] = useState([]); // this is looking for 'PIN' and it's content
8 9
   
9 10
     // this connects us to the API and fetches the json file with the mociones
10 11
     const getMociones = async () => {
11 12
        try {
12
-        const response = await fetch('http://10.190.1.140:5000/send?PIN=121071'); // connection to the website 
13
+        const response = await fetch('http://10.0.0.65:5000/send?PIN=894761'); // connection to the website 
13 14
         const json = await response.json();
14 15
   
15 16
         // setting the content of each category 
@@ -20,14 +21,17 @@ export default App = ({ navigation }) => {
20 21
       } 
21 22
       
22 23
     }
24
+    */}
23 25
 
24 26
     const pressHandler = () => {
25
-        navigation.navigate('Pinpage', {Pin:PIN});
27
+        navigation.navigate('Pinpage');
26 28
     }
27 29
     
30
+    {/*
28 31
     useEffect(() => {
29 32
         getMociones();
30 33
       }, []);
34
+    */}
31 35
 
32 36
     return (
33 37
         <View style = {globalStyles.container}>

+ 1
- 1
MocionesIUPI/screens/MocionScreen.js Ver fichero

@@ -10,7 +10,7 @@ export default App = () => {
10 10
   // this connects us to the API and fetches the json file with the mociones
11 11
   const getMociones = async () => {
12 12
      try {
13
-      const response = await fetch('http://10.190.1.140:5000/send?PIN=121071');
13
+      const response = await fetch('http://10.0.0.65:5000/send?PIN=894761');
14 14
       const json = await response.json();
15 15
       setMocion(json.Mocion);
16 16
       setDescription(json.Description);

+ 32
- 3
MocionesIUPI/screens/PincodeScreen.js Ver fichero

@@ -2,11 +2,35 @@ import React from "react";
2 2
 import { StyleSheet, View, Text, Button } from 'react-native';
3 3
 import { globalStyles } from "../styles/global";
4 4
 import SmoothPinCodeInput from 'react-native-smooth-pincode-input';
5
-
5
+import { useEffect, useState } from "react";
6 6
 
7 7
 
8 8
 
9 9
 export default class App extends React.Component {
10
+
11
+  
12
+    // this connects us to the API and fetches the json file with the mociones
13
+    getMociones = async (code) => {
14
+       try {
15
+        const response = await fetch(`http://10.0.0.65:5000/send?PIN=${code}`); // connection to the website 
16
+        const json = await response.json();
17
+        console.log(json);
18
+
19
+        // checks if the mocion exists
20
+        if (json == "Error: No hay mocion con ese PIN."){
21
+          alert("Error: No hay mocion con ese PIN.")
22
+        } else {
23
+          this.setState({ pincode: true});
24
+        }
25
+        
26
+  
27
+      } catch (error) {
28
+        console.error(error);
29
+      } 
30
+      
31
+    }
32
+    
33
+
10 34
     
11 35
     pressHandler = () => {
12 36
     {/*Dentro del parentesis va el path al screen para redirigir*/}
@@ -20,12 +44,17 @@ export default class App extends React.Component {
20 44
     pinInput = React.createRef();
21 45
   
22 46
     _checkCode = (code) => {
23
-      if (code != this.props.navigation.state.params.Pin) { //this is for recieving the parameters from another screen
47
+
48
+      this.getMociones(code);
49
+
50
+    {/*
51
+      if (code != 894761) { //this is for recieving the parameters from another screen
24 52
         this.pinInput.current.shake()
25 53
           .then(() => this.setState({ code: '' }));
26 54
       } else {
27 55
         this.setState({ pincode: true});
28 56
       }
57
+    */} 
29 58
     }
30 59
   
31 60
     render() {
@@ -41,7 +70,7 @@ export default class App extends React.Component {
41 70
               value={code}
42 71
               codeLength={6}
43 72
               onTextChange={code => this.setState({ code })}
44
-              onFulfill={this._checkCode}
73
+              onFulfill={this.getMociones}
45 74
               onBackspace={() => console.log('No more back.')}
46 75
               />
47 76
           </View>