-
-
Save cleverg/df69b949a0f4d78af406f93f5e1ea64f 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
import React, {Component} from 'react'; | |
import { | |
AppRegistry, | |
StyleSheet, | |
Text, | |
View, | |
Button, | |
Navigator | |
} from 'react-native'; | |
import Menu from './app/componentes/Menu'; | |
const SideMenu = require('react-native-side-menu'); | |
export default class Aplicacion extends Component { | |
constructor() | |
{ | |
super(); | |
this.state = { | |
isOpen: false, | |
selectedItem: 'Home' | |
}; | |
} | |
toggle() | |
{ | |
this.setState({ | |
isOpen: !this.state.isOpen | |
}) | |
} | |
updateMenuState(isOpen) | |
{ | |
this.setState({isOpen}) | |
} | |
//al seleccionar un elemento del menú | |
onMenuItemSelected = (el) => { | |
//cerramos el menú | |
this.setState({ | |
isOpen: false, | |
selectedItem: el.item, | |
}); | |
//navegamos al componente | |
this.refs.navigator.push({ | |
component: el.component | |
}) | |
} | |
render() | |
{ | |
const menu = <Menu | |
navigator={navigator} | |
onItemSelected={this.onMenuItemSelected} | |
/> | |
return ( | |
<View style={{flex: 1}}> | |
<SideMenu | |
menu={menu} | |
isOpen={this.state.isOpen} | |
onChange={(isOpen) => this.updateMenuState(isOpen)} | |
> | |
<Text | |
style={{padding: 10, backgroundColor: 'black', color: 'white', textAlign: 'center'}} | |
> | |
{this.state.selectedItem} | |
</Text> | |
</SideMenu> | |
</View> | |
); | |
} | |
} | |
AppRegistry.registerComponent('Aplicacion', () => Aplicacion); |
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
{ | |
"name": "Aplicacion", | |
"version": "0.0.1", | |
"private": true, | |
"scripts": { | |
"start": "node node_modules/react-native/local-cli/cli.js start", | |
"test": "jest" | |
}, | |
"dependencies": { | |
"react": "16.0.0-alpha.12", | |
"react-native": "0.46.4", | |
"react-native-side-menu": "^1.0.2" | |
}, | |
"devDependencies": { | |
"babel-jest": "20.0.3", | |
"babel-preset-react-native": "2.1.0", | |
"jest": "20.0.4", | |
"react-test-renderer": "16.0.0-alpha.12" | |
}, | |
"jest": { | |
"preset": "react-native" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment