Last active
October 23, 2019 16:29
-
-
Save artyorsh/89a479883a2863ceadd84f20192dd018 to your computer and use it in GitHub Desktop.
Drawer component for Home Navigator (Binding React Navigation 5 to Eva Design System)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { Drawer, DrawerElement, MenuItemType } from 'react-native-ui-kitten'; | |
import { InfoIcon, LogoutIcon } from '@app-assets/icons'; | |
import { AppRoute } from '@app-navigation/app-routes'; | |
import { SafeAreaLayout, SaveAreaInset} from '@app-components/safe-area-layout.component'; | |
const drawerData: MenuItemType[] = [ | |
{ icon: InfoIcon, title: 'About' }, | |
{ icon: LogoutIcon, title: 'Log Out' }, | |
]; | |
export const DrawerHomeScreen = (props): DrawerElement => { | |
const onMenuItemSelect = (index: number): void => { | |
const { [index]: selectedItem } = drawerData; | |
switch (selectedItem.title) { | |
case 'Log Out': | |
props.navigation.navigate(AppRoute.AUTH); | |
break; | |
default: | |
props.navigation.navigate(selectedItem.title); | |
break; | |
} | |
props.navigation.closeDrawer(); | |
}; | |
return ( | |
<SafeAreaLayout insets={SaveAreaInset.TOP}> | |
<Drawer data={drawerData} onSelect={onMenuItemSelect} /> | |
</SafeAreaLayout> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment