Created
August 26, 2017 20:44
-
-
Save dk0r/a1e21478ef491e02aa862c4cbee4cd70 to your computer and use it in GitHub Desktop.
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
class LoggedInWrap extends Component { | |
state = { | |
route: { | |
routeName: "Home", | |
}, | |
}; | |
openDrawer = () => { | |
this.drawer.openDrawer(); | |
}; | |
closeDrawer = () => { | |
this.drawer.closeDrawer(); | |
}; | |
handleNavigate = (location, params) => { | |
const navigateAction = NavigationActions.navigate({ | |
routeName: location, | |
params, | |
}); | |
this.closeDrawer(); | |
this.nav.dispatch(navigateAction); | |
}; | |
onNavigationStateChange = (prevState, newState, action) => { | |
this.setState({ | |
route: newState.routes[newState.index], | |
}); | |
}; | |
render() { | |
return ( | |
<View style={{ flex: 1 }}> | |
<Drawer | |
ref={drawer => (this.drawer = drawer)} | |
drawerWidth={width - 50} | |
renderNavigationView={() => | |
<DrawerComponent activeItem={this.state.route} navigate={this.handleNavigate} />} | |
hitSlop={{ top: 0, bottom: 0, left: 0, right: 20 }} | |
> | |
<LoggedInNav | |
ref={nav => (this.nav = nav)} | |
screenProps={{ openDrawer: this.openDrawer }} | |
onNavigationStateChange={this.onNavigationStateChange} | |
/> | |
</Drawer> | |
</View> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment