-
Notifications
You must be signed in to change notification settings - Fork 3
/
App.tsx
120 lines (110 loc) · 3.27 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import React from 'react';
import { TouchableOpacity } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import {
createStackNavigator,
TransitionPresets
} from '@react-navigation/stack';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { StatusBar } from 'expo-status-bar';
import { AuthProvider } from './src/contexts/AuthContext';
import { SitesProvider, SitesContext } from './src/contexts/SitesContext';
import NoSite from './src/screens/NoSite';
import SiteSetup from './src/screens/SiteSetup';
import SiteSelector from './src/screens/SiteSelector';
import Login from './src/screens/Login';
import Register from './src/screens/Register';
import Home from './src/screens/Home';
import Post from './src/components/Post';
import { Feather } from '@expo/vector-icons';
const AppStack = createStackNavigator();
const AuthStack = createStackNavigator();
const SiteStack = createStackNavigator<SiteStackParamList>();
const AuthNavigator = () => (
<AuthStack.Navigator>
<AuthStack.Screen name='Login' component={Login} />
<AuthStack.Screen name='Register' component={Register} />
</AuthStack.Navigator>
);
export type SiteStackParamList = {
Home: undefined;
Post: { postId: number };
};
const SiteNavigator = () => (
<SiteStack.Navigator
screenOptions={{
headerStyle: {
backgroundColor: '#222222',
shadowColor: '#999999'
},
headerLeftContainerStyle: {
paddingLeft: 12
},
headerTitleStyle: {
color: '#DEDEDE'
}
}}
>
<SiteStack.Screen
name='Home'
component={Home}
options={({ navigation }) => ({
headerTitle: '',
headerLeft: () => (
<TouchableOpacity
onPress={() => {
navigation.navigate('SiteSelector');
}}
>
<Feather name='menu' color='#DEDEDE' size={28} />
</TouchableOpacity>
)
})}
/>
<SiteStack.Screen
name='Post'
component={Post}
options={({ navigation }) => ({
headerLeft: () => (
<TouchableOpacity onPress={navigation.goBack}>
<Feather name='chevron-left' color='#DEDEDE' size={28} />
</TouchableOpacity>
)
})}
/>
</SiteStack.Navigator>
);
const AppNavigator = () => {
const { activeSite } = React.useContext(SitesContext);
return (
<AppStack.Navigator
headerMode='none'
initialRouteName={activeSite ? 'Site' : 'NoSite'}
mode='modal'
screenOptions={{
gestureEnabled: true,
cardOverlayEnabled: true,
...TransitionPresets.ModalPresentationIOS
}}
>
<AppStack.Screen name='NoSite' component={NoSite} />
<AppStack.Screen name='Site' component={SiteNavigator} />
<AppStack.Screen name='Auth' component={AuthNavigator} />
<AppStack.Screen name='SiteSetup' component={SiteSetup} />
<AppStack.Screen name='SiteSelector' component={SiteSelector} />
</AppStack.Navigator>
);
};
const App = () => (
<AuthProvider>
<StatusBar style='light' />
<SitesProvider>
<SafeAreaProvider>
<NavigationContainer>
<AppNavigator />
</NavigationContainer>
</SafeAreaProvider>
</SitesProvider>
</AuthProvider>
);
export default App;