-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
108 lines (100 loc) · 2.73 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
import React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import ProfileStartupScreen from './screens/ProfileStartupScreen';
import ProfileUserScreen from './screens/ProfileUserScreen';
import MainFeedScreen from './screens/MainFeedScreen';
import LoginScreen from './screens/AuthLoginScreen';
import RegisterScreen from './screens/AuthRegisterScreen';
import UpdateNews from './screens/UpdateNews';
import UpdateOperations from './screens/UpdateOperations';
import UpdateFinancials from './screens/UpdateFinancials';
import AuthenticationContext from './AuthenticationContext';
import { Text } from 'react-native';
import SearchScreen from './screens/SearchScreen';
import MenuScreen from './screens/MenuScreen';
const Stack = createNativeStackNavigator();
const AuthStack = () => (
<Stack.Navigator>
<Stack.Screen
name='Login'
component={LoginScreen}
></Stack.Screen>
<Stack.Screen
name='Register'
component={RegisterScreen}
></Stack.Screen>
</Stack.Navigator>
)
const AppStack = () => (
<Stack.Navigator>
<Stack.Screen
name='Feed'
component={MainFeedScreen}
></Stack.Screen>
<Stack.Screen
name='Menu'
component={MenuScreen}
></Stack.Screen>
<Stack.Screen
name='Search'
component={SearchScreen}
></Stack.Screen>
<Stack.Screen
name="Startup"
component={ProfileStartupScreen}
options={{
headerTransparent: true,
headerTitleStyle: {
color: 'white'
}
}}
></Stack.Screen>
<Stack.Screen
name="User"
component={ProfileUserScreen}
options={{
headerTransparent: true,
headerTitleStyle: {
color: 'white'
}
}}
></Stack.Screen>
<Stack.Screen
name="News"
component={UpdateNews}
></Stack.Screen>
<Stack.Screen
name="Operations"
component={UpdateOperations}
></Stack.Screen>
<Stack.Screen
name='Finances'
component={UpdateFinancials}
></Stack.Screen>
</Stack.Navigator>
)
export default class App extends React.Component {
static contextType = AuthenticationContext;
constructor(props) {
super(props);
this.state = {
auth: {
authToken: null,
updateAuthToken: token => {
this.state.auth.authToken = token;
this.forceUpdate();
}
}
}
}
render() {
return <AuthenticationContext.Provider value={this.state.auth}>
<NavigationContainer>
{this.state.auth.authToken ?
<AppStack></AppStack> : <AuthStack></AuthStack>
}
</NavigationContainer>
</AuthenticationContext.Provider>
}
}