Application Android et IOS pour l'amicale des élèves
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CustomSideMenu.js 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // @flow
  2. import * as React from 'react';
  3. import SideMenu from "react-native-side-menu";
  4. import SideBar from "./Sidebar";
  5. import {View} from "react-native";
  6. type Props = {
  7. navigation: Object,
  8. children: React.Node,
  9. isOpen: boolean,
  10. onChange: Function,
  11. }
  12. type State = {
  13. shouldShowMenu: boolean, // Prevent menu from showing in transitions between tabs
  14. }
  15. export default class CustomSideMenu extends React.Component<Props, State> {
  16. state = {
  17. shouldShowMenu: this.props.isOpen,
  18. };
  19. // Stop the side menu from being shown while tab transition is playing
  20. // => Hide the menu when behind the actual screen
  21. onMenuMove(percent: number) {
  22. if (percent <= 0)
  23. this.setState({shouldShowMenu: false});
  24. else if (this.state.shouldShowMenu === false)
  25. this.setState({shouldShowMenu: true});
  26. }
  27. render() {
  28. return (
  29. <SideMenu menu={
  30. this.state.shouldShowMenu ?
  31. <SideBar navigation={this.props.navigation}/>
  32. : <View/>}
  33. isOpen={this.props.isOpen}
  34. onChange={this.props.onChange}
  35. onSliding={(percent) => this.onMenuMove(percent)}>
  36. {this.props.children}
  37. </SideMenu>
  38. );
  39. }
  40. }