-
Notifications
You must be signed in to change notification settings - Fork 2
/
App.js
114 lines (106 loc) · 4 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
104
105
106
107
108
109
110
111
112
113
114
import { NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
import Ionicons from "@expo/vector-icons/Ionicons";
import { store, persistor } from "./src/app/store";
import { Provider, useSelector } from "react-redux";
import { PersistGate } from "redux-persist/integration/react";
import { StatusBar } from "expo-status-bar";
import { Text } from "react-native";
import ChatPage from "./src/pages/ChatPage/ChatPage";
import ConversationsPage from "./src/pages/ConversationsPage/ConversationsPage";
import Settings from "./src/pages/SettingsPage/SettingsPage";
import ChatSettings from "./src/pages/SettingsPage/ChatSettings";
import NewChat from "./src/features/chat/NewChat";
import ChatSettingsProvider from "./src/pages/SettingsPage/ChatSettingsProvider";
import { colors, navTheme } from "./src/styles/colors";
// Navigation
const Tab = createBottomTabNavigator();
const SettingsStack = createNativeStackNavigator();
const SettingsStackScreen = () => {
return (
<SettingsStack.Navigator
screenOptions={{
headerShown: false,
}}
>
<SettingsStack.Screen
name="Main"
component={Settings}
></SettingsStack.Screen>
<SettingsStack.Screen
name="Chat Settings"
component={ChatSettings}
></SettingsStack.Screen>
<SettingsStack.Screen
name="OpenAI"
component={ChatSettingsProvider}
initialParams={{ name: "OpenAI", provider: "openAi" }}
></SettingsStack.Screen>
<SettingsStack.Screen
name="Anthropic"
component={ChatSettingsProvider}
initialParams={{ name: "Anthropic", provider: "anthropic" }}
></SettingsStack.Screen>
<SettingsStack.Screen
name="Mistral"
component={ChatSettingsProvider}
initialParams={{ name: "Mistral", provider: "mistral" }}
></SettingsStack.Screen>
</SettingsStack.Navigator>
);
};
const MainApp = () => {
const theme = useSelector((state) => state.chat.theme);
return (
<>
<StatusBar backgroundColor={colors[theme].statusBarBg} style="light" />
<PersistGate loading={<Text>Loading...</Text>} persistor={persistor}>
<NavigationContainer theme={navTheme[theme]}>
<Tab.Navigator
screenOptions={({ route }) => ({
headerShown: false,
headerStyle: {
borderBottomWidth: 0.2,
},
tabBarShowLabel: true,
tabBarStyle: {
borderTopWidth: 0.2,
},
tabBarIcon: ({ focused, color, size }) => {
let iconName;
if (route.name === "Chat") {
iconName = focused
? "chatbox-ellipses"
: "chatbox-ellipses-outline";
} else if (route.name === "Conversations") {
iconName = focused ? "list" : "list-outline";
} else if (route.name === "Settings") {
iconName = focused ? "settings" : "settings-outline";
} else if (route.name === "New Chat") {
iconName = focused ? "add" : "add-outline";
}
return <Ionicons name={iconName} size={size} color={color} />;
},
tabBarActiveTintColor: navTheme[theme].tabBarActiveTintColor,
tabBarInactiveTintColor: navTheme[theme].tabBarInactiveTintColor,
})}
>
<Tab.Screen name="Chat" component={ChatPage} />
<Tab.Screen name="Conversations" component={ConversationsPage} />
<Tab.Screen name="New Chat" component={NewChat} />
<Tab.Screen name="Settings" component={SettingsStackScreen} />
</Tab.Navigator>
</NavigationContainer>
</PersistGate>
</>
);
};
const App = () => {
return (
<Provider store={store}>
<MainApp />
</Provider>
);
};
export default App;