-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathApp.js
136 lines (127 loc) · 4.53 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
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 ProvidersSettings from "./src/pages/SettingsPage/ProvidersSettings";
import ConversationsSettings from "./src/pages/SettingsPage/ConversationsSettings";
import NewConversation from "./src/features/chat/NewConversation";
import ProviderSettings from "./src/pages/SettingsPage/ProviderSettings";
import { colors, navTheme } from "./src/styles/colors";
// import * as SplashScreen from 'expo-splash-screen';
// SplashScreen.setOptions({
// duration: 1000,
// fade: true,
// });
// Navigation
const Tab = createBottomTabNavigator();
const SettingsStack = createNativeStackNavigator();
const ConversationsStack = createNativeStackNavigator();
const SettingsStackScreen = () => {
return (
<SettingsStack.Navigator
screenOptions={{
headerShown: false,
}}
>
<SettingsStack.Screen
name="Main"
component={Settings}
></SettingsStack.Screen>
<SettingsStack.Screen
name="ProvidersSettings"
component={ProvidersSettings}
></SettingsStack.Screen>
<SettingsStack.Screen
name="OpenAI"
component={ProviderSettings}
initialParams={{ name: "OpenAI", provider: "openAi" }}
></SettingsStack.Screen>
<SettingsStack.Screen
name="Anthropic"
component={ProviderSettings}
initialParams={{ name: "Anthropic", provider: "anthropic" }}
></SettingsStack.Screen>
<SettingsStack.Screen
name="Mistral"
component={ProviderSettings}
initialParams={{ name: "Mistral", provider: "mistral" }}
></SettingsStack.Screen>
<SettingsStack.Screen
name="ConversationsSettings"
component={ConversationsSettings}
></SettingsStack.Screen>
</SettingsStack.Navigator>
);
};
const ConversationsStackScreen = () => {
return (
<ConversationsStack.Navigator screenOptions={{ headerShown: false }}>
<ConversationsStack.Screen
name="ConversationsPage"
component={ConversationsPage}
/>
<ConversationsStack.Screen name="ChatPage" component={ChatPage} />
</ConversationsStack.Navigator>
);
};
const MainApp = () => {
const theme = useSelector((state) => state.chat.theme);
const getIconName = (routeName, focused) => {
const icons = {
Conversations: focused ? "list" : "list-outline",
Settings: focused ? "settings" : "settings-outline",
"New Conversation": focused ? "add" : "add-outline",
};
return icons[routeName];
};
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 }) => {
const iconName = getIconName(route.name, focused);
return <Ionicons name={iconName} size={size} color={color} />;
},
tabBarActiveTintColor: navTheme[theme].tabBarActiveTintColor,
tabBarInactiveTintColor: navTheme[theme].tabBarInactiveTintColor,
})}
>
<Tab.Screen
name="Conversations"
component={ConversationsStackScreen}
/>
<Tab.Screen name="New Conversation" component={NewConversation} />
<Tab.Screen name="Settings" component={SettingsStackScreen} />
</Tab.Navigator>
</NavigationContainer>
</PersistGate>
</>
);
};
const App = () => {
return (
<Provider store={store}>
<MainApp />
</Provider>
);
};
export default App;