Skip to main content

FancyDrawer

Component

The withFancyDrawer function is a HOC that enhances a given component with additional animations and styles to simulate a fancy drawer effect.

The code makes use of React hooks and animation libraries (useDrawerProgress, useDrawerStatus, and useAnimatedStyle) to dynamically apply animations based on the drawer's state and progress.

withFancyDrawer

Type: withFancyDrawer<T>(Component: React.ComponentType<React.PropsWithChildren<T>>)

Example

/src/components/CustomDrawerContent.js
import React from 'react';
import {
DrawerContentComponentProps,
DrawerContentScrollView,
DrawerItem,
DrawerItemList,
} from '@react-navigation/drawer';
import { View, StyleSheet } from 'react-native';

import Avatar from '@flexnative/avatar';
import Ionicons from '@expo/vector-icons/Ionicons';


const profilePic = require("../../../assets/icon.png");

/**
* The drawer itself
*/
export default (props: DrawerContentComponentProps) => {
return (
<DrawerContentScrollView style={styles.container} {...props} >
<Avatar style={styles.avatar} source={profilePic} size='large' />
<DrawerItemList {...props} />
<Separator />
<DrawerItem
label="Logout"
activeTintColor='white'
inactiveTintColor='white'
icon={(props) => <Ionicons name="log-out-outline" size={props.size} color={props.color}/> }
onPress={() => console.log('help')}
/>
</DrawerContentScrollView>
);
}

const Separator = () => (
<View style={styles.separator}></View>
)

const styles = StyleSheet.create({
container: {
paddingTop: 50
},
avatar: {
marginBottom: DEMO_COMPONENT_GAP
},
separator: {
margin: 15,
height: 1,
width: '100%',
backgroundColor: '#ffffff30',
}
});