-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathApp.js
132 lines (122 loc) · 3.95 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import React, { useState, useEffect } from 'react';
import { StyleSheet } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { StatusBar } from 'expo-status-bar';
import * as Font from 'expo-font';
import * as SplashScreen from 'expo-splash-screen';
import * as FileSystem from 'expo-file-system';
import { getDatabase, ref, onValue, set, query } from 'firebase/database';
import { db } from './src/firebase/config';
import AsyncStorage from '@react-native-async-storage/async-storage';
import KakaoLogin from './src/Components/KakaoLogin';
import LoginPage from './src/Screen/LoginPage';
import Main from './src/Screen/Main';
import AIPage from './src/Screen/AIPage';
import TextPage from './src/Screen/TextPage';
import InformationPage from './src/Screen/InformationPage';
import NotePage from './src/Screen/Note';
import FolderPage from './src/Screen/FolderPage';
import { getData } from './src/Functions/DataFunction';
const Stack = createNativeStackNavigator();
const STORAGE_KEY = '@login_id';
SplashScreen.preventAutoHideAsync();
export default function App() {
const [appIsReady, setAppIsReady] = useState(false);
const [userId, setUserId] = useState();
// 폰트 불러오는 작업 실행 , 실행 완료시 스플래시 스크린 종료
useEffect(() => {
async function prepare() {
try {
await Font.loadAsync({
'SUITE-Light': require('./assets/fonts/SUITE-Light.otf'),
'SUITE-Medium': require('./assets/fonts/SUITE-Medium.otf'),
IropkeBatangM: require('./assets/fonts/IropkeBatangM.otf'),
});
userLoad();
await new Promise((resolve) => setTimeout(resolve, 2000));
} catch (e) {
console.warn(e);
} finally {
setAppIsReady(true);
}
}
prepare();
}, []);
useEffect(() => {
console.log('[App.js] userId', userId);
getData(userId);
}, [userId]);
useEffect(() => {
if (appIsReady) {
console.log('[App.js] prepare is OK');
SplashScreen.hideAsync();
}
}, [appIsReady]);
async function userLoad() {
setUserId(await AsyncStorage.getItem(STORAGE_KEY));
}
if (appIsReady) {
return (
<NavigationContainer>
<Stack.Navigator initialRouteName="Login">
<Stack.Screen
name="Login"
component={LoginPage}
options={{
headerShown: false, // 상단에 흰색 바가 생기고 HOME이라는 글씨가 쓰여있는데 그거 안 보이게 하는 속성
}}
/>
<Stack.Screen
name="Main_Home"
component={Main}
options={{
gestureEnabled: false,
headerShown: false,
}}
/>
<Stack.Screen
name="AI"
component={AIPage}
options={{
gestureEnabled: false,
headerShown: false,
}}
/>
<Stack.Screen
name="TextInput"
component={TextPage}
options={{ headerShown: false }}
/>
<Stack.Screen
name="KakaoLogin"
component={KakaoLogin}
options={{ headerShown: false }}
/>
<Stack.Screen
name="Information"
component={InformationPage}
options={{ headerShown: false }}
/>
<Stack.Screen
name="Folder"
component={FolderPage}
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="Note"
component={NotePage}
options={{
headerShown: false,
}}
/>
</Stack.Navigator>
<StatusBar style="auto" />
</NavigationContainer>
);
}
}
const styles = StyleSheet.create({});