-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathApp.js
More file actions
66 lines (59 loc) · 1.64 KB
/
App.js
File metadata and controls
66 lines (59 loc) · 1.64 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
57
58
59
60
61
62
63
64
65
66
import React, { useState, useEffect, useContext } from "react";
import { View, StatusBar } from "react-native";
import AppLoading from "expo-app-loading";
import { SafeAreaView } from "react-navigation";
import StackNavigator from "./src/Screens/StackNavigator";
import DiscoverContextProvider from "./src/Context/DiscoverContext";
import ThemesContextProvider from "./src/Context/ThemesContext";
import { ThemesContext } from "./src/Context/ThemesContext";
import { getTheme } from "./src/utils/themePersist";
const AppContainer = () => {
const [appLoading, setAppLoading] = useState(true);
const { theme, themeType, setTheme } = useContext(ThemesContext);
useEffect(() => {
getTheme()
.then(theme => {
if (theme) {
setTheme(theme.colors);
}
setAppLoading(false);
})
.catch(error => console.log(error));
}, []);
if (appLoading) {
return <AppLoading />;
}
return (
<View style={styles(theme).appContainer}>
<StatusBar
barStyle={themeType == "dark" ? "light-content" : "dark-content"}
/>
<SafeAreaView style={{ flex: 1 }} forceInset={{ bottom: "never" }}>
<StackNavigator screenProps={{ theme: theme }} />
</SafeAreaView>
</View>
);
};
const App = () => {
return (
<View style={{ flex: 1 }}>
<ThemesContextProvider>
<DiscoverContextProvider>
<AppContainer />
</DiscoverContextProvider>
</ThemesContextProvider>
</View>
);
};
const styles = theme => {
return {
app: {
flex: 1,
},
appContainer: {
flex: 1,
backgroundColor: theme.base01,
},
};
};
export default App;