-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
62 lines (56 loc) · 1.9 KB
/
App.js
File metadata and controls
62 lines (56 loc) · 1.9 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
import React, { useState } from 'react';
import { View, StyleSheet, Platform, StatusBar as RNStatusBar } from 'react-native';
import { StatusBar } from 'expo-status-bar';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { NavigationContainer, DefaultTheme, DarkTheme } from '@react-navigation/native';
import RootNavigator from './src/navigation/RootNavigator';
import SplashScreen from './src/screens/SplashScreen';
import { ThemeProvider, useTheme } from './src/context/ThemeContext';
function MainApp() {
const [isLoading, setIsLoading] = useState(true);
const { theme } = useTheme();
// Create a Navigation Theme based on our custom theme
const navigationTheme = {
...DefaultTheme,
colors: {
...DefaultTheme.colors,
background: theme.background,
card: theme.surface,
text: theme.textPrimary,
border: theme.border,
primary: theme.primary,
},
};
if (isLoading) {
return (
<>
<StatusBar style={theme.isDark ? "light" : "dark"} />
<SplashScreen onFinish={() => setIsLoading(false)} />
</>
);
}
return (
<NavigationContainer theme={navigationTheme}>
<StatusBar style={theme.isDark ? "light" : "dark"} />
<View style={[styles.container, { backgroundColor: theme.background }]}>
<RootNavigator />
</View>
</NavigationContainer>
);
}
export default function App() {
return (
<SafeAreaProvider>
<ThemeProvider>
<MainApp />
</ThemeProvider>
</SafeAreaProvider>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
// Background color is handled dynamically now
paddingTop: Platform.OS === 'android' ? RNStatusBar.currentHeight : 0,
},
});