-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
140 lines (128 loc) · 3.95 KB
/
App.tsx
File metadata and controls
140 lines (128 loc) · 3.95 KB
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
133
134
135
136
137
138
139
140
import { createStackNavigator, StackHeaderProps } from "@react-navigation/stack";
import { AppLoading } from "expo";
import React, { useState } from "react";
import { Text, ThemeProvider } from "react-native-elements";
import ErrorBoundary from "react-native-error-boundary";
import "react-native-gesture-handler"; // must be the first import
import { Provider } from "react-redux";
import { LinkingNavigationContainer } from "./components/LinkingNavigationContainer";
import NavHeader from "./components/NavHeader";
import { defaultTheme, loadFonts } from "./config/Theming";
import { urlPrefixes } from "./model/Sharing";
import BlogEditScreen, { BlogEditParams } from "./screens/BlogEditScreen";
import BlogListScreen from "./screens/BlogListScreen";
import BlogReadScreen, { BlogReadParams } from "./screens/BlogReadScreen";
import LoginScreen from "./screens/LoginScreen";
import { delay } from "./src/AsyncTools";
import Warnings from "./src/Warnings";
import { doRestoreLogin } from "./store/AuthActions";
import { store } from "./store/index";
Warnings.ignore("Setting a timer");
export type RootStackParamList = {
BlogList: undefined;
BlogRead: BlogReadParams;
BlogEdit: BlogEditParams;
Login: undefined;
DebugScreen: undefined;
};
const DummyStack = createStackNavigator();
const Stack = createStackNavigator<RootStackParamList>();
const navigatorOptions = {
screenOptions: {
header: (headerProps: StackHeaderProps) => (
<NavHeader headerProps={headerProps} />
),
},
};
const linking = {
prefixes: urlPrefixes,
config: {
Dummy: {
initialRouteName: "BlogList",
screens: {
BlogList: {
path: "list",
},
BlogRead: {
path: "post/:id",
},
},
},
},
};
function RootStackNavigator() {
// const DebugScreen = (props: any) => <LoginScreen showDebugButtons={true} {...props}/>
const DebugScreen = (props: any) => <TestScreen {...props}/>
const testing = !true
return (
<Stack.Navigator {...navigatorOptions}>
{testing && <Stack.Screen
name="DebugScreen"
component={DebugScreen}
options={{ title: "Testing" }}
/>}
<Stack.Screen
name="BlogList"
component={BlogListScreen}
options={{ title: "All Blog Entries" }}
/>
<Stack.Screen
name="BlogRead"
component={BlogReadScreen}
options={{ title: "Single Blog Entry" }}
/>
<Stack.Screen
name="BlogEdit"
component={BlogEditScreen}
options={{ title: "Edit Blog Entry" }}
/>
<Stack.Screen
name="Login"
component={LoginScreen}
options={{ title: "Log in or Sign up" }}
/>
</Stack.Navigator>
);
}
async function performStartupStuff() {
// this is all kind of silly, but that's only
// because firebase initialization is slow and stupid...
const results = await Promise.all([
store.dispatch<any>(doRestoreLogin()),
delay(100),
loadFonts(),
]);
return; // results;
// await store.dispatch(doRestoreLogin());
// await delay(100);
// await store.dispatch(doRestoreLogin());
}
export default function App() {
const [startUpFinished, setStartUpFinished] = useState(false);
if (!startUpFinished) {
return (
<AppLoading
startAsync={performStartupStuff}
onFinish={() => setStartUpFinished(true)}
onError={console.warn}
// autoHideconsoconsole.log(Splash={false}
/>
);
}
return (
<ErrorBoundary>
<ThemeProvider theme={defaultTheme}>
<Provider store={store}>
<LinkingNavigationContainer
linking={linking}
fallback={<Text>Loading...</Text>}
>
<DummyStack.Navigator screenOptions={{ headerShown: false }}>
<DummyStack.Screen name="Dummy" component={RootStackNavigator} />
</DummyStack.Navigator>
</LinkingNavigationContainer>
</Provider>
</ThemeProvider>
</ErrorBoundary>
);
}