-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.tsx
101 lines (96 loc) · 2.95 KB
/
App.tsx
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
import React, {useEffect, useState} from 'react';
import {NativeBaseProvider, extendTheme} from 'native-base';
import {StoreTabs} from './src/views/StoreTabs';
import {StatusBar} from 'react-native';
import * as SecureStore from 'expo-secure-store';
import {AuthLoading} from './src/views/AuthLoading';
import AsyncStorage from '@react-native-async-storage/async-storage';
import {AuthContext} from './src/helpers/AuthContext';
import {NavigationContainer} from '@react-navigation/native';
import {createNativeStackNavigator} from '@react-navigation/native-stack';
import {TryRetry} from './src/views/TryRetry';
import {LoginForm} from './src/views/LoginView';
import WebViewLogin from './src/views/WebViewLogin';
import ShardSelect from './src/views/ShardSelect';
const theme = extendTheme({
config: {
initialColorMode: 'dark',
},
colors: {
backgroundColor: 'red',
},
fontConfig: {
MarkPro: {
400: {
normal: 'mark-pro--regular',
},
500: {
normal: 'mark-pro--medium',
},
600: {
normal: 'mark-pro--medium',
},
700: {
normal: 'mark-pro--bold',
},
},
},
// Make sure values below matches any of the keys in `fontConfig`
fonts: {
heading: 'MarkPro',
body: 'MarkPro',
mono: 'MarkPro',
},
});
const Stack = createNativeStackNavigator();
export default function App() {
const [loggedIn, setLoggedIn] = useState(false);
useEffect(() => {
async function fetchMyAPI() {
let aTokenFound =
(await SecureStore.getItemAsync('val_access_token')) !== null;
let eTokenFound =
(await SecureStore.getItemAsync('val_ent_token')) !== null;
let uuidFound = (await AsyncStorage.getItem('playerUuid')) !== null;
setLoggedIn(aTokenFound && eTokenFound && uuidFound);
}
fetchMyAPI();
}, []);
return (
<NavigationContainer>
<NativeBaseProvider theme={theme}>
<StatusBar backgroundColor="black" />
<AuthContext.Provider value={{loggedIn, setLoggedIn}}>
<Stack.Navigator>
{loggedIn === true && (
<Stack.Screen
name="Store"
component={StoreTabs}
options={{headerShown: false}}
/>
)}
{loggedIn === false && (
<>
<Stack.Screen
name="LoginForm"
component={WebViewLogin}
options={{headerShown: false}}
/>
<Stack.Screen
name="AuthWait"
component={AuthLoading}
options={{headerShown: false}}
/>
<Stack.Screen
name="ShardSelect"
component={ShardSelect}
options={{headerShown: false}}
/>
</>
)}
</Stack.Navigator>
</AuthContext.Provider>
</NativeBaseProvider>
</NavigationContainer>
);
}