-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppContent.tsx
More file actions
32 lines (26 loc) · 982 Bytes
/
AppContent.tsx
File metadata and controls
32 lines (26 loc) · 982 Bytes
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
// App.tsx
import { useContext, useEffect } from "react";
import { Context as SettingsContext } from "./src/contexts/SettingsContext"; // make sure this is exported
import { navigationRef } from './src/RootNavigation';
import { NavigationContainer } from "@react-navigation/native";
import SwitchNavigator from "./src/navigators/Switch";
import { Provider as PaperProvider } from "react-native-paper";
import { buildTheme } from "./src/helpers/colors";
import { Text } from "react-native";
export const AppContent = () => {
const { state: settingsState, loadColor } = useContext(SettingsContext);
useEffect(() => {
loadColor();
}, [settingsState.loaded])
if (!settingsState.loaded) {
return <Text>Loading theme</Text>;
}
const theme = buildTheme(settingsState.mainColor);
return (
<PaperProvider theme={theme}>
<NavigationContainer ref={navigationRef}>
<SwitchNavigator />
</NavigationContainer>
</PaperProvider>
);
}