forked from BlueWallet/BlueWallet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NavigationService.ts
36 lines (30 loc) · 914 Bytes
/
NavigationService.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { createNavigationContainerRef, NavigationAction, ParamListBase, StackActions } from '@react-navigation/native';
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);
}
}
export function reset() {
if (navigationRef.isReady()) {
navigationRef.current?.reset({
index: 0,
routes: [{ name: 'UnlockWithScreen' }],
});
}
}
export function popToTop() {
if (navigationRef.isReady()) {
navigationRef.current?.dispatch(StackActions.popToTop());
}
}
export function pop() {
if (navigationRef.isReady()) {
navigationRef.current?.dispatch(StackActions.pop());
}
}