直到现在它呈现但没有打开抽屉。
我相信是与参考相关的东西,但我不确定。
如果有人可以帮助我,那就太棒了。
路由器.js
import React, { Component } from 'react';
import { Actions, Router, Scene } from 'react-native-router-flux';
import Dashboard from './components/dashboard';
import Home from './components/home';
import ViewCamera from './components/view-camera';
import Register from './components/register';
import SideDrawer from './components/sideDrawer';
import TabIcon from './components/tabIcon';
function openDrawer() {
return (<TabIcon
press={() => {
Actions.refresh({ key: 'drawer', open: true })
}}
/>);
}
class RouterComponent extends Component {
render() {
return (
<Router>
<Scene key="root">
<Scene
panHandlers={null}
key="home"
hideNavBar component={Home} title="Login" initial
/>
<Scene
panHandlers={null}
key="viewCamera"
hideNavBar component={ViewCamera} title="Captura del Documento"
/>
<Scene
panHandlers={null}
key="register"
hideNavBar component={Register} title="Registro"
/>
</Scene>
<Scene
key="drawer" component={SideDrawer}
>
<Scene
key="tabs"
tabs
>
<Scene
initial
panHandlers={null}
component={Dashboard}
hideTabBar
key="dashboard"
title="Propuestas"
renderLeftButton={openDrawer}
/>
{/*<Scene panHandlers={null} key="pollCreation" component={Poll} />*/}
</Scene>
</Scene>
</Router>
);
}
}
export default RouterComponent;
组件/tabIcon.js
import React, {
Component,
PropTypes,
StyleSheet
} from 'react';
import {
Text,
} from 'react-native';
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
import { Button } from 'native-base';
import { Actions } from 'react-native-router-flux';
const propTypes = {
selected: PropTypes.bool,
title: PropTypes.string,
};
class TabIcon extends Component {
render() {
return (
<Button
transparent
onPress={this.openDrawer.bind(this)} style={styles.navButton}
style={{ backgroundColor: 'rgba(0,0,0,0)' }}
>
<Text>
<MaterialIcons name="menu" size={30} />
</Text>
</Button>
);
}
openDrawer = () => {
Actions.get('drawer').ref.toggle();
};
}
TabIcon.propTypes = propTypes;
const styles = {
navButton: {
alignItems: 'flex-end',
flex: 1,
}
};
export default TabIcon;
sideDrawer.js
import React, { Component, PropTypes } from 'react';
import {
BackAndroid,
StyleSheet,
Text,
View,
} from 'react-native';
import { Drawer } from 'native-base';
import { DefaultRenderer, Actions } from 'react-native-router-flux';
import SideBar from './sidebar';
const propTypes = {
navigationState: PropTypes.object,
};
class SideDrawer extends Component {
static propTypes = {
closeDrawer: React.PropTypes.func,
drawerState: React.PropTypes.string,
}
constructor(props) {
super(props);
this.state = {
animatingLoadingSpinner: false,
url: 'polls',
};
}
componentDidMount() {
BackAndroid.addEventListener('hardwareBackPress', () => {
Actions.pollCreation();
});
Actions.refresh({ key: 'drawer', ref: this.refs.navigation });
}
finishSpinnerAnimation() {
this.setState({
animatingLoadingSpinner: false
});
}
startSpinnerAnimation() {
this.setState({
animatingLoadingSpinner: true
});
}
noServerConnection() {
return (
<View style={styles.errorBody} >
<Text > No es posible la conexión con Nuestros servidores </Text>
</View>
);
}
render() {
const state = this.props.navigationState;
const children = state.children;
return (
<View style={styles.container} >
<Drawer
ref='navigation'
type="overlay"
tweenDuration={150}
content={
<SideBar
closeDrawer={() => {
this.drawer.close();
}}
/>
}
tapToClose
acceptPan={false}
openDrawerOffset={0.2}
panCloseMask={0.2}
styles={{
drawer: {
shadowColor: '#000000',
shadowOpacity: 0.8,
shadowRadius: 3,
},
}}
tweenHandler={(ratio) => { // eslint-disable-line
return {
drawer: { shadowRadius: ratio < 0.2 ? ratio * 5 * 5 : 5 },
main: {
opacity: (2 - ratio) / 2,
},
};
}}
negotiatePan
onOpen={() => Actions.refresh({ key: state.key, open: true })}
onClose={() => Actions.refresh({ key: state.key, open: false })}
>
{/*<View style={{ marginTop: 45 }} />*/}
<DefaultRenderer navigationState={children[0]} onNavigate={this.props.onNavigate} />
</Drawer>
</View>
);
}
}
let WEBVIEW_REF = 'webview';
const BGWASH = '#F6F6F6';
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: BGWASH,
},
addressBarRow: {
flexDirection: 'row',
height: 10,
},
errorBody: {
alignItems: 'center',
justifyContent: 'center',
},
navButton: {
alignItems: 'flex-end',
flex: 1,
},
navText: {
fontSize: 18,
},
navTextContainer: {
alignItems: 'center',
flex: 8,
justifyContent: 'center',
},
});
SideDrawer.propTypes = propTypes;
export default SideDrawer;