-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.js
73 lines (66 loc) · 2.49 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
import './src/utils/firebase'
import React from 'react'
import { SafeAreaView, StatusBar } from 'react-native'
import { NavigationContainer, DefaultTheme } from '@react-navigation/native'
import { createNativeStackNavigator } from '@react-navigation/native-stack'
import { getAuth, onAuthStateChanged } from 'firebase/auth'
import { PisangProvider } from './src/utils'
import Landing from './src/components/Landing'
import Login from './src/components/Login'
import Register from './src/components/Register'
import Home from './src/components/Home'
import PisangList from './src/components/PisangList'
import PisangDetail from './src/components/PisangDetail'
const Stack = createNativeStackNavigator()
const customTheme = {
...DefaultTheme,
colors: {
...DefaultTheme,
background: 'transparent'
},
}
const auth = getAuth()
function App() {
const [user, setUser] = React.useState(null)
React.useEffect(() => {
const unsubscribe = onAuthStateChanged(auth, user => setUser(user))
return unsubscribe
}, [])
if (!user) {
return (
<SafeAreaView style={{ marginTop: StatusBar.currentHeight, flex: 1 }}>
<NavigationContainer theme={customTheme}>
<Stack.Navigator initialRouteName="Landing" screenOptions={{ headerShown: false }}>
<Stack.Screen name="Landing" component={Landing} />
<Stack.Screen name="Login" component={Login} />
<Stack.Screen name="Register" component={Register} />
</Stack.Navigator>
</NavigationContainer>
</SafeAreaView >
)
}
return (
<PisangProvider>
<SafeAreaView style={{ marginTop: StatusBar.currentHeight, flex: 1 }}>
<NavigationContainer theme={customTheme}>
<Stack.Navigator initialRouteName="Home" screenOptions={{ headerShown: false }}>
<Stack.Screen name="Home" component={Home} />
<Stack.Screen name="PisangList" component={PisangList} options={{
headerShown: true,
headerTitle: 'Daftar Pisang',
headerTintColor: 'white',
headerStyle: { backgroundColor: '#FFC100' }
}} />
<Stack.Screen name="PisangDetail" component={PisangDetail} options={{
headerShown: true,
headerTitle: 'Daftar Pisang',
headerTintColor: 'white',
headerStyle: { backgroundColor: '#FFC100' }
}} />
</Stack.Navigator>
</NavigationContainer>
</SafeAreaView >
</PisangProvider>
)
}
export default App