1.1.0 • Published 3 years ago

@stanislav7766/rn-menu-drawer v1.1.0

Weekly downloads
4
License
MIT
Repository
github
Last release
3 years ago

Installation:

npm install --save @stanislav7766/rn-menu-drawer

yarn add @stanislav7766/rn-menu-drawer

Examples:

MenuDrawer usage:

// body of your component
...
// impelementing MenuContent, YourScreen
...
  const [showMenu, setShowMenu] = useState(false);
...
 const ScreenWithMenu = (
    <MenuDrawer
      open={showMenu}
      onShowMenu={setShowMenu}
      opacity={0.35}
      backgroundColor='#000'
      drawerWidth={300}
      animationTime={250}
      allowedSwipeWidth={200}
      tapToClose
      paddingGesture={50}
      position="right"
      MenuContent={SomeMenuContent}>
      {YourScreen}
    </MenuDrawer>
  );
...
// return
return {ScreenWithMenu};

useMenuDrawer(default params) usage:

// body of your component
...
// impelementing MenuContent, YourScreen
...
   const [ScreenWithMenu] = useMenuDrawer({
    MenuContent,
    children: YourApp,
  });
...
// return
return {ScreenWithMenu};

useMenuDrawer usage:

// body of your component
...
// impelementing MenuContent, YourScreen
...
  const [ScreenWithMenu, onShowMenu, onHideMenu] = useMenuDrawer({
    opacity: 0.35,
    backgroundColor: '#000',
    drawerWidth: 300,
    animationTime: 250,
    tapToClose: true,
    paddingGesture: 50,
    position: 'left',
    MenuContent,
    children: YourApp,
  });
...
//calling onShowMenu, onHideMenu for managing menu side. For example, onPress
...
// return
return {ScreenWithMenu};

Video usage:

see video

Props:

MenuDrawer Props:

PropTypeRequiredDefault ValueDesciption
openbooleantrue-If true, shows menu side otherwise hides
onShowMenu(show: boolean) => voidtrue-Need for manage open prop
tapToClosebooleantrue-If true, single tap outside of menu area - hides menu otherwise notihing happened
position'left', 'right'true-Set menu position on screen
paddingGesturenumbertrue-Define area for hand gesture to show menu
drawerWidthnumbertrue-Set menu width on screen
allowedSwipeWidthnumberfalsewidth_screen*0.5Set width of hand swipe that manages menu side. If real swipe's width >= 'your_value', menu side will be opened\hidden otherwise will be returned to it's original
animationTimenumbertrue-Set animation time on show\hide menu side
opacitynumbertrue-Set max opacity value to children's mask. Opacity will be dynamically changed from 0 to 'your_value' on 'moving state'. Use range 0..1
backgroundColorstringtrue-Set background color to children's mask. Background color will be applied to mask on 'moving state' only. Use hex or rgb colors
MenuContentJSX.Elementtrue-It's your component that will be rendered on menu side
childrenReact.ReactNodetrue-It's your app\screen component that will be wrapped by MenuDrawer

useMenuDrawer params:

paramTypeRequiredDefault Value
tapToClosebooleanfalsetrue
position'left', 'right'false'right'
paddingGesturenumberfalse50
drawerWidthnumberfalsewidth_screen*0.7
allowedSwipeWidthnumberfalsewidth_screen*0.5
animationTimenumberfalse250
opacitynumberfalse0.35
backgroundColorstringfalse'#000'
MenuContentJSX.Elementtrue-
childrenReact.ReactNodetrue-