forked from BlueWallet/BlueWallet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NavigationService.ts
40 lines (33 loc) · 1.02 KB
/
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
37
38
39
40
import { createNavigationContainerRef, NavigationAction, ParamListBase, StackActions } from '@react-navigation/native';
export const navigationRef = createNavigationContainerRef<ParamListBase>();
export function navigate(name: string, params?: ParamListBase, options?: { merge: boolean }) {
if (navigationRef.isReady()) {
navigationRef.current?.navigate({ name, params, merge: options?.merge });
}
}
export function dispatch(action: NavigationAction) {
if (navigationRef.isReady()) {
navigationRef.current?.dispatch(action);
}
}
export function navigateToWalletsList() {
navigate('WalletsList');
}
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());
}
}