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
|
import type { AppStateStatus } from "react-native";
import { useEffect } from "react";
import { AppState, Platform } from "react-native";
import { useRouter } from "expo-router";
import { Stack } from "expo-router/stack";
import { StyledStack } from "@/components/navigation/stack";
import { useIsLoggedIn } from "@/lib/session";
import { focusManager } from "@tanstack/react-query";
function onAppStateChange(status: AppStateStatus) {
if (Platform.OS !== "web") {
focusManager.setFocused(status === "active");
}
}
export default function Dashboard() {
const router = useRouter();
const isLoggedIn = useIsLoggedIn();
useEffect(() => {
if (isLoggedIn !== undefined && !isLoggedIn) {
return router.replace("server-address");
}
}, [isLoggedIn]);
useEffect(() => {
const subscription = AppState.addEventListener("change", onAppStateChange);
return () => subscription.remove();
}, []);
return (
<StyledStack
contentClassName="bg-gray-100 dark:bg-background"
headerClassName="bg-gray-100 dark:bg-background text-foreground"
screenOptions={{
headerTransparent: true,
}}
>
<Stack.Screen
name="(tabs)"
options={{ headerShown: false, title: "Home" }}
/>
<Stack.Screen
name="favourites"
options={{
headerTitle: "",
headerBackTitle: "Back",
headerTransparent: true,
}}
/>
<Stack.Screen
name="bookmarks/[slug]/index"
options={{
headerTitle: "",
headerBackTitle: "Back",
headerTransparent: true,
}}
/>
<Stack.Screen
name="bookmarks/new"
options={{
headerTitle: "New Bookmark",
headerBackTitle: "Back",
headerTransparent: true,
presentation: "modal",
}}
/>
<Stack.Screen
name="bookmarks/[slug]/manage_lists"
options={{
headerTitle: "Manage Lists",
headerBackTitle: "Back",
headerTransparent: true,
presentation: "modal",
}}
/>
<Stack.Screen
name="bookmarks/[slug]/info"
options={{
headerBackTitle: "Back",
headerTransparent: true,
presentation: "modal",
}}
/>
<Stack.Screen
name="lists/new"
options={{
headerTitle: "New List",
headerBackTitle: "Back",
headerTransparent: true,
presentation: "modal",
}}
/>
<Stack.Screen
name="archive"
options={{
headerTitle: "",
headerBackTitle: "Back",
headerTransparent: true,
}}
/>
<Stack.Screen
name="search"
options={{
headerTitle: "",
headerBackTitle: "",
headerTransparent: true,
headerShown: false,
animation: "fade_from_bottom",
animationDuration: 100,
}}
/>
<Stack.Screen
name="settings/theme"
options={{
title: "Theme",
headerTitle: "Theme",
headerBackTitle: "Back",
}}
/>
</StyledStack>
);
}
|