forked from KookminNA/KookminNA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
106 lines (92 loc) · 3.54 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
import React, { createContext, useContext, useEffect, useState } from 'react';
import {SearchPage, InformPage} from './src/page';
import NameSearch from './src/component/Search/NameSearch.js';
import CalendarView from './src/component/CalendarView';
import InformTable from './src/component/InformTable';
import "react-native-gesture-handler";
import { NavigationContainer, StackRouter } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import * as api from './src/api/server.js';
import AppContext from './src/store';
import InformContext from './src/stores/store2.js';
import snsContext from './src/stores/store3.js';
import SplashScreen from 'react-native-splash-screen';
import { Image, View, Text} from 'react-native';
const App = () => {
const Stack = createStackNavigator();
const [schedule, setSchedule] = useState(null)
const getScheduleInfo = async () => {
await api
.getSchedule()
.then((data) =>{
setSchedule(data);
})
.catch((error) => console.log(error));
}
const [information, setInformation] = useState(null)
const getInformation = async () => {
await api
.getInform()
.then((data) => {
setInformation(data);
})
.catch((error) => console.log(error))
}
const [snsInform, setSnsInform] = useState(null)
const getSnsInform = async () => {
await api
.getSns()
.then((data) => {
setSnsInform(data);
})
.catch((error) => console.log(error))
}
useEffect(()=>{
getScheduleInfo()
getInformation()
getSnsInform()
if (schedule !== null && information !== null && snsInform !== null)
{
SplashScreen.hide()
}
},[schedule])
return (
// <Example/>
<InformContext.Provider value = {information}>
<snsContext.Provider value = {snsInform}>
<AppContext.Provider value = {schedule} >
<NavigationContainer>
<Stack.Navigator
initialRouteName='Start'
screenOptions={() => ({
headerTitleStyle:{
color:'#2B65B4', fontSize: 17, fontWeight: 'bold'
},
})}>
<Stack.Screen options={{headerShown: false}} name='Name' component={NameSearch}/>
<Stack.Screen
options={({route}) => (
{headerTitle : '국회의원 일정 - ' + route.params.name , headerTitleAlign: "center",
headerRight : () => (
<Image
source = {{ uri : `https://www.assembly.go.kr/static/portal/img/openassm/${route.params.code}.jpg`}}
style = {{
width: 35 , height: 35,
borderRadius: 99, borderWidth: 2, borderColor: '#2B65B4', margin: 20
}} />), })}
name='Calendar'
component={CalendarView}/>
<Stack.Screen
options={({route}) => (
{headerTitle : '국회의원 - ' + route.params.name , headerTitleAlign: "center", headerBackTitle: "Back"}
)}
name='Info'
component={InformTable}/>
</Stack.Navigator>
</NavigationContainer>
</AppContext.Provider>
</snsContext.Provider>
</InformContext.Provider>
);
};
export default App;