-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
77 lines (69 loc) · 2.16 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
74
75
76
77
import React, { useState } from "react";
import styled from "styled-components";
import { Button } from "react-native";
import { Provider } from "react-redux";
import store from "./shared/store";
import AuthScreen from "./Screens/AuthScreen/AuthScreen";
import MoviesScreen from "./Screens/MoviesScreen/MoviesScreen";
import { NavigationContainer } from "@react-navigation/native";
import {
createDrawerNavigator,
DrawerContentScrollView,
DrawerItem,
DrawerItemList,
} from "@react-navigation/drawer";
import FavoriteScreen from "./Screens/FavoriteScreen/FavoriteScreen";
import { PersistGate } from "redux-persist/integration/react";
const Drawer = createDrawerNavigator();
const Root = styled.View`
flex: 1;
justify-content: center;
`;
const App = () => {
const [isLogin, setIsLogin] = useState(false);
const createHomeStack = () => (
<AuthScreen isLogin={isLogin} setIsLogin={setIsLogin}></AuthScreen>
);
return (
<Provider store={store.store}>
<PersistGate loading={null} persistor={store.persistor}>
<NavigationContainer>
<Drawer.Navigator
initialRouteName="Home"
drawerContent={(props) => {
return (
<DrawerContentScrollView>
<DrawerItemList {...props}></DrawerItemList>
{isLogin && (
<DrawerItem
label="Logout"
onPress={() => setIsLogin(false)}
/>
)}
</DrawerContentScrollView>
);
}}
>
<Drawer.Screen
name="home"
component={createHomeStack}
></Drawer.Screen>
{isLogin && (
<>
<Drawer.Screen
name="Movies"
component={MoviesScreen}
></Drawer.Screen>
<Drawer.Screen
name="Favorites"
component={FavoriteScreen}
></Drawer.Screen>
</>
)}
</Drawer.Navigator>
</NavigationContainer>
</PersistGate>
</Provider>
);
};
export default App;