-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathApp.js
260 lines (248 loc) · 8.33 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
import { NavigationContainer } from "@react-navigation/native";
import { createStackNavigator } from "@react-navigation/stack";
import * as Notifications from "expo-notifications";
import { StatusBar } from "expo-status-bar";
import React, { useEffect, useRef } from "react";
import { AppRegistry, Platform, UIManager, View } from "react-native";
import { Provider as PaperProvider } from "react-native-paper";
import Toast from "react-native-toast-message";
import {
Provider as ReduxProvider,
useDispatch,
useSelector,
} from "react-redux";
import { PersistGate } from "redux-persist/integration/react";
import Subject from "./components/NewSubject";
import BottomNavBar from "./navigation/BottomNavBar";
import { loadEvents } from "./redux/actions/eventActions";
import { persistor, store } from "./redux/store";
import AboutUs from "./screens/dashboardScreens/AboutUs";
import Config from "./screens/dashboardScreens/Config";
import Contact from "./screens/dashboardScreens/Contact";
import EventScreen from "./screens/dashboardScreens/Eventos";
import FreqScreen from "./screens/dashboardScreens/Frequencia";
import SubjectScreen from "./screens/dashboardScreens/Materias";
import NotasScreen from "./screens/dashboardScreens/Notas";
import SigaScreen from "./screens/dashboardScreens/Siga";
import Details from "./screens/Details";
import EditScreen from "./screens/EditScreen";
import RestaurantNotice from "./screens/RestaurantNotice";
import Welcome from "./screens/Welcome";
import { CombinedDarkThemes, CombinedDefaultThemes } from "./theme/Themes";
import {
useFonts,
RobotoCondensed_300Light,
RobotoCondensed_300Light_Italic,
RobotoCondensed_400Regular,
RobotoCondensed_400Regular_Italic,
RobotoCondensed_700Bold,
RobotoCondensed_700Bold_Italic,
} from "@expo-google-fonts/roboto-condensed";
import Links from "./screens/dashboardScreens/Links";
import * as Sentry from "sentry-expo";
import RuSyncScreen from "./screens/dashboardScreens/RuSyncScreen";
import Constants from "expo-constants";
import * as Application from "expo-application";
Sentry.init({
dsn: "https://c1a9d3d02d424eaa91ee720bd5225f83@o4505104445079552.ingest.sentry.io/4505104464805888",
enableInExpoDevelopment: false,
debug: __DEV__,
dist: Application.nativeBuildVersion,
release: Constants.expoConfig.android.package +
"@" + Constants.expoConfig.version +
"+" + Constants.expoConfig.android.versionCode.toString(),
});
if (
Platform.OS === "android" &&
UIManager.setLayoutAnimationEnabledExperimental
) {
UIManager.setLayoutAnimationEnabledExperimental(true);
}
const HomeStackRoutes = createStackNavigator();
Notifications.setNotificationHandler({
handleNotification: async() => ({
shouldShowAlert: true,
shouldPlaySound: true,
shouldSetBadge: false,
}),
});
AppRegistry.registerComponent("X", () => App);
export default function App() {
try {
const notificationListener = useRef();
const responseListener = useRef();
useEffect(() => {
notificationListener.current =
Notifications.addNotificationReceivedListener((notification) => {
Toast.show({
type: "success",
text1: notification.request.content.title,
text2: notification.request.content.body,
});
});
responseListener.current =
Notifications.addNotificationResponseReceivedListener((response) => {
console.log(response);
});
return () => {
Notifications.removeNotificationSubscription(
notificationListener.current,
);
Notifications.removeNotificationSubscription(responseListener.current);
};
}, []);
return (
<ReduxProvider store={store}>
<PersistGate loading={null} persistor={persistor}>
<Loader />
</PersistGate>
</ReduxProvider>
);
} catch (error) {
Sentry.Native.captureException(error);
}
}
function Loader() {
const eventsSt = useSelector((state) => state.events);
const dispatch = useDispatch();
dispatch(loadEvents(eventsSt));
const user = useSelector((state) => state.user).user;
const themeConfig = useSelector((state) => state.theme);
let theme = themeConfig.isDark ?
CombinedDarkThemes[themeConfig.themeIdx] :
CombinedDefaultThemes[themeConfig.themeIdx];
let [fontsLoaded] = useFonts({
RobotoCondensed_300Light,
RobotoCondensed_300Light_Italic,
RobotoCondensed_400Regular,
RobotoCondensed_400Regular_Italic,
RobotoCondensed_700Bold,
RobotoCondensed_700Bold_Italic,
});
if (!fontsLoaded) {
return <View style={{ flex: 1, backgroundColor: "#E8243C" }} />;
}
return (
<>
<StatusBar style={themeConfig.isDark ? "light" : "dark"} />
<PaperProvider theme={theme}>
<NavigationContainer theme={theme}>
<HomeStackRoutes.Navigator
initialRouteName={user.welcome ? "Welcome" : "BottomNav"}
screenOptions={() => ({
headerStyle: {
backgroundColor: theme.colors.headerInactive,
},
headerTintColor: theme.colors.onHeaderInactive,
})}
>
<HomeStackRoutes.Screen
name="Welcome"
component={Welcome}
options={() => ({
headerTitleAlign: "center",
headerShown: false,
})}
/>
<HomeStackRoutes.Group screenOptions={{ headerShown: false }}>
<HomeStackRoutes.Screen
name="BottomNav"
component={BottomNavBar}
/>
</HomeStackRoutes.Group>
<HomeStackRoutes.Screen
name="Event"
component={Details}
options={() => ({
headerTitleAlign: "center",
})}
/>
<HomeStackRoutes.Screen
name="EditScreen"
component={EditScreen}
options={() => ({
headerTitleAlign: "center",
})}
/>
<HomeStackRoutes.Screen
name="RestaurantNotice"
component={RestaurantNotice}
options={({ route }) => ({
title: route.params.title,
})}
/>
<HomeStackRoutes.Screen
name="Subject"
component={Subject}
options={() => ({
title: "Média",
headerTitleAlign: "center",
})}
/>
<HomeStackRoutes.Screen
name="Configurações"
component={Config} />
<HomeStackRoutes.Screen
name="AboutUs"
options={() => ({
title: "Sobre nós",
})}
component={AboutUs} />
<HomeStackRoutes.Screen
name="Links"
options={() => ({
title: "Links Úteis",
})}
component={Links} />
<HomeStackRoutes.Screen
name="Contato"
component={Contact} />
<HomeStackRoutes.Screen
name="Eventos"
component={EventScreen}
options={() => ({
title: "Eventos",
})}
/>
<HomeStackRoutes.Screen
name="Materias"
component={SubjectScreen}
options={() => ({
title: "Matérias",
})}
/>
<HomeStackRoutes.Screen
name="Notas"
component={NotasScreen}
options={() => ({
title: "Notas",
})}
/>
<HomeStackRoutes.Screen
name="Frequencia"
component={FreqScreen}
options={() => ({
title: "Frequência",
})}
/>
<HomeStackRoutes.Screen
name="Siga"
component={SigaScreen}
options={() => ({
title: "Siga",
})}
/>
<HomeStackRoutes.Screen
name="RuSync"
component={RuSyncScreen}
options={() => ({
title: "Sincronização do Saldo",
})}
/>
</HomeStackRoutes.Navigator>
</NavigationContainer>
</PaperProvider>
<Toast bottomOffset={20} text1NumberOfLines={2} />
</>
);
}