-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
56 lines (51 loc) · 2.03 KB
/
App.tsx
File metadata and controls
56 lines (51 loc) · 2.03 KB
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
import { NavigationContainer } from "@react-navigation/native";
import { useFonts } from "expo-font";
import * as SplashScreen from "expo-splash-screen";
import { useState } from "react";
import { StatusBar, Text } from "react-native";
import { useColorScheme } from "react-native/";
import { ThemeProvider } from "styled-components/native";
import { HistoryContext } from "./src/contexts/historyContext";
import { UserContext } from "./src/contexts/userContext";
import { Routes } from "./src/Routes";
import { theme } from "./src/theme/theme";
import { User } from "./src/types/user";
export default function App() {
/* Armazena o estado do usuário atualmente selecionado no topo da árvore de componentes
para ser repassado via Context conforme o necessário */
const [user, setUser] = useState<User.profile | null>(null);
const [history, setHistory] = useState<User.profile[]>([]);
//Retorna o tema atual do aparelho para aplicar os diferentes temas
const colorMode = useColorScheme();
//Impede que o saia da tela inicial, para que possamos carregar as fontes
SplashScreen.preventAutoHideAsync();
const [fontsLoaded] = useFonts({
hubot: require("./assets/fonts/Hubot-Sans-MediumWide.otf"),
fredoka: require("./assets/fonts/Fredoka-Regular.ttf"),
});
//Só mostra o aplicativo se as fontes forem carregadas
if (!fontsLoaded) {
return <Text>Loading...</Text>;
}
SplashScreen.hideAsync();
return (
<NavigationContainer>
<StatusBar
backgroundColor={
colorMode == "dark"
? theme.dark.colors.statusBarColor
: theme.light.colors.statusBarColor
}
/>
<ThemeProvider theme={colorMode === "dark" ? theme.dark : theme.light}>
<UserContext.Provider value={{ profile: user, setProfile: setUser }}>
<HistoryContext.Provider
value={{ history: history, setHistory: setHistory }}
>
<Routes />
</HistoryContext.Provider>
</UserContext.Provider>
</ThemeProvider>
</NavigationContainer>
);
}