1

我有一个Navigation Drawer应该出现在我的所有屏幕中(屏幕除外Splash)。

我是这样的:


const Stack = createStackNavigator();
const Drawer = createDrawerNavigator();

const StackNavigator = () => {
    return (
        <Stack.Navigator>
            <Stack.Screen name="EstateDetails" component={Screens.EstateDetails} />
            <Stack.Screen name="Tour" component={Screens.Tour} />
            <Stack.Screen name="Comparison" component={Screens.Comparison} />
            <Stack.Screen name="Blog" component={Screens.Blog} />
            <Stack.Screen name="Auth" component={Screens.Auth} />
        </Stack.Navigator>
    );
};

const DrawerNavigator = () => {
    return (
        <Drawer.Navigator drawerContent={props => CustomDrawerContent(props)}>
            <Drawer.Screen name="HomeScreen" component={Screens.Home} />
            <Drawer.Screen name="stack" component={StackNavigator} />
            <Drawer.Screen name="RegisterEstate" component={Screens.RegisterEstate} />
            <Drawer.Screen name="Filter" component={Screens.Filter} />
            <Drawer.Screen name="Conditions" component={Screens.Conditions} />
            <Drawer.Screen name="Judicial" component={Screens.Judicial} />
            <Drawer.Screen name="ContactUs" component={Screens.ContactUs} />
            <Drawer.Screen name="ReportBugs" component={Screens.ReportBugs} />
        </Drawer.Navigator>
    )
};

export const AppNavigator = () => {
    return (
        <NavigationContainer>
            <Stack.Navigator initialRouteName="Splash">
                <Stack.Screen name="Splash" component={Screens.Splash}/>
                <Stack.Screen name="Home" component={DrawerNavigator}/>
            </Stack.Navigator>
        </NavigationContainer>
    );
};

在这种情况下,所有正常的堆栈屏幕都充当抽屉屏幕。(屏幕只加载一次,下次显示初始加载,如博客屏幕)。‌</p>

我需要将光标放在除启动画面之外的所有页面上并堆叠我的一些页面(例如没有相同内容的动态页面)

4

1 回答 1

2

如果您想在所有其他屏幕中显示相同的抽屉,只需将 {DrawerNavigator} 传递给您要显示抽屉的所有其他屏幕。因此,在您的示例中,如果您想在旅游和博客屏幕中显示抽屉,只需添加

<Stack.Screen name="Blog " component={DrawerNavigator} />
<Stack.Screen name="Tour" component={DrawerNavigator} />

现在您可以在博客和旅游屏幕中访问。

如果您想在其他屏幕中显示不同的抽屉,请创建一个新功能。

于 2020-10-23T12:21:16.780 回答