Skip to content

Instantly share code, notes, and snippets.

@alperbayram
Created April 7, 2024 10:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alperbayram/e437c7028ae56760dbbcdee1da6d618e to your computer and use it in GitHub Desktop.
Save alperbayram/e437c7028ae56760dbbcdee1da6d618e to your computer and use it in GitHub Desktop.
drawer
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