Created
April 7, 2024 10:32
-
-
Save alperbayram/e437c7028ae56760dbbcdee1da6d618e to your computer and use it in GitHub Desktop.
drawer
This file contains 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 { Drawer } from "expo-router/drawer"; | |
import { | |
Button, | |
useWindowDimensions, | |
} from "react-native"; | |
import { useNavigation } from "expo-router"; | |
import { DrawerActions } from "@react-navigation/native"; | |
export default function Layout() { | |
const dimensions = useWindowDimensions(); | |
const navigation = useNavigation(); | |
const openDrawer = () => { | |
navigation.dispatch(DrawerActions.openDrawer()); | |
}; | |
return ( | |
<Drawer | |
screenOptions={{ | |
headerRight: () => ( | |
<Button | |
title="drawer" | |
onPress={() => navigation.dispatch(DrawerActions.openDrawer())} | |
/> | |
), | |
headerLeft: () => <></>, | |
drawerPosition: "right", | |
drawerType: dimensions.width >= 768 ? "permanent" : "front", | |
}} | |
> | |
<Drawer.Screen | |
name="profile" | |
options={{ | |
drawerLabel: "Profile", | |
title: "Profile", | |
}} | |
/> | |
<Drawer.Screen | |
name="dashboard" | |
options={{ | |
drawerLabel: "Dashboard", | |
title: "dashboard", | |
}} | |
/> | |
<Drawer.Screen | |
name="favorites" | |
options={{ | |
drawerLabel: "Favorites", | |
title: "favorites", | |
}} | |
/> | |
</Drawer> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment