在返回反应导航时省略一个抽屉
omit one drawer on going back with react navigation
用户可以像下面这样导航:
路径A(好)
概述 -> 游戏画面
返回:概述 <- GameplayScreen
路径B(不行)
概述 -> CreateGame -> GameplayScreen
返回:概述 <- CreateGame <- GameplayScreen
当用户返回时,他再次登陆“CreateGame”。当用户返回时,如何省略此页面?
<Drawer.Navigator
drawerPosition='right'
screenOptions={{
headerShown: true,
headerStyle: {
backgroundColor: colors.header_bg,
},
headerTintColor: '#fff',
headerTitleStyle: {
fontWeight: 'bold',
},
}}
>
<Drawer.Screen
name={t("Overview")}
component={HomeScreen}
initialParams={{signOut: signOut}}
options={{
headerRight: () => (
<HeaderButtons HeaderButtonComponent={IoniconsHeaderButton}>
<OverflowMenu
style={{ marginHorizontal: 10 }}
OverflowIcon={<Ionicons name="ios-more" size={23} color="white" />}
>
<HiddenItem title={t("signout")} onPress={signOut} />
</OverflowMenu>
</HeaderButtons>
),
}}
/>
<Drawer.Screen
name="GameplayScreen"
component={GameplayScreen}
options={{
title: t("playing"),
gestureEnabled: false,
}}
/>
<Drawer.Screen
name="UserChoser"
component={UserChoser}
options={{
title: t('otherUsers'),
gestureEnabled: true,
}}
/>
<Drawer.Screen
name="CreateGame"
component={CreateGame}
options={{
title: t('createGame'),
gestureEnabled: true,
}}
/>
<Drawer.Screen
name="DeleteGame"
component={DeleteGame}
options={{
title: t('deleteGame'),
gestureEnabled: true,
}}
/>
<Drawer.Screen
name="GameHistory"
component={GameHistory}
options={{
title: t('gameHistory'),
gestureEnabled: true,
}}
/>
<Drawer.Screen
name="UserProfile"
component={UserProfile}
options={{
title: t('userProfile'),
gestureEnabled: true,
}}
/>
</Drawer.Navigator>
导航到下一个屏幕时使用“replace()”而不是“navigate()”,例如 Snack.io
用户可以像下面这样导航:
路径A(好) 概述 -> 游戏画面 返回:概述 <- GameplayScreen
路径B(不行) 概述 -> CreateGame -> GameplayScreen 返回:概述 <- CreateGame <- GameplayScreen
当用户返回时,他再次登陆“CreateGame”。当用户返回时,如何省略此页面?
<Drawer.Navigator
drawerPosition='right'
screenOptions={{
headerShown: true,
headerStyle: {
backgroundColor: colors.header_bg,
},
headerTintColor: '#fff',
headerTitleStyle: {
fontWeight: 'bold',
},
}}
>
<Drawer.Screen
name={t("Overview")}
component={HomeScreen}
initialParams={{signOut: signOut}}
options={{
headerRight: () => (
<HeaderButtons HeaderButtonComponent={IoniconsHeaderButton}>
<OverflowMenu
style={{ marginHorizontal: 10 }}
OverflowIcon={<Ionicons name="ios-more" size={23} color="white" />}
>
<HiddenItem title={t("signout")} onPress={signOut} />
</OverflowMenu>
</HeaderButtons>
),
}}
/>
<Drawer.Screen
name="GameplayScreen"
component={GameplayScreen}
options={{
title: t("playing"),
gestureEnabled: false,
}}
/>
<Drawer.Screen
name="UserChoser"
component={UserChoser}
options={{
title: t('otherUsers'),
gestureEnabled: true,
}}
/>
<Drawer.Screen
name="CreateGame"
component={CreateGame}
options={{
title: t('createGame'),
gestureEnabled: true,
}}
/>
<Drawer.Screen
name="DeleteGame"
component={DeleteGame}
options={{
title: t('deleteGame'),
gestureEnabled: true,
}}
/>
<Drawer.Screen
name="GameHistory"
component={GameHistory}
options={{
title: t('gameHistory'),
gestureEnabled: true,
}}
/>
<Drawer.Screen
name="UserProfile"
component={UserProfile}
options={{
title: t('userProfile'),
gestureEnabled: true,
}}
/>
</Drawer.Navigator>
导航到下一个屏幕时使用“replace()”而不是“navigate()”,例如 Snack.io