hybrid-navigation 2.18.3 → 2.18.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/LICENSE +1 -1
  2. package/{lib → dist}/Navigation.js +3 -2
  3. package/{lib → dist}/NavigationComponentWrap.js +6 -5
  4. package/{lib → dist}/Navigator.d.ts +0 -1
  5. package/{lib → dist}/Navigator.js +15 -4
  6. package/{lib → dist}/hooks.js +2 -1
  7. package/{lib → dist}/router/index.js +6 -2
  8. package/{lib → dist}/router/stack.js +1 -1
  9. package/ios/HybridNavigation/HBDUtils.h +2 -0
  10. package/ios/HybridNavigation/HBDUtils.m +12 -3
  11. package/ios/HybridNavigation/ReactBridge/HBDGardenModule.m +2 -6
  12. package/ios/HybridNavigation/ReactBridge/HBDNavigationModule.m +11 -12
  13. package/ios/HybridNavigation/ViewController/HBDDrawerController.m +1 -1
  14. package/ios/HybridNavigation/ViewController/HBDNavigationController.m +1 -1
  15. package/ios/HybridNavigation/ViewController/HBDViewController.m +1 -1
  16. package/package.json +47 -78
  17. package/src/DeepLink.ts +52 -52
  18. package/src/Event.ts +88 -83
  19. package/src/GardenModule.ts +30 -30
  20. package/src/Navigation.ts +293 -281
  21. package/src/NavigationComponentWrap.tsx +52 -47
  22. package/src/NavigationModule.ts +77 -77
  23. package/src/Navigator.ts +212 -201
  24. package/src/Options.ts +120 -112
  25. package/src/Route.ts +59 -59
  26. package/src/handler/BarButtonEventHandler.ts +50 -46
  27. package/src/handler/DispatchCommandHandler.ts +56 -52
  28. package/src/handler/LayoutCommandHandler.ts +21 -21
  29. package/src/handler/ResultEventHandler.ts +63 -49
  30. package/src/handler/VisibilityEventHandler.ts +57 -40
  31. package/src/hooks.ts +23 -21
  32. package/src/index.ts +15 -15
  33. package/src/router/drawer.ts +24 -24
  34. package/src/router/index.ts +206 -198
  35. package/src/router/screen.ts +28 -28
  36. package/src/router/stack.ts +76 -76
  37. package/src/router/tabs.ts +28 -28
  38. package/src/store.ts +9 -9
  39. package/README.md +0 -79
  40. /package/{lib → dist}/DeepLink.d.ts +0 -0
  41. /package/{lib → dist}/DeepLink.js +0 -0
  42. /package/{lib → dist}/Event.d.ts +0 -0
  43. /package/{lib → dist}/Event.js +0 -0
  44. /package/{lib → dist}/GardenModule.d.ts +0 -0
  45. /package/{lib → dist}/GardenModule.js +0 -0
  46. /package/{lib → dist}/Navigation.d.ts +0 -0
  47. /package/{lib → dist}/NavigationComponentWrap.d.ts +0 -0
  48. /package/{lib → dist}/NavigationModule.d.ts +0 -0
  49. /package/{lib → dist}/NavigationModule.js +0 -0
  50. /package/{lib → dist}/Options.d.ts +0 -0
  51. /package/{lib → dist}/Options.js +0 -0
  52. /package/{lib → dist}/Route.d.ts +0 -0
  53. /package/{lib → dist}/Route.js +0 -0
  54. /package/{lib → dist}/handler/BarButtonEventHandler.d.ts +0 -0
  55. /package/{lib → dist}/handler/BarButtonEventHandler.js +0 -0
  56. /package/{lib → dist}/handler/DispatchCommandHandler.d.ts +0 -0
  57. /package/{lib → dist}/handler/DispatchCommandHandler.js +0 -0
  58. /package/{lib → dist}/handler/LayoutCommandHandler.d.ts +0 -0
  59. /package/{lib → dist}/handler/LayoutCommandHandler.js +0 -0
  60. /package/{lib → dist}/handler/ResultEventHandler.d.ts +0 -0
  61. /package/{lib → dist}/handler/ResultEventHandler.js +0 -0
  62. /package/{lib → dist}/handler/VisibilityEventHandler.d.ts +0 -0
  63. /package/{lib → dist}/handler/VisibilityEventHandler.js +0 -0
  64. /package/{lib → dist}/hooks.d.ts +0 -0
  65. /package/{lib → dist}/index.d.ts +0 -0
  66. /package/{lib → dist}/index.js +0 -0
  67. /package/{lib → dist}/router/drawer.d.ts +0 -0
  68. /package/{lib → dist}/router/drawer.js +0 -0
  69. /package/{lib → dist}/router/index.d.ts +0 -0
  70. /package/{lib → dist}/router/screen.d.ts +0 -0
  71. /package/{lib → dist}/router/screen.js +0 -0
  72. /package/{lib → dist}/router/stack.d.ts +0 -0
  73. /package/{lib → dist}/router/tabs.d.ts +0 -0
  74. /package/{lib → dist}/router/tabs.js +0 -0
  75. /package/{lib → dist}/store.d.ts +0 -0
  76. /package/{lib → dist}/store.js +0 -0
package/src/Event.ts CHANGED
@@ -1,112 +1,117 @@
1
- import { NativeModules, NativeEventEmitter, NativeModule } from 'react-native'
2
- import type { Visibility } from './Route'
1
+ import {NativeModules, NativeEventEmitter, NativeModule} from 'react-native';
2
+ import type {Visibility} from './Route';
3
3
  interface HBDEventEmitter extends NativeModule {
4
- getConstants: () => {
5
- EVENT_NAVIGATION: string
6
- EVENT_SWITCH_TAB: string
7
- EVENT_DID_SET_ROOT: string
8
- EVENT_WILL_SET_ROOT: string
9
- ON_COMPONENT_RESULT: string
10
- ON_BAR_BUTTON_ITEM_CLICK: string
11
- ON_COMPONENT_APPEAR: string
12
- ON_COMPONENT_DISAPPEAR: string
13
- KEY_REQUEST_CODE: string
14
- KEY_RESULT_CODE: string
15
- KEY_RESULT_DATA: string
16
- KEY_SCENE_ID: string
17
- KEY_MODULE_NAME: string
18
- KEY_INDEX: string
19
- KEY_ACTION: string
20
- KEY_ON: string
21
- }
4
+ getConstants: () => {
5
+ EVENT_NAVIGATION: string;
6
+ EVENT_SWITCH_TAB: string;
7
+ EVENT_DID_SET_ROOT: string;
8
+ EVENT_WILL_SET_ROOT: string;
9
+ ON_COMPONENT_RESULT: string;
10
+ ON_BAR_BUTTON_ITEM_CLICK: string;
11
+ ON_COMPONENT_APPEAR: string;
12
+ ON_COMPONENT_DISAPPEAR: string;
13
+ KEY_REQUEST_CODE: string;
14
+ KEY_RESULT_CODE: string;
15
+ KEY_RESULT_DATA: string;
16
+ KEY_SCENE_ID: string;
17
+ KEY_MODULE_NAME: string;
18
+ KEY_INDEX: string;
19
+ KEY_ACTION: string;
20
+ KEY_ON: string;
21
+ };
22
22
  }
23
23
 
24
- const HBDEventEmitter: HBDEventEmitter = NativeModules.HBDEventEmitter
25
- const HBDEventReceiver = new NativeEventEmitter(HBDEventEmitter)
24
+ const HBDEventEmitter: HBDEventEmitter = NativeModules.HBDEventEmitter;
25
+ const HBDEventReceiver = new NativeEventEmitter(HBDEventEmitter);
26
26
 
27
27
  function listenComponentResult(
28
- listener: (sceneId: string, requestCode: number, resultCode: number, resultData: object) => void,
28
+ listener: (
29
+ sceneId: string,
30
+ requestCode: number,
31
+ resultCode: number,
32
+ resultData: object,
33
+ ) => void,
29
34
  ) {
30
- const {
31
- EVENT_NAVIGATION,
32
- KEY_ON,
33
- ON_COMPONENT_RESULT,
34
- KEY_REQUEST_CODE,
35
- KEY_RESULT_CODE,
36
- KEY_RESULT_DATA,
37
- KEY_SCENE_ID,
38
- } = HBDEventEmitter.getConstants()
35
+ const {
36
+ EVENT_NAVIGATION,
37
+ KEY_ON,
38
+ ON_COMPONENT_RESULT,
39
+ KEY_REQUEST_CODE,
40
+ KEY_RESULT_CODE,
41
+ KEY_RESULT_DATA,
42
+ KEY_SCENE_ID,
43
+ } = HBDEventEmitter.getConstants();
39
44
 
40
- return HBDEventReceiver.addListener(EVENT_NAVIGATION, data => {
41
- if (data[KEY_ON] === ON_COMPONENT_RESULT) {
42
- const requestCode = data[KEY_REQUEST_CODE]
43
- const resultCode = data[KEY_RESULT_CODE]
44
- const resultData = data[KEY_RESULT_DATA]
45
- const sceneId = data[KEY_SCENE_ID]
45
+ return HBDEventReceiver.addListener(EVENT_NAVIGATION, data => {
46
+ if (data[KEY_ON] === ON_COMPONENT_RESULT) {
47
+ const requestCode = data[KEY_REQUEST_CODE];
48
+ const resultCode = data[KEY_RESULT_CODE];
49
+ const resultData = data[KEY_RESULT_DATA];
50
+ const sceneId = data[KEY_SCENE_ID];
46
51
 
47
- listener(sceneId, requestCode, resultCode, resultData)
48
- }
49
- })
52
+ listener(sceneId, requestCode, resultCode, resultData);
53
+ }
54
+ });
50
55
  }
51
56
 
52
57
  function listenComponentVisibility(listener: (sceneId: string, visibility: Visibility) => void) {
53
- const { EVENT_NAVIGATION, KEY_ON, ON_COMPONENT_APPEAR, ON_COMPONENT_DISAPPEAR, KEY_SCENE_ID } =
54
- HBDEventEmitter.getConstants()
58
+ const {EVENT_NAVIGATION, KEY_ON, ON_COMPONENT_APPEAR, ON_COMPONENT_DISAPPEAR, KEY_SCENE_ID} =
59
+ HBDEventEmitter.getConstants();
55
60
 
56
- return HBDEventReceiver.addListener(EVENT_NAVIGATION, data => {
57
- if (data[KEY_ON] === ON_COMPONENT_APPEAR) {
58
- listener(data[KEY_SCENE_ID], 'visible')
59
- }
61
+ return HBDEventReceiver.addListener(EVENT_NAVIGATION, data => {
62
+ if (data[KEY_ON] === ON_COMPONENT_APPEAR) {
63
+ listener(data[KEY_SCENE_ID], 'visible');
64
+ }
60
65
 
61
- if (data[KEY_ON] === ON_COMPONENT_DISAPPEAR) {
62
- listener(data[KEY_SCENE_ID], 'invisible')
63
- }
64
- })
66
+ if (data[KEY_ON] === ON_COMPONENT_DISAPPEAR) {
67
+ listener(data[KEY_SCENE_ID], 'invisible');
68
+ }
69
+ });
65
70
  }
66
71
 
67
72
  function listenBarButtonItemClick(listener: (sceneId: string, action: string) => void) {
68
- const { EVENT_NAVIGATION, KEY_ON, ON_BAR_BUTTON_ITEM_CLICK, KEY_ACTION, KEY_SCENE_ID } =
69
- HBDEventEmitter.getConstants()
73
+ const {EVENT_NAVIGATION, KEY_ON, ON_BAR_BUTTON_ITEM_CLICK, KEY_ACTION, KEY_SCENE_ID} =
74
+ HBDEventEmitter.getConstants();
70
75
 
71
- return HBDEventReceiver.addListener(
72
- EVENT_NAVIGATION,
73
- data => {
74
- if (data[KEY_ON] === ON_BAR_BUTTON_ITEM_CLICK) {
75
- listener(data[KEY_SCENE_ID], data[KEY_ACTION])
76
- }
77
- },
78
- {},
79
- )
76
+ return HBDEventReceiver.addListener(
77
+ EVENT_NAVIGATION,
78
+ data => {
79
+ if (data[KEY_ON] === ON_BAR_BUTTON_ITEM_CLICK) {
80
+ listener(data[KEY_SCENE_ID], data[KEY_ACTION]);
81
+ }
82
+ },
83
+ {},
84
+ );
80
85
  }
81
86
 
82
87
  function listenTabSwitch(listener: (sceneId: string, from: number, to: number) => void) {
83
- const { EVENT_SWITCH_TAB, KEY_INDEX, KEY_SCENE_ID } = HBDEventEmitter.getConstants()
84
- return HBDEventReceiver.addListener(EVENT_SWITCH_TAB, event => {
85
- const index = event[KEY_INDEX]
86
- const [from, to] = index.split('-')
87
- listener(event[KEY_SCENE_ID], parseInt(from, 10), parseInt(to, 10))
88
- })
88
+ const {EVENT_SWITCH_TAB, KEY_INDEX, KEY_SCENE_ID} = HBDEventEmitter.getConstants();
89
+ return HBDEventReceiver.addListener(EVENT_SWITCH_TAB, event => {
90
+ const index = event[KEY_INDEX];
91
+ const [from, to] = index.split('-');
92
+ listener(event[KEY_SCENE_ID], parseInt(from, 10), parseInt(to, 10));
93
+ });
89
94
  }
90
95
 
91
96
  function listenWillSetRoot(willSetRoot: () => void) {
92
- const { EVENT_WILL_SET_ROOT } = HBDEventEmitter.getConstants()
93
- return HBDEventReceiver.addListener(EVENT_WILL_SET_ROOT, _ => {
94
- willSetRoot()
95
- })
97
+ const {EVENT_WILL_SET_ROOT} = HBDEventEmitter.getConstants();
98
+ return HBDEventReceiver.addListener(EVENT_WILL_SET_ROOT, _ => {
99
+ willSetRoot();
100
+ });
96
101
  }
97
102
 
98
103
  function listenDidSetRoot(didSetRoot: (tag: number) => void) {
99
- const { EVENT_DID_SET_ROOT } = HBDEventEmitter.getConstants()
100
- return HBDEventReceiver.addListener(EVENT_DID_SET_ROOT, (event: { tag: number }) => {
101
- didSetRoot(event.tag)
102
- })
104
+ const {EVENT_DID_SET_ROOT} = HBDEventEmitter.getConstants();
105
+ return HBDEventReceiver.addListener(EVENT_DID_SET_ROOT, (event: {tag: number}) => {
106
+ didSetRoot(event.tag);
107
+ });
103
108
  }
104
109
 
105
110
  export default {
106
- listenBarButtonItemClick,
107
- listenComponentResult,
108
- listenComponentVisibility,
109
- listenTabSwitch,
110
- listenWillSetRoot,
111
- listenDidSetRoot,
112
- }
111
+ listenBarButtonItemClick,
112
+ listenComponentResult,
113
+ listenComponentVisibility,
114
+ listenTabSwitch,
115
+ listenWillSetRoot,
116
+ listenDidSetRoot,
117
+ };
@@ -1,50 +1,50 @@
1
- import { NativeModules, NativeModule, NativeEventEmitter, Platform } from 'react-native'
1
+ import {NativeModules, NativeModule, NativeEventEmitter, Platform} from 'react-native';
2
2
 
3
3
  interface GardenModule extends NativeModule {
4
- getConstants: () => {
5
- TOOLBAR_HEIGHT: number
6
- STATUSBAR_HEIGHT: number
7
- EVENT_STATUSBAR_FRAME_CHANGE: string
8
- }
9
-
10
- setStyle: (style: object) => void
11
- setTitleItem: (sceneId: string, item: object) => void
12
- setLeftBarButtonItem: (sceneId: string, item: object | null) => void
13
- setRightBarButtonItem: (sceneId: string, item: object | null) => void
14
- setLeftBarButtonItems: (sceneId: string, item: object | null) => void
15
- setRightBarButtonItems: (sceneId: string, item: object | null) => void
16
- updateOptions: (sceneId: string, options: object) => void
17
- updateTabBar: (sceneId: string, item: object) => void
18
- setTabItem: (sceneId: string, item: object) => void
19
- setMenuInteractive: (sceneId: string, enabled: boolean) => void
4
+ getConstants: () => {
5
+ TOOLBAR_HEIGHT: number;
6
+ STATUSBAR_HEIGHT: number;
7
+ EVENT_STATUSBAR_FRAME_CHANGE: string;
8
+ };
9
+
10
+ setStyle: (style: object) => void;
11
+ setTitleItem: (sceneId: string, item: object) => void;
12
+ setLeftBarButtonItem: (sceneId: string, item: object | null) => void;
13
+ setRightBarButtonItem: (sceneId: string, item: object | null) => void;
14
+ setLeftBarButtonItems: (sceneId: string, item: object | null) => void;
15
+ setRightBarButtonItems: (sceneId: string, item: object | null) => void;
16
+ updateOptions: (sceneId: string, options: object) => void;
17
+ updateTabBar: (sceneId: string, item: object) => void;
18
+ setTabItem: (sceneId: string, item: object) => void;
19
+ setMenuInteractive: (sceneId: string, enabled: boolean) => void;
20
20
  }
21
21
 
22
- const GardenModule: GardenModule = NativeModules.GardenModule
22
+ const GardenModule: GardenModule = NativeModules.GardenModule;
23
23
 
24
- const { STATUSBAR_HEIGHT, TOOLBAR_HEIGHT, EVENT_STATUSBAR_FRAME_CHANGE } =
25
- GardenModule.getConstants()
24
+ const {STATUSBAR_HEIGHT, TOOLBAR_HEIGHT, EVENT_STATUSBAR_FRAME_CHANGE} =
25
+ GardenModule.getConstants();
26
26
 
27
- let _statusBarHeight = STATUSBAR_HEIGHT
27
+ let _statusBarHeight = STATUSBAR_HEIGHT;
28
28
 
29
29
  if (Platform.OS === 'ios') {
30
- const GardenEventReceiver = new NativeEventEmitter(GardenModule)
31
- GardenEventReceiver.addListener(EVENT_STATUSBAR_FRAME_CHANGE, ({ statusBarHeight: height }) => {
32
- _statusBarHeight = height
33
- })
30
+ const GardenEventReceiver = new NativeEventEmitter(GardenModule);
31
+ GardenEventReceiver.addListener(EVENT_STATUSBAR_FRAME_CHANGE, ({statusBarHeight: height}) => {
32
+ _statusBarHeight = height;
33
+ });
34
34
  }
35
35
 
36
36
  function statusBarHeight() {
37
- return _statusBarHeight
37
+ return _statusBarHeight;
38
38
  }
39
39
 
40
40
  function toolbarHeight() {
41
- return TOOLBAR_HEIGHT
41
+ return TOOLBAR_HEIGHT;
42
42
  }
43
43
 
44
44
  function topBarHeight() {
45
- return statusBarHeight() + toolbarHeight()
45
+ return statusBarHeight() + toolbarHeight();
46
46
  }
47
47
 
48
- export { statusBarHeight, toolbarHeight, topBarHeight }
48
+ export {statusBarHeight, toolbarHeight, topBarHeight};
49
49
 
50
- export default GardenModule
50
+ export default GardenModule;