-
Notifications
You must be signed in to change notification settings - Fork 0
/
CustomDrawer.tsx
56 lines (48 loc) · 1.61 KB
/
CustomDrawer.tsx
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
import React from 'react';
import {View, Text} from 'react-native';
import {
DrawerContentComponentProps,
useDrawerProgress,
} from '@react-navigation/drawer';
import Animated, {interpolate, useAnimatedStyle} from 'react-native-reanimated';
import {useSafeAreaInsets} from 'react-native-safe-area-context';
import drawerStyles from './drawer.styles';
import DrawerItem from '../../components/layout/navigation/drawer/DrawerItem';
import DrawerItemList from '../../components/layout/navigation/drawer/DrawerItemList';
export default function CustomDrawer(props: DrawerContentComponentProps) {
const drawerProgress: any = useDrawerProgress();
const {top: topInset} = useSafeAreaInsets();
const animatedStyles = useAnimatedStyle(() => {
const translateY: number = interpolate(
drawerProgress.value,
[0, 1],
[0, topInset],
);
const borderTopRadius: number = interpolate(
drawerProgress.value,
[0, 1],
[0, 45],
);
return {
transform: [{translateY}],
borderTopLeftRadius: borderTopRadius,
};
});
return (
<Animated.ScrollView
style={[drawerStyles.contentContainerStyles, animatedStyles]}>
<View style={drawerStyles.drawerHeaderContainer}>
<Text style={drawerStyles.logoText}>Beka</Text>
</View>
<View style={drawerStyles.customDrawerContentContainer}>
<DrawerItemList {...props} />
</View>
<View style={drawerStyles.drawerFooterStyles}>
<DrawerItem
item={{title: 'Sign Out'}}
onPress={() => console.log('Sign Out')}
/>
</View>
</Animated.ScrollView>
);
}