Browse Source

Initial commit client

dmr1725 4 years ago
parent
commit
e2fb54358a

+ 4
- 0
client/.expo-shared/assets.json View File

@@ -0,0 +1,4 @@
1
+{
2
+  "12bb71342c6255bbf50437ec8f4441c083f47cdb74bd89160c15e4f43e52a1cb": true,
3
+  "40b842e832070c58deac6aa9e08fa459302ee3f9da492c7e77d93d2fbf4a56fd": true
4
+}

+ 13
- 0
client/.gitignore View File

@@ -0,0 +1,13 @@
1
+node_modules/**/*
2
+.expo/*
3
+npm-debug.*
4
+*.jks
5
+*.p8
6
+*.p12
7
+*.key
8
+*.mobileprovision
9
+*.orig.*
10
+web-build/
11
+
12
+# macOS
13
+.DS_Store

+ 91
- 0
client/App.js View File

@@ -0,0 +1,91 @@
1
+import { StatusBar } from 'expo-status-bar';
2
+import React, {useState} from 'react';
3
+import { StyleSheet, Text, View } from 'react-native';
4
+import * as Google from "expo-google-app-auth";
5
+import {SocialIcon, socialIcon} from 'react-native-elements'
6
+import {createDrawerNavigator} from '@react-navigation/drawer'
7
+import { NavigationContainer } from '@react-navigation/native';
8
+import * as SecureStore from 'expo-secure-store';
9
+
10
+import HomeScreen from './Screens/HomeScreen'
11
+import NotificationsScreen from './Screens/NotificationScreen'
12
+import SettingScreen from './Screens/SettingScreen'
13
+import AddTakenCourses from './Screens/AddTakenCourses'
14
+
15
+const Drawer = createDrawerNavigator()
16
+
17
+const IOS_CLIENT_ID =
18
+  "116415331974-tf6sehooctplmmn7j0gt831mdf1oqipl.apps.googleusercontent.com";
19
+
20
+export default function App() {
21
+  const [hasToken, setHasToken] = useState(false)
22
+  
23
+  const signInWithGoogle = async ()=>{
24
+    try {
25
+      const result = await Google.logInAsync({
26
+        iosClientId: IOS_CLIENT_ID,
27
+        scopes: ["profile", "email"]
28
+      })
29
+
30
+      if (result.type == "success"){
31
+        console.log(result.accessToken)
32
+
33
+        // try {
34
+        //   let response = await fetch('http://619835f05c38.ngrok.io/rest-auth/google/', {
35
+        //     method: 'POST',
36
+        //     headers: {
37
+        //       'content-type': 'application/json'
38
+        //     }, 
39
+        //     body: JSON.stringify({
40
+        //       access_token: `${result.accessToken}`
41
+        //     })
42
+        //   })
43
+        //   let responseJson = await response.json()
44
+        //   if (responseJson){
45
+        //     if (responseJson.key){
46
+        //       await SecureStore.setItemAsync('token', responseJson.key)
47
+        //     }
48
+        //   }
49
+
50
+        // } catch(error){
51
+        //   console.log(error)
52
+        // }
53
+        setHasToken(true) // update states and redirect
54
+      }
55
+
56
+      else {
57
+        console.log("no")
58
+      }
59
+    } catch(error){
60
+      console.log(error)
61
+    }
62
+  }
63
+  if (!hasToken){
64
+    return (
65
+      <View style={styles.container}>
66
+        <SocialIcon title="Login With Google" button={true} type={"google"} onPress={signInWithGoogle}/>
67
+      </View>
68
+    );
69
+  }
70
+  console.log(hasToken)
71
+  return (
72
+    <NavigationContainer>
73
+        <Drawer.Navigator initialRouteName="Home">
74
+          <Drawer.Screen name="Home" component={HomeScreen}/>
75
+          <Drawer.Screen name="Notifications" component={NotificationsScreen} />
76
+          <Drawer.Screen name="Settings" component={SettingScreen} />
77
+          <Drawer.Screen name="Add Taken Courses" component={AddTakenCourses} />
78
+        </Drawer.Navigator>
79
+    </NavigationContainer>
80
+  )
81
+  
82
+}
83
+
84
+const styles = StyleSheet.create({
85
+  container: {
86
+    flex: 1,
87
+    backgroundColor: '#fff',
88
+    alignItems: 'center',
89
+    justifyContent: 'center',
90
+  },
91
+});

+ 82
- 0
client/Screens/AddTakenCourses.js View File

@@ -0,0 +1,82 @@
1
+import React, { Component } from "react";
2
+import { Text, View, StyleSheet, Button, ScrollView, Picker, TextInput } from "react-native";
3
+
4
+
5
+export default class SettingScreen extends Component {
6
+    state = {
7
+        faculty: "naturales"
8
+
9
+    }
10
+    render() {
11
+
12
+        return(
13
+
14
+
15
+            <View style={styles.container}>
16
+                <View style={{alignItems: "center", backgroundColor: 'red', marginTop: 30, marginBottom: 150}}>
17
+                    <Text style= {{fontSize: 20, fontWeight: "bold"}}> Add Taken </Text>
18
+                    <Text style= {{fontSize: 20, fontWeight: "bold"}}>Course{/*{this.props.navigation.getParam("username")} */}</Text>
19
+
20
+                </View>
21
+
22
+                <View style={{alignItems: "flex-start", backgroundColor: 'white', flex:0}}>
23
+                <Button
24
+                    title="<Back"
25
+                    onPress= {() => this.props.navigation.navigate("Profile")}
26
+                    /> 
27
+                </View>
28
+
29
+                <View style={{alignItems: "flex-start",backgroundColor: 'white', flex:0}}>
30
+                    <Text style={{ fontSize: 20}}> Course: </Text>
31
+                    <TextInput style= {{borderColor: "black", borderWidth: 2, width: 100}}>
32
+                    </TextInput>
33
+                    
34
+                    <Text style={{ fontSize: 20}}> Section: </Text>
35
+                    <TextInput style= {{borderColor: "black", borderWidth: 2, width: 100}}>
36
+                    </TextInput>
37
+
38
+                    <Text style={{ fontSize: 20}}> Semester#: </Text>
39
+                    <TextInput style= {{borderColor: "black", borderWidth: 2, width: 100}}>
40
+                    </TextInput>
41
+
42
+                    <Text style={{ fontSize: 20}}> Professor: </Text>
43
+                    <TextInput style= {{borderColor: "black", borderWidth: 2, width: 250}}>
44
+                    </TextInput>
45
+                </View>
46
+
47
+                <View style={{alignItems: "flex-end", backgroundColor: 'white', marginTop: 50, marginBottom: 250}}> 
48
+                <Text style={{ fontSize: 20, fontWeight: "bold" , height:30 }}> Grade: </Text>
49
+                    <Picker
50
+                    selectedValue={this.state.faculty}
51
+                    style={{ height: 0, width: 40}}
52
+                    onValueChange={(itemValue, itemIndex) =>
53
+                    this.setState({ faculty: itemValue })}>
54
+                        <Picker.Item label="A" value="001" />
55
+                        <Picker.Item label="B" value="002" />
56
+                        <Picker.Item label="C" value="003" />
57
+                        <Picker.Item label="D" value="004" />
58
+                        <Picker.Item label="F" value="005" />
59
+                        <Picker.Item label="PS" value="006" />
60
+                        <Picker.Item label="NP" value="007" />
61
+                    </Picker>
62
+                </View>
63
+                    <Button
64
+                        title="Submit Taken Course"
65
+                        onPress={null}
66
+                    /> 
67
+            </View>
68
+            
69
+        );
70
+    }
71
+}
72
+
73
+
74
+const styles = StyleSheet.create({
75
+  container: {
76
+    flex: 1,
77
+    justifyContent: "center"
78
+  }
79
+  
80
+
81
+});
82
+

+ 27
- 0
client/Screens/HomeScreen.js View File

@@ -0,0 +1,27 @@
1
+import * as React from 'react';
2
+import { Button, View } from 'react-native';
3
+import * as SecureStore from 'expo-secure-store';
4
+
5
+
6
+function HomeScreen({ navigation }) {
7
+  const credentials = async ()=>{
8
+    const response = await SecureStore.getItemAsync('token')
9
+    console.log(response)
10
+  }
11
+    return (
12
+      <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
13
+        <Button
14
+          onPress={() => navigation.navigate('Notifications')}
15
+          title="Go to notifications"
16
+        />
17
+        <Button
18
+          onPress={credentials}
19
+          title="Prueba"
20
+        />
21
+      </View>
22
+    );
23
+}
24
+
25
+export default HomeScreen
26
+
27
+

+ 12
- 0
client/Screens/NotificationScreen.js View File

@@ -0,0 +1,12 @@
1
+import * as React from 'react';
2
+import { Button, View } from 'react-native';
3
+
4
+function NotificationsScreen({ navigation }) {
5
+  return (
6
+    <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
7
+      <Button onPress={() => navigation.goBack()} title="Go back home" />
8
+    </View>
9
+  );
10
+}
11
+
12
+export default NotificationsScreen

+ 53
- 0
client/Screens/ProfileScreen.js View File

@@ -0,0 +1,53 @@
1
+import React, { Component } from "react";
2
+import { Text, View, StyleSheet, Button } from "react-native";
3
+
4
+export default class ProfileScreen extends Component {
5
+  prueba = async()=>{
6
+    let response = await fetch('http://05cb04aa6bc5.ngrok.io/api/hello',{
7
+      method: 'GET',
8
+      headers: {
9
+        Authorization: 'Token c33cc0e20cdf09a12d1e3e3de2515f3e9f2fd008'
10
+      }
11
+    })
12
+    let responseJson = await response.json()
13
+    console.log(responseJson)
14
+  }
15
+  render() {
16
+    return (
17
+      <View style={styles.container}>
18
+        <Text> Profile Screen </Text>
19
+        <Text style={{ fontSize: 20, fontWeight: "bold" }}>
20
+          Welcome, {this.props.navigation.getParam("username")}
21
+        </Text>
22
+        <Button
23
+          title="Sign out"
24
+          onPress={() => this.props.navigation.navigate("Login")}
25
+        />
26
+        <Button
27
+          title="Test"
28
+          onPress={this.prueba}
29
+        />
30
+
31
+        <Button
32
+          title="Add Taken Course"
33
+          onPress= {() => this.props.navigation.navigate("AddTakenCourse")}
34
+        />
35
+
36
+        <Button
37
+          title="Settings"
38
+          onPress= {() => this.props.navigation.navigate("Settings")}
39
+        />
40
+        
41
+      </View>
42
+    );
43
+  }
44
+}
45
+
46
+const styles = StyleSheet.create({
47
+  container: {
48
+    flex: 1,
49
+    backgroundColor: "#fff",
50
+    alignItems: "center",
51
+    justifyContent: "center"
52
+  }
53
+});

+ 87
- 0
client/Screens/SettingScreen.js View File

@@ -0,0 +1,87 @@
1
+import React, { Component } from "react";
2
+import { Text, View, StyleSheet, Button, ScrollView, Picker, TextInput } from "react-native";
3
+
4
+
5
+export default class SettingScreen extends Component {
6
+    state = {
7
+        faculty: "naturales"
8
+
9
+    }
10
+    render() {
11
+
12
+        return(
13
+
14
+
15
+            <View style={styles.container}>
16
+                <View style={{alignItems: "center", backgroundColor: 'red', marginTop: 30, marginBottom: 150}}>
17
+                    <Text style= {{fontSize: 20, fontWeight: "bold"}}> Profile Settings </Text>
18
+            
19
+                </View>
20
+
21
+                <View style={{alignItems: "flex-start", backgroundColor: 'Silver', flex:0}}>
22
+                <Button
23
+                    title="<Back"
24
+                    onPress= {() => this.props.navigation.navigate("Profile")}
25
+                    /> 
26
+                </View>
27
+
28
+                <View style={{alignItems: "center",backgroundColor: 'white', flex:0}}>
29
+                    <Text style={{ fontSize: 20}}> Name: </Text>
30
+                    <TextInput style= {{borderColor: "black", borderWidth: 2, width: 250}}>
31
+                    </TextInput>
32
+                    <Button
33
+                        title="Update Name"
34
+                        onPress={this.prueba}
35
+                        />
36
+                    <Text style={{ fontSize: 20}}> Email: </Text>
37
+                    <TextInput style= {{borderColor: "black", borderWidth: 2, width: 250}}>
38
+                    </TextInput>
39
+                    <Button
40
+                        title="Update Email"
41
+                        onPress={this.prueba}
42
+                    /> 
43
+
44
+                    <Text style={{ fontSize: 20}}> Student ID: </Text>
45
+                    <TextInput style= {{borderColor: "black", borderWidth: 2, width: 250}}>
46
+                    </TextInput>
47
+                    <Button
48
+                        title="Update Student ID"
49
+                        onPress={this.prueba}
50
+                    /> 
51
+                </View>
52
+
53
+                <View style={{alignItems: "center", backgroundColor: 'red', marginTop: 50, marginBottom: 300}}> 
54
+                <Text style={{ fontSize: 20, fontWeight: "bold" , height:30 }}> Faculty </Text>
55
+
56
+                    <Picker
57
+                        selectedValue={this.state.faculty}
58
+                        style={{ height: 0, width: 1000}}
59
+                        onValueChange={(itemValue, itemIndex) =>
60
+                        this.setState({ faculty: itemValue })
61
+                        }>
62
+                        
63
+                        <Picker.Item label="Administración de Empresas" value="001" />
64
+                        <Picker.Item label="Arquitectura" value="002" />
65
+                        <Picker.Item label="Ciencias Naturales" value="003" />
66
+                        <Picker.Item label="Ciencias Sociales" value="004" />
67
+                        <Picker.Item label="Educación" value="005" />
68
+                        <Picker.Item label="Bellas Artes" value="006" />
69
+                        <Picker.Item label="Communicaciones" value="007" />
70
+                    </Picker>
71
+                </View>
72
+        </View>
73
+            
74
+        );
75
+    }
76
+}
77
+
78
+
79
+const styles = StyleSheet.create({
80
+  container: {
81
+    flex: 1,
82
+    justifyContent: "center"
83
+  }
84
+  
85
+
86
+});
87
+

+ 33
- 0
client/app.json View File

@@ -0,0 +1,33 @@
1
+{
2
+  "expo": {
3
+    "name": "native_google",
4
+    "slug": "native_google",
5
+    "version": "1.0.0",
6
+    "orientation": "portrait",
7
+    "icon": "./assets/icon.png",
8
+    "splash": {
9
+      "image": "./assets/splash.png",
10
+      "resizeMode": "contain",
11
+      "backgroundColor": "#ffffff"
12
+    },
13
+    "updates": {
14
+      "fallbackToCacheTimeout": 0
15
+    },
16
+    "assetBundlePatterns": [
17
+      "**/*"
18
+    ],
19
+    "ios": {
20
+      "supportsTablet": true,
21
+      "bundleIdentifier": "com.webiosandroid.all",
22
+      "config":{
23
+        "googleSignIn":{
24
+          "reservedClientId": "com.googleusercontent.apps.116415331974-tf6sehooctplmmn7j0gt831mdf1oqipl"
25
+        }
26
+      }
27
+      
28
+    },
29
+    "web": {
30
+      "favicon": "./assets/favicon.png"
31
+    }
32
+  }
33
+}

BIN
client/assets/favicon.png View File


BIN
client/assets/icon.png View File


BIN
client/assets/splash.png View File


+ 6
- 0
client/babel.config.js View File

@@ -0,0 +1,6 @@
1
+module.exports = function(api) {
2
+  api.cache(true);
3
+  return {
4
+    presets: ['babel-preset-expo'],
5
+  };
6
+};

+ 3
- 0
client/debug.log View File

@@ -0,0 +1,3 @@
1
+[1026/183028.266:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
2
+[1027/212234.749:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
3
+[1111/110331.802:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)

+ 8024
- 0
client/package-lock.json
File diff suppressed because it is too large
View File


+ 33
- 0
client/package.json View File

@@ -0,0 +1,33 @@
1
+{
2
+  "main": "node_modules/expo/AppEntry.js",
3
+  "scripts": {
4
+    "start": "expo start",
5
+    "android": "expo start --android",
6
+    "ios": "expo start --ios",
7
+    "web": "expo start --web",
8
+    "eject": "expo eject"
9
+  },
10
+  "dependencies": {
11
+    "@react-native-community/masked-view": "0.1.10",
12
+    "@react-navigation/drawer": "^5.11.2",
13
+    "@react-navigation/native": "^5.8.9",
14
+    "@react-navigation/stack": "^5.12.6",
15
+    "expo": "~39.0.2",
16
+    "expo-google-app-auth": "^8.1.3",
17
+    "expo-secure-store": "~9.2.0",
18
+    "expo-status-bar": "~1.0.2",
19
+    "react": "16.13.1",
20
+    "react-dom": "16.13.1",
21
+    "react-native": "https://github.com/expo/react-native/archive/sdk-39.0.4.tar.gz",
22
+    "react-native-elements": "^3.0.0-alpha.1",
23
+    "react-native-gesture-handler": "~1.7.0",
24
+    "react-native-reanimated": "~1.13.0",
25
+    "react-native-safe-area-context": "3.1.4",
26
+    "react-native-screens": "~2.10.1",
27
+    "react-native-web": "~0.13.12"
28
+  },
29
+  "devDependencies": {
30
+    "@babel/core": "~7.9.0"
31
+  },
32
+  "private": true
33
+}