Переглянути джерело

added smooth-code-input again

Ricardo-gonzalez32 2 роки тому
джерело
коміт
3204a4a7ba

+ 32
- 0
MocionesIUPI/package-lock.json Переглянути файл

10
       "dependencies": {
10
       "dependencies": {
11
         "@apollo/client": "^3.7.2",
11
         "@apollo/client": "^3.7.2",
12
         "@expo/webpack-config": "^0.17.2",
12
         "@expo/webpack-config": "^0.17.2",
13
+        "deprecated-react-native-prop-types": "^2.2.0",
13
         "expo": "~47.0.6",
14
         "expo": "~47.0.6",
14
         "expo-status-bar": "~1.4.2",
15
         "expo-status-bar": "~1.4.2",
15
         "graphql": "^15.8.0",
16
         "graphql": "^15.8.0",
21
         "react-native-paper": "^3.12.0",
22
         "react-native-paper": "^3.12.0",
22
         "react-native-safe-area-context": "4.4.1",
23
         "react-native-safe-area-context": "4.4.1",
23
         "react-native-screens": "~3.18.0",
24
         "react-native-screens": "~3.18.0",
25
+        "react-native-smooth-pincode-input": "^1.0.9",
24
         "react-native-svg": "^13.4.0",
26
         "react-native-svg": "^13.4.0",
25
         "react-native-vector-icons": "^9.2.0",
27
         "react-native-vector-icons": "^9.2.0",
26
         "react-native-web": "~0.18.9",
28
         "react-native-web": "~0.18.9",
8900
         "node": ">= 0.6"
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
     "node_modules/des.js": {
8915
     "node_modules/des.js": {
8904
       "version": "1.0.1",
8916
       "version": "1.0.1",
8905
       "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.1.tgz",
8917
       "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.1.tgz",
16863
         "react": "18.1.0"
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
     "node_modules/react-native-codegen": {
16886
     "node_modules/react-native-codegen": {
16867
       "version": "0.70.6",
16887
       "version": "0.70.6",
16868
       "resolved": "https://registry.npmjs.org/react-native-codegen/-/react-native-codegen-0.70.6.tgz",
16888
       "resolved": "https://registry.npmjs.org/react-native-codegen/-/react-native-codegen-0.70.6.tgz",
16986
         "react-native": "*"
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
     "node_modules/react-native-svg": {
17021
     "node_modules/react-native-svg": {
16990
       "version": "13.4.0",
17022
       "version": "13.4.0",
16991
       "resolved": "https://registry.npmjs.org/react-native-svg/-/react-native-svg-13.4.0.tgz",
17023
       "resolved": "https://registry.npmjs.org/react-native-svg/-/react-native-svg-13.4.0.tgz",

+ 2
- 0
MocionesIUPI/package.json Переглянути файл

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

+ 7
- 3
MocionesIUPI/screens/HomeScreen.js Переглянути файл

4
 import { globalStyles } from "../styles/global";
4
 import { globalStyles } from "../styles/global";
5
 
5
 
6
 export default App = ({ navigation }) => {
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
     // this connects us to the API and fetches the json file with the mociones
10
     // this connects us to the API and fetches the json file with the mociones
10
     const getMociones = async () => {
11
     const getMociones = async () => {
11
        try {
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
         const json = await response.json();
14
         const json = await response.json();
14
   
15
   
15
         // setting the content of each category 
16
         // setting the content of each category 
20
       } 
21
       } 
21
       
22
       
22
     }
23
     }
24
+    */}
23
 
25
 
24
     const pressHandler = () => {
26
     const pressHandler = () => {
25
-        navigation.navigate('Pinpage', {Pin:PIN});
27
+        navigation.navigate('Pinpage');
26
     }
28
     }
27
     
29
     
30
+    {/*
28
     useEffect(() => {
31
     useEffect(() => {
29
         getMociones();
32
         getMociones();
30
       }, []);
33
       }, []);
34
+    */}
31
 
35
 
32
     return (
36
     return (
33
         <View style = {globalStyles.container}>
37
         <View style = {globalStyles.container}>

+ 1
- 1
MocionesIUPI/screens/MocionScreen.js Переглянути файл

10
   // this connects us to the API and fetches the json file with the mociones
10
   // this connects us to the API and fetches the json file with the mociones
11
   const getMociones = async () => {
11
   const getMociones = async () => {
12
      try {
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
       const json = await response.json();
14
       const json = await response.json();
15
       setMocion(json.Mocion);
15
       setMocion(json.Mocion);
16
       setDescription(json.Description);
16
       setDescription(json.Description);

+ 32
- 3
MocionesIUPI/screens/PincodeScreen.js Переглянути файл

2
 import { StyleSheet, View, Text, Button } from 'react-native';
2
 import { StyleSheet, View, Text, Button } from 'react-native';
3
 import { globalStyles } from "../styles/global";
3
 import { globalStyles } from "../styles/global";
4
 import SmoothPinCodeInput from 'react-native-smooth-pincode-input';
4
 import SmoothPinCodeInput from 'react-native-smooth-pincode-input';
5
-
5
+import { useEffect, useState } from "react";
6
 
6
 
7
 
7
 
8
 
8
 
9
 export default class App extends React.Component {
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
     pressHandler = () => {
35
     pressHandler = () => {
12
     {/*Dentro del parentesis va el path al screen para redirigir*/}
36
     {/*Dentro del parentesis va el path al screen para redirigir*/}
20
     pinInput = React.createRef();
44
     pinInput = React.createRef();
21
   
45
   
22
     _checkCode = (code) => {
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
         this.pinInput.current.shake()
52
         this.pinInput.current.shake()
25
           .then(() => this.setState({ code: '' }));
53
           .then(() => this.setState({ code: '' }));
26
       } else {
54
       } else {
27
         this.setState({ pincode: true});
55
         this.setState({ pincode: true});
28
       }
56
       }
57
+    */} 
29
     }
58
     }
30
   
59
   
31
     render() {
60
     render() {
41
               value={code}
70
               value={code}
42
               codeLength={6}
71
               codeLength={6}
43
               onTextChange={code => this.setState({ code })}
72
               onTextChange={code => this.setState({ code })}
44
-              onFulfill={this._checkCode}
73
+              onFulfill={this.getMociones}
45
               onBackspace={() => console.log('No more back.')}
74
               onBackspace={() => console.log('No more back.')}
46
               />
75
               />
47
           </View>
76
           </View>