在反應本地的,我想在
Dashboard
屏幕上Login
禁用抽屜,抽屜啓用 。我已實施'react-native-drawer'
與Navigator
在路線之間導航。如何設置「反應母語抽屜」可見只有儀表盤登錄後在反應母語
渲染方法如下:
render() {
<Drawer
ref={(ref) => this._drawer = ref}
disabled={!this.state.drawerEnabled}
type="overlay"
content={<Menu navigate={(route) => {
this._navigator.push(navigationHelper(route));
this._drawer.close()
}}/>}
tapToClose={true}
openDrawerOffset={0.2}
panCloseMask={0.2}
closedDrawerOffset={-3}
styles={{
drawer: {shadowColor: '#000000', shadowOpacity: 0.8, shadowRadius: 3},
main: {paddingLeft: 3}
}}
tweenHandler={(ratio) => ({
main: { opacity:(2-ratio)/2 }
})}>
<Navigator
ref={(ref) => this._navigator = ref}
configureScene={(route) => Navigator.SceneConfigs.FloatFromLeft}
initialRoute={{
id: 'Login',
title: 'Login',
index: 0
}}
renderScene={(route, navigator) => this._renderScene(route, navigator)}
navigationBar={
<Navigator.NavigationBar
style={styles.navBar}
routeMapper={NavigationBarRouteMapper} />
}
/>
</Drawer>
);
}
renderScene如下導航路線:
_renderScene(route, navigator) {
navigator.navigate = self.navigate;
switch (route.id) {
case 'Login':
return (<Login navigator={navigator}/>);
case 'Dashboard':
return (<Dashboard navigator={navigator}/>);
}
}
我已經寫一個方法來啓用和在反應禁用抽屜-native:
navigate(route, method){
if(route)
switch (route.id) {
case 'Login':
this.state = {drawerEnabled: false, navigationBarEnabled: false};
break;
case 'Dashboard':
this.state = {drawerEnabled: true, navigationBarEnabled: true};
break;
}
this.forceUpdate();
this.refs.navigator[method](route);
}
}
最初我在類中和構造函數中設置了屬性,調用了導航方法。
state = {drawerEnabled:true, navigationBarEnabled: true};
constructor(){
super();
this.navigate = this.navigate.bind(this);
}
然後將Login
菜單上禁用抽屜,並使其在Dashboard
屏幕可能的方式。
精湛。其實現在我可以說。我在自己的戰略中犯了一個錯誤。我實際上是在不同的頁面上添加抽屜,這需要抽屜。 – SSS