|
@@ -1,123 +1,3 @@
|
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 AddTakenCourse from './Screens/AddTakenCourse'
|
14
|
|
-// import MyCurriculum from './Screens/MyCurriculum'
|
15
|
|
-// import EnrollNextSemester from './Screens/EnrollNextSemester'
|
16
|
|
-
|
17
|
|
-
|
18
|
|
-// const Drawer = createDrawerNavigator()
|
19
|
|
-
|
20
|
|
-// const IOS_CLIENT_ID =
|
21
|
|
-// "116415331974-tf6sehooctplmmn7j0gt831mdf1oqipl.apps.googleusercontent.com";
|
22
|
|
-
|
23
|
|
-// export default function App() {
|
24
|
|
-// const [hasToken, setHasToken] = useState(false)
|
25
|
|
-
|
26
|
|
-// const signInWithGoogle = async ()=>{
|
27
|
|
-// try {
|
28
|
|
-// const result = await Google.logInAsync({
|
29
|
|
-// iosClientId: IOS_CLIENT_ID,
|
30
|
|
-// scopes: ["profile", "email"]
|
31
|
|
-// })
|
32
|
|
-
|
33
|
|
-// if (result.type == "success"){
|
34
|
|
-// console.log(result.accessToken)
|
35
|
|
-
|
36
|
|
-// try {
|
37
|
|
-// // login user in backend
|
38
|
|
-// let response = await fetch('http://5ce95b6ddcbd.ngrok.io/rest-auth/google/', {
|
39
|
|
-// method: 'POST',
|
40
|
|
-// headers: {
|
41
|
|
-// 'content-type': 'application/json'
|
42
|
|
-// },
|
43
|
|
-// body: JSON.stringify({
|
44
|
|
-// access_token: `${result.accessToken}`
|
45
|
|
-// })
|
46
|
|
-// })
|
47
|
|
-
|
48
|
|
-// // storing our token
|
49
|
|
-// let responseJson = await response.json()
|
50
|
|
-// if (responseJson){
|
51
|
|
-// if (responseJson.key){
|
52
|
|
-// await SecureStore.setItemAsync('token', responseJson.key)
|
53
|
|
-// }
|
54
|
|
-// }
|
55
|
|
-
|
56
|
|
-// const token = await SecureStore.getItemAsync('token')
|
57
|
|
-
|
58
|
|
-// // storing our id
|
59
|
|
-// let id = await fetch('http://5ce95b6ddcbd.ngrok.io/api/get_user_id', {
|
60
|
|
-// method: 'GET',
|
61
|
|
-// headers: {
|
62
|
|
-// 'content-type': 'application/json',
|
63
|
|
-// Authorization: `Token ${token}`
|
64
|
|
-// }
|
65
|
|
-// })
|
66
|
|
-// let idJson = await id.json()
|
67
|
|
-// if (idJson){
|
68
|
|
-// if(idJson.user_id){
|
69
|
|
-// idJson = idJson.user_id
|
70
|
|
-// let id = idJson.toString()
|
71
|
|
-// await SecureStore.setItemAsync('id', id)
|
72
|
|
-// }
|
73
|
|
-// }
|
74
|
|
-
|
75
|
|
-// } catch(error){
|
76
|
|
-// console.log(error)
|
77
|
|
-// }
|
78
|
|
-
|
79
|
|
-// setHasToken(true) // update states and redirect
|
80
|
|
-// }
|
81
|
|
-
|
82
|
|
-// else {
|
83
|
|
-// console.log("no")
|
84
|
|
-// }
|
85
|
|
-// } catch(error){
|
86
|
|
-// console.log(error)
|
87
|
|
-// }
|
88
|
|
-// }
|
89
|
|
-// if (!hasToken){
|
90
|
|
-// return (
|
91
|
|
-// <View style={styles.container}>
|
92
|
|
-// <SocialIcon title="Login With Google" button={true} type={"google"} onPress={signInWithGoogle}/>
|
93
|
|
-// </View>
|
94
|
|
-// );
|
95
|
|
-// }
|
96
|
|
-
|
97
|
|
-// return (
|
98
|
|
-// <NavigationContainer>
|
99
|
|
-// <Drawer.Navigator initialRouteName="Home">
|
100
|
|
-// <Drawer.Screen name="Home" component={HomeScreen}/>
|
101
|
|
-// <Drawer.Screen name="Notifications" component={NotificationsScreen} />
|
102
|
|
-// <Drawer.Screen name="Settings" component={SettingScreen} />
|
103
|
|
-// <Drawer.Screen name="Add Taken Courses" component={AddTakenCourse} />
|
104
|
|
-// <Drawer.Screen name="My Curriculum" component={MyCurriculum} />
|
105
|
|
-// <Drawer.Screen name="Enroll Next Semester" component={EnrollNextSemester} />
|
106
|
|
-
|
107
|
|
-// </Drawer.Navigator>
|
108
|
|
-// </NavigationContainer>
|
109
|
|
-// )
|
110
|
|
-
|
111
|
|
-// }
|
112
|
|
-
|
113
|
|
-// const styles = StyleSheet.create({
|
114
|
|
-// container: {
|
115
|
|
-// flex: 1,
|
116
|
|
-// backgroundColor: '#fff',
|
117
|
|
-// alignItems: 'center',
|
118
|
|
-// justifyContent: 'center',
|
119
|
|
-// },
|
120
|
|
-// });
|
121
|
1
|
import { StatusBar } from 'expo-status-bar';
|
122
|
2
|
import React, {useState} from 'react';
|
123
|
3
|
import { StyleSheet, Text, View } from 'react-native';
|