-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
152 lines (135 loc) · 4.31 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
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import "react-native-gesture-handler";
import MaterialCommunityIcons from "@expo/vector-icons/build/MaterialCommunityIcons";
import { NavigationContainer } from "@react-navigation/native";
import { createStackNavigator } from "@react-navigation/stack";
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
import { useKeepAwake } from "expo-keep-awake";
import { StatusBar } from "expo-status-bar";
import { useEffect } from "react";
import { LogBox, StyleSheet } from "react-native";
import { MenuProvider } from "react-native-popup-menu";
import { SafeAreaProvider } from "react-native-safe-area-context";
import { AppStateProvider } from "./src/appState";
import { speakInit } from "./src/service/speech";
import { Word } from "./src/service/words";
import CreateWordScreen from "./src/screens/editWord/CreateWordScreen";
import EditWordScreen from "./src/screens/editWord/EditWordScreen";
import MainScreen from "./src/screens/main/MainScreen";
import ImageSearchScreen from "./src/screens/imageSearch/ImageSearchScreen";
import KeyboardScreen from "./src/screens/keyboard/KeyboardScreen";
import TemplateSearchScreen from "./src/screens/templates/TemplateSearchScreen";
// https://reactnavigation.org/docs/troubleshooting/#i-get-the-warning-non-serializable-values-were-found-in-the-navigation-state
LogBox.ignoreLogs([
"Non-serializable values were found in the navigation state",
]);
export type RootStackParamList = {
Home: undefined;
createWord: undefined;
editWord: { word: Word };
searchImage: { onUpdateUri: (uri: string) => void };
searchTemplate: undefined;
};
const Stack = createStackNavigator<RootStackParamList>();
export type HomeTabsParamList = {
TabHome: undefined;
TabKeyboard: undefined;
};
const Tab = createBottomTabNavigator<HomeTabsParamList>();
function HomeTabs() {
const screenOptions = {
headerShown: false,
};
const homeTabOptions = {
title: "Home",
tabBarIcon: ({ color, size }: { color: string; size: number }) => (
<MaterialCommunityIcons name="home" color={color} size={size} />
),
};
const keyboardTabOptions = {
title: "Keyboard",
tabBarIcon: ({ color, size }: { color: string; size: number }) => (
<MaterialCommunityIcons name="keyboard" color={color} size={size} />
),
};
return (
<Tab.Navigator screenOptions={screenOptions}>
<Tab.Screen
name="TabHome"
component={MainScreen}
options={homeTabOptions}
/>
<Tab.Screen
name="TabKeyboard"
component={KeyboardScreen}
options={keyboardTabOptions}
/>
</Tab.Navigator>
);
}
export default function App() {
useKeepAwake();
useEffect(() => {
speakInit();
}, []);
return (
<MenuProvider>
<AppStateProvider>
<SafeAreaProvider>
<NavigationContainer>
<Stack.Navigator screenOptions={screenOptions}>
<Stack.Screen
name="Home"
component={HomeTabs}
options={{ headerShown: false }}
/>
<Stack.Screen
name="createWord"
component={CreateWordScreen}
options={{ title: "Add New Word" }}
/>
<Stack.Screen
name="editWord"
component={EditWordScreen}
options={{ title: "Edit Word" }}
/>
<Stack.Screen
name="searchImage"
component={ImageSearchScreen}
options={{ title: "Search Symbol" }}
/>
<Stack.Screen
name="searchTemplate"
component={TemplateSearchScreen}
options={{ title: "Import a Template" }}
/>
</Stack.Navigator>
</NavigationContainer>
<StatusBar style="auto" />
</SafeAreaProvider>
</AppStateProvider>
</MenuProvider>
);
}
const styles = StyleSheet.create({
container: {
alignItems: "stretch",
backgroundColor: "#fff",
flex: 1,
justifyContent: "flex-start",
},
header: {
height: 60,
},
headerTitle: {
fontSize: 16,
bottom: 5,
},
headerBackTitle: {
marginBottom: 15,
},
});
const screenOptions = {
headerStyle: styles.header,
headerTitleStyle: styles.headerTitle,
headerBackTitleStyle: styles.headerBackTitle,
};