fix(dae): navigation back
This commit is contained in:
parent
cf00b5cea4
commit
59ccc13836
2 changed files with 20 additions and 2 deletions
|
|
@ -85,6 +85,7 @@ export default React.memo(function DrawerNav() {
|
|||
|
||||
return (
|
||||
<Drawer.Navigator
|
||||
backBehavior="history"
|
||||
drawerContent={(props) => <DrawerContent {...props} />}
|
||||
drawerStyle={{
|
||||
width: getDefaultDrawerWidth(dimensions),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import React from "react";
|
||||
|
||||
import { Image } from "react-native";
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
import { useNavigation, CommonActions } from "@react-navigation/native";
|
||||
import { HeaderBackButton } from "@react-navigation/elements";
|
||||
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
||||
|
||||
|
|
@ -28,7 +28,24 @@ export default function HeaderLeft(props) {
|
|||
if (canGoBack) {
|
||||
navigation.goBack();
|
||||
} else {
|
||||
navigation.navigate(drawerState.topTabPrev || "SendAlert");
|
||||
// HeaderLeft is rendered by the RootStack which has a single
|
||||
// "Main" screen, so canGoBack is always false here.
|
||||
// Dispatch GO_BACK targeted at the Drawer navigator so it
|
||||
// uses its history-based back behaviour.
|
||||
const rootState = navigation.getState();
|
||||
const drawerNavState = rootState.routes[0]?.state;
|
||||
if (
|
||||
drawerNavState?.key &&
|
||||
drawerNavState.history?.filter((h) => h.type === "route")
|
||||
.length > 1
|
||||
) {
|
||||
navigation.dispatch({
|
||||
...CommonActions.goBack(),
|
||||
target: drawerNavState.key,
|
||||
});
|
||||
} else {
|
||||
navigation.navigate(drawerState.topTabPrev || "SendAlert");
|
||||
}
|
||||
}
|
||||
}}
|
||||
backImage={() => (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue