嗨朋友,我在最近2天的反应导航中摸不着头脑,我尝试了很多东西(文档对于初学者来说似乎不太清楚),所以现在我面临的一些问题对我来说似乎并不复杂,因此我寻求建议和帮助继续进行 . 以下是我寻求帮助的案例/问题/情景 -
我使用下面的代码块来达到这一点
import React, {Component} from 'react';
import { AppRegistry, View, BackAndroid, StatusBar,} from 'react-native';
import {
NavigationActions,
addNavigationHelpers,
StackNavigator,
DrawerNavigator
} from 'react-navigation';
import LandingScreen from 'src/screens/landingScreen';
import Login from 'src/screens/login'
import SignUp from 'src/screens/signUp'
import ForgotPassword from 'src/screens/forgotPassword'
import Dashboard from 'src/screens/dashboard'
import UserProfile from 'src/screens/userProfile'
export const Drawer = DrawerNavigator({
Dashboard:{
path:'/',
screen:Dashboard,
},
UserProfile:{
path:'/'
screen:UserProfile
},
}, {
initialRouteName: 'Dashboard',
contentOptions: {
activeTintColor: '#e91e63',
},
headerMode: 'screen',
});
const routesConfig = {
Landing:{screen:LandingScreen},
Login: { screen: Login },
SignUp: { screen: SignUp },
ForgotPassword: { screen: ForgotPassword },
Drawer:{screen:Drawer}
};
export const AppNavigator = StackNavigator(routesConfig, {
initialRouteName: 'Drawer'
});
AppRegistry.registerComponent('Riduk', () => AppNavigator);
- Other problem is how should I add 2 drawers in my app at the same screen
5 回答
DrawerNavigator中有一个issue for Header .
但你可以使用 StackNavigator inside DrawerNavigator 修复
然后将
headerMode: 'none'
设置为 root StackNavigator这里,AppNavigator是根StackNavigator,routesConfig有DrawerNavigator和其他屏幕 .
这是一个简化的例子:
这是你要解决的问题吗?
https://blog.callstack.io/android-drawer-statusbar-done-right-for-react-native-7e85f01fc099
据我所知,你必须做两件事:1 . 将抽屉控件放在导航堆栈的顶部 . 2.设置StatusBar的
translucent
属性如果它确实有效,请告诉我 .
DrawerNavigator
必须在StackNavigator
上,这是我解决这个问题的方法:希望这可以帮助 .