-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
103 lines (96 loc) · 3.02 KB
/
App.js
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
import React, { useState, useEffect } from "react";
import { NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import HomeScreen from "./src/screens/HomeScreen";
import ConvoSelectScreen from "./src/screens/ConvoSelectScreen";
import ConvoScreen from "./src/screens/ConvoScreen";
import SettingsScreen from "./src/screens/SettingsScreen";
import AddServerScreen from "./src/screens/AddServerScreen";
import EditServerScreen from "./src/screens/EditServerScreen";
import AboutScreen from "./src/screens/AboutScreen";
import TutorialScreen from "./src/screens/TutorialScreen";
import { database } from "./src/utils/database";
import AsyncStorage from "@react-native-async-storage/async-storage";
const Stack = createNativeStackNavigator();
export default function App() {
const [isLoading, setIsLoading] = useState(true);
const [firstLaunch, setFirstLaunch] = useState(null);
useEffect(() => {
const initializeDatabase = async () => {
try {
await database.init();
setIsLoading(false);
} catch (error) {
console.error("Database initialization failed:", error);
}
};
AsyncStorage.getItem('alreadyLaunched').then(value => {
if (value == null) {
AsyncStorage.setItem('alreadyLaunched', 'true');
setFirstLaunch(true);
} else {
setFirstLaunch(false);
}
});
initializeDatabase();
}, []);
return (
<NavigationContainer>
<Stack.Navigator
initialRouteName={firstLaunch ? "Tutorial" : "Home"}
screenOptions={{
headerStyle: {
backgroundColor: "#A12516",
},
headerTintColor: "#fff",
headerTitleStyle: {
fontWeight: "bold",
},
}}
>
{firstLaunch && (
<Stack.Screen
name="Tutorial"
component={TutorialScreen}
options={{ title: "Tutorial" }}
/>
)}
<Stack.Screen
name="Home"
component={HomeScreen}
options={{ title: "Model / App / Server Combos" }}
/>
<Stack.Screen
name="ConvoSelectScreen"
component={ConvoSelectScreen}
options={{ title: "Conversations" }}
/>
<Stack.Screen
name="ConvoScreen"
component={ConvoScreen}
options={{ title: "Chat" }}
/>
<Stack.Screen
name="Settings"
component={SettingsScreen}
options={{ title: "Settings" }}
/>
<Stack.Screen
name="About"
component={AboutScreen}
options={{ title: "About" }}
/>
<Stack.Screen
name="AddServerScreen"
component={AddServerScreen}
options={{ title: "Add Combo" }}
/>
<Stack.Screen
name="EditServerScreen"
component={EditServerScreen}
options={{ title: "Edit / Duplicate Server" }}
/>
</Stack.Navigator>
</NavigationContainer>
);
}