Last active
June 24, 2016 18:59
-
-
Save xseignard/e71b8c00540ddab87a8d2221b769c2e1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import React, { Component } from 'react'; | |
import { DrawerLayoutAndroid } from 'react-native'; | |
import { Provider } from 'react-redux'; | |
import { store } from './store'; | |
import NavRoot from './components/NavRoot'; | |
import Menu from './components/Menu'; | |
import { startWatch, stopWatch } from './services/geolocator'; | |
import { startCheckZones, stopCheckZones } from './services/zonesChecker'; | |
export default class Main extends Component { | |
static childContextTypes = { | |
drawer: React.PropTypes.object, | |
}; | |
constructor(props) { | |
super(props); | |
this.state = { drawer: null }; | |
} | |
getChildContext() { | |
return { drawer: this.state.drawer }; | |
} | |
componentDidMount() { | |
startWatch(); | |
startCheckZones(); | |
// eslint-disable-next-line | |
if (!this.state.drawer) this.setState({ drawer: this.refs.DRAWER }); | |
} | |
componentWillUnmount() { | |
stopWatch(); | |
stopCheckZones(); | |
} | |
setDrawer(drawer) { | |
this.setState({ drawer }); | |
} | |
render() { | |
return ( | |
<Provider store={store}> | |
<DrawerLayoutAndroid | |
drawerWidth={300} | |
drawerPosition={DrawerLayoutAndroid.positions.Left} | |
renderNavigationView={() => <Menu />} | |
ref="DRAWER" | |
> | |
<NavRoot /> | |
</DrawerLayoutAndroid> | |
</Provider> | |
); | |
} | |
} |
Author
xseignard
commented
Jun 24, 2016
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment