MCPcopy Index your code
hub / github.com/Tinysymphony/react-native-drawer-menu

github.com/Tinysymphony/react-native-drawer-menu @v0.2.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.2.2 ↗ · + Follow
42 symbols 99 edges 8 files 1 documented · 2%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

react-native-drawer-menu Build Status Coverage Status

A drawer component for React Native Application (ios / android)

Similar to drawer menu component of QQ mobile.

Examples

iOS Platform

Android Platform

Usage

SUGGESTION In iOS, the drawer menu component should only be used in the top level route, because the action that swipes from left side of the screen to right is designed to pop route from navigate stack. You are supposed to avoid the conflict of the UI interactions. At least, don't use the Left drawer menu to wrap sub routes, use Right drawer menu if it's needed.

install from npm

npm install --save react-native-drawer-menu

import in project

import Drawer from 'react-native-drawer-menu';
import {Easing} from 'react-native'; // Customize easing function (Optional)
// in render function
render() {
  // prepare your drawer content
  var drawerContent = (<View style={styles.drawerContent}>
    <View style={styles.leftTop}/>
    <View style={styles.leftBottom}>
      <View><Text>Drawer Content</Text></View>
    </View>
  </View>);
  // customize drawer's style (Optional)
  var customStyles = {
    drawer: {
      shadowColor: '#000',
      shadowOpacity: 0.4,
      shadowRadius: 10
    },
    mask: {}, // style of mask if it is enabled
    main: {} // style of main board
  };
  return (
    <Drawer
      style={styles.container}
      drawerWidth={300}
      drawerContent={drawerContent}
      type={Drawer.types.Overlay}
      customStyles={{drawer: styles.drawer}}
      drawerPosition={Drawer.positions.Right}
      onDrawerOpen={() => {console.log('Drawer is opened');}}
      onDrawerClose={() => {console.log('Drawer is closed')}}
      easingFunc={Easing.ease}
    >
      <View style={styles.content}>
        <Text>{Object.values(Drawer.positions).join(' ')}</Text>
        <Text>{Object.values(Drawer.types).join(' ')}</Text>
      </View>
    </Drawer>
  );
}

Notice: The reference of the drawer is passed to drawer content element, you could use this.props.drawer to invoke Drawer's instance methods like this.props.drawer.closeDrawer()

Properties

Property Type Default Description
disabled Bool false Whether the drawer menu is disabled or not.
type String ‘default' Type of the drawer. default / overlay You can also use static value Drawer.type.Default / Drawer.type.Overlay.
drawerPosition String ‘left' Determine where does the drawer come out. left / right / both You can also use static value Drawer.positions.Left / Drawer.positions.Right / Drawer.positions.Both.
drawerWidth Number 200 The width of drawer, it’s disabled when use replace type.
drawerContent React Component null The content of the drawer menu, default is left content.
leftDrawerContent React Component null The content of the left drawer menu.
rightDrawerContent React Component null The content of the right drawer menu.
duration Number 160 The duration of animation to open or close drawer.
maskAlpha Number 0.4 Maximum value is 0.5, the opactiy value of the mask over the main board when drawer is open. Mask can be disabled with showMask property.
showMask Bool true Whether show the mask when drawer is open.
customStyles Object {} Customize drawer styles. You can customize main / mask / drawer / leftDrawer / rightDrawer.
onDrawerOpen function null Triggers when drawer is totally opened.
onLeftDrawerOpen function null Triggers when the left drawer is totally opened.
onRightDrawerOpen function null Triggers when the right drawer is totally opened.
onDrawerClose function null Triggers when drawer is totally closed.
onLeftDrawerClose function null Triggers when the left drawer is totally closed.
onRightDrawerClose function null Triggers when the right drawer is totally closed.
startCapture Bool false Whether to capture touch events while clicking on screen.
moveCapture Bool false Whether to capture touch events while swiping over the screen.
easingFunc function null Easing function of drawer animation, default is Easing.linear. You can pass function like Easing.ease/Easing.bezier(x1, y1, x2, y2)/Easing.sin/Easing.elastic(times)/Easing.bounce etc.
responderNegotiate function null Customize conditions to set pan responder, evt & gestureState will be passed as arguments. Default condition is left 20% area on screen in left Drawer, or right 20% area on screen in right Drawer.

Instance methods

Use ref to invoke instance methods.

Method Description
openDrawer Open drawer manually
openLeftDrawer Open left drawer manually
openRightDrawer Open right drawer manually
closeDrawer Close drawer manually. The drawerContent has a ref of drawer instance, you can also trigger with it.
closeLeftDrawer Close left drawer manually
closeRightDrawer Close right drawer manually

Core symbols most depended-on inside this repo

_handlePanResponderMove
called by 7
Drawer/index.js
_updateNativeStyles
called by 7
Drawer/index.js
openDrawer
called by 6
Drawer/index.js
_touchPositionCheck
called by 5
Drawer/index.js
closeDrawer
called by 5
Drawer/index.js
_handlePanResponderEnd
called by 4
Drawer/index.js
_onMoveShouldSetPanResponder
called by 3
Drawer/index.js
_getCurrentDrawerWidth
called by 3
Drawer/index.js

Shape

Method 34
Class 5
Function 3

Languages

TypeScript83%
Java17%

Modules by API surface

Drawer/index.js31 symbols
android/app/src/main/java/com/drawer/MainApplication.java5 symbols
index.ios.js3 symbols
android/app/src/main/java/com/drawer/MainActivity.java2 symbols
Drawer/Animation.js1 symbols

For agents

$ claude mcp add react-native-drawer-menu \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page