-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathApp.js
More file actions
86 lines (79 loc) · 2.45 KB
/
App.js
File metadata and controls
86 lines (79 loc) · 2.45 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import React, {useState, useContext} from 'react';
import {View, Dimensions} from 'react-native';
import Animated, {interpolate} from 'react-native-reanimated';
import {createDrawerNavigator} from '@react-navigation/drawer';
import {NavigationContainer} from '@react-navigation/native';
import styled from 'styled-components/native';
import {
DrawerContentScrollView,
DrawerItemList,
} from '@react-navigation/drawer';
import HomeScreen from './HomePage';
import OtherScreen from './OtherScreen';
import {withFancyDrawer} from './withFancyHeader';
export const THEME_COLOR = '#0069fe';
// We are gonna use react Context to passe the progress animated Value
// from react-navigation drawer to the Wrapper
export const AnimatedContext = React.createContext(void 0);
const Drawer = createDrawerNavigator();
/**
* The drawer itself
*/
function CustomDrawerContent(props) {
return (
<DrawerContentScrollView {...props}>
<FakeDrawerHeader>
<AppTitle>FancyDrawer</AppTitle>
</FakeDrawerHeader>
<DrawerItemList
inactiveBackgroundColor={'transparent'}
inactiveTintColor={'white'}
activeBackgroundColor={'#FFFFFF88'}
activeTintColor={'white'}
{...props}
/>
</DrawerContentScrollView>
);
}
export default function App() {
const [animatedValue, setAnimatedValue] = useState(new Animated.Value(0));
return (
<AnimatedContext.Provider value={animatedValue}>
<View style={{backgroundColor: THEME_COLOR, flex: 1}}>
<NavigationContainer>
<Drawer.Navigator
drawerStyle={{
backgroundColor: 'transparent',
}}
drawerType={'slide'}
initialRouteName="Home"
overlayColor="transparent"
drawerContent={props => {
setAnimatedValue(props.progress);
return <CustomDrawerContent {...props} />;
}}>
<Drawer.Screen
name="Home"
component={withFancyDrawer(HomeScreen)}
/>
<Drawer.Screen
name="OtherScreen"
component={withFancyDrawer(OtherScreen)}
/>
</Drawer.Navigator>
</NavigationContainer>
</View>
</AnimatedContext.Provider>
);
}
const FakeDrawerHeader = styled.View`
width: 100%;
aspect-ratio: 1.5;
align-items: center;
justify-content: center;
`;
const AppTitle = styled.Text`
font-size: 22px;
color: white;
font-weight: bold;
`;