-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
89 lines (84 loc) · 2.73 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
import * as React from "react";
import { StatusBar, View } from "react-native";
import { NavigationContainer } from "@react-navigation/native";
import {
CardStyleInterpolators,
createStackNavigator,
StackNavigationOptions,
} from "@react-navigation/stack";
import { backgroundDark } from "./src/common/vars";
import { CurrentTimeProvider } from "./src/common/CurrentTimeContext";
import { ErrorView } from "./src/components/ErrorView";
import { FullPageView } from "./src/components/FullPageView";
import {
SafeAreaProvider,
useSafeAreaInsets,
} from "react-native-safe-area-context";
import { NewsListScreen } from "./src/screens/NewsList";
import { CommentsList } from "./src/screens/CommentsList";
import { CommentsSink } from "./src/screens/CommentsSink";
import { ErrorBoundary } from "./src/components/ErrorBoundary";
import { HNStory } from "./src/common/types";
import { QueryClientProvider } from "react-query";
import { queryClient } from "./src/lib/queryClient";
const Stack = createStackNavigator<RootStackParamList>();
export type RootStackParamList = {
Home: undefined;
Comments: { id: string; story?: HNStory };
CommentsTesting: undefined;
};
const screenOptions: StackNavigationOptions = {
gestureEnabled: true,
gestureDirection: "horizontal",
gestureResponseDistance: {
horizontal: 135,
vertical: 135,
},
cardStyle: { backgroundColor: backgroundDark },
cardStyleInterpolator: CardStyleInterpolators.forHorizontalIOS,
};
function AppWrapper() {
const { right, left, top } = useSafeAreaInsets();
return (
<ErrorBoundary
fallback={(error) => (
<FullPageView backgroundColor={backgroundDark}>
<ErrorView error={error} />
</FullPageView>
)}
>
<QueryClientProvider client={queryClient}>
<CurrentTimeProvider>
<StatusBar barStyle={"light-content"} />
<View
style={{
flex: 1,
paddingRight: right,
paddingLeft: left,
paddingTop: top,
paddingBottom: 0,
backgroundColor: backgroundDark,
}}
>
<Stack.Navigator
initialRouteName="Home"
headerMode="none"
screenOptions={screenOptions}
>
<Stack.Screen name="Home" component={NewsListScreen} />
<Stack.Screen name="Comments" component={CommentsList} />
<Stack.Screen name="CommentsTesting" component={CommentsSink} />
</Stack.Navigator>
</View>
</CurrentTimeProvider>
</QueryClientProvider>
</ErrorBoundary>
);
}
export default () => (
<SafeAreaProvider>
<NavigationContainer>
<AppWrapper />
</NavigationContainer>
</SafeAreaProvider>
);