2024-06-04 03:27:21 +02:00
|
|
|
import { createNavigationContainerRef, NavigationAction, ParamListBase, StackActions } from '@react-navigation/native';
|
2024-01-05 18:50:07 +01:00
|
|
|
|
|
|
|
export const navigationRef = createNavigationContainerRef<ParamListBase>();
|
|
|
|
|
|
|
|
export function navigate(name: string, params?: ParamListBase) {
|
|
|
|
if (navigationRef.isReady()) {
|
|
|
|
navigationRef.current?.navigate(name, params);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function dispatch(action: NavigationAction) {
|
|
|
|
if (navigationRef.isReady()) {
|
|
|
|
navigationRef.current?.dispatch(action);
|
|
|
|
}
|
|
|
|
}
|
2024-02-24 16:08:10 +01:00
|
|
|
|
|
|
|
export function reset() {
|
|
|
|
if (navigationRef.isReady()) {
|
|
|
|
navigationRef.current?.reset({
|
|
|
|
index: 0,
|
2024-06-04 03:27:21 +02:00
|
|
|
routes: [{ name: 'UnlockWithScreen' }],
|
2024-02-24 16:08:10 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2024-06-04 03:27:21 +02:00
|
|
|
|
|
|
|
export function popToTop() {
|
|
|
|
if (navigationRef.isReady()) {
|
|
|
|
navigationRef.current?.dispatch(StackActions.popToTop());
|
|
|
|
}
|
|
|
|
}
|
2024-06-08 18:01:56 +02:00
|
|
|
|
|
|
|
export function pop() {
|
|
|
|
if (navigationRef.isReady()) {
|
|
|
|
navigationRef.current?.dispatch(StackActions.pop());
|
|
|
|
}
|
|
|
|
}
|