hybrid-navigation 2.13.0-beta.2 → 2.13.0

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 (80) hide show
  1. package/android/src/main/java/com/reactnative/hybridnavigation/ReactFragment.java +3 -20
  2. package/ios/HybridNavigation/HBDUtils.h +3 -6
  3. package/ios/HybridNavigation/HBDUtils.m +10 -0
  4. package/ios/HybridNavigation/Navigator/HBDStackNavigator.m +7 -2
  5. package/ios/HybridNavigation/ReactBridge/HBDNavigationModule.m +1 -1
  6. package/ios/HybridNavigation/View/HBDRootView.m +9 -3
  7. package/ios/HybridNavigation/ViewController/HBDNavigationController.m +0 -30
  8. package/ios/HybridNavigation/ViewController/HBDViewController.m +7 -3
  9. package/ios/HybridNavigation/ViewController/UINavigationController+HBD.m +0 -3
  10. package/lib/Event.d.ts +18 -0
  11. package/lib/Event.js +71 -0
  12. package/lib/Garden.d.ts +46 -68
  13. package/lib/Garden.js +53 -70
  14. package/lib/GardenModule.d.ts +20 -0
  15. package/lib/GardenModule.js +3 -0
  16. package/lib/Navigation.d.ts +74 -0
  17. package/lib/Navigation.js +182 -0
  18. package/lib/NavigationComponentWrap.d.ts +19 -0
  19. package/lib/NavigationComponentWrap.js +46 -0
  20. package/lib/NavigationModule.d.ts +33 -22
  21. package/lib/NavigationModule.js +79 -22
  22. package/lib/Navigator.d.ts +55 -28
  23. package/lib/Navigator.js +122 -263
  24. package/lib/{typing.d.ts → Options.d.ts} +46 -50
  25. package/lib/{typing.js → Options.js} +0 -0
  26. package/lib/ReactRegistry.d.ts +16 -14
  27. package/lib/ReactRegistry.js +18 -93
  28. package/lib/Route.d.ts +74 -0
  29. package/lib/{router/typing.js → Route.js} +0 -0
  30. package/lib/handler/BarButtonEventHandler.d.ts +10 -0
  31. package/lib/handler/BarButtonEventHandler.js +38 -0
  32. package/lib/handler/DispatchCommandHandler.d.ts +24 -0
  33. package/lib/handler/DispatchCommandHandler.js +28 -0
  34. package/lib/handler/LayoutCommandHandler.d.ts +11 -0
  35. package/lib/handler/LayoutCommandHandler.js +39 -0
  36. package/lib/handler/ResultEventHandler.d.ts +15 -0
  37. package/lib/handler/ResultEventHandler.js +47 -0
  38. package/lib/handler/VisibilityEventHandler.d.ts +13 -0
  39. package/lib/handler/VisibilityEventHandler.js +32 -0
  40. package/lib/hooks.d.ts +0 -1
  41. package/lib/hooks.js +14 -29
  42. package/lib/index.d.ts +10 -2
  43. package/lib/index.js +17 -2
  44. package/lib/router/drawer.d.ts +1 -1
  45. package/lib/router/index.d.ts +4 -7
  46. package/lib/router/index.js +13 -6
  47. package/lib/router/screen.d.ts +1 -1
  48. package/lib/router/stack.d.ts +1 -1
  49. package/lib/router/tabs.d.ts +1 -1
  50. package/lib/store.d.ts +0 -9
  51. package/lib/store.js +0 -22
  52. package/package.json +1 -1
  53. package/src/Event.ts +123 -0
  54. package/src/Garden.ts +63 -149
  55. package/src/GardenModule.ts +24 -0
  56. package/src/Navigation.ts +278 -0
  57. package/src/NavigationComponentWrap.tsx +73 -0
  58. package/src/NavigationModule.ts +118 -29
  59. package/src/Navigator.ts +147 -319
  60. package/src/{typing.ts → Options.ts} +51 -57
  61. package/src/ReactRegistry.tsx +25 -127
  62. package/src/Route.ts +88 -0
  63. package/src/handler/BarButtonEventHandler.ts +50 -0
  64. package/src/handler/DispatchCommandHandler.ts +56 -0
  65. package/src/handler/LayoutCommandHandler.ts +49 -0
  66. package/src/handler/ResultEventHandler.ts +67 -0
  67. package/src/handler/VisibilityEventHandler.ts +44 -0
  68. package/src/hooks.ts +13 -38
  69. package/src/index.ts +38 -3
  70. package/src/router/drawer.ts +1 -1
  71. package/src/router/index.ts +36 -12
  72. package/src/router/screen.ts +1 -1
  73. package/src/router/stack.ts +1 -1
  74. package/src/router/tabs.ts +1 -1
  75. package/src/store.ts +0 -28
  76. package/lib/router/typing.d.ts +0 -37
  77. package/lib/utils.d.ts +0 -9
  78. package/lib/utils.js +0 -50
  79. package/src/router/typing.ts +0 -45
  80. package/src/utils.ts +0 -83
@@ -1,4 +1,4 @@
1
- import { RouteGraph, LayoutMode } from './typing';
1
+ import { LayoutMode, RouteGraph } from '../Route';
2
2
  export interface ScreenGraph extends RouteGraph {
3
3
  layout: 'screen';
4
4
  sceneId: string;
@@ -1,4 +1,4 @@
1
- import { RouteGraph, LayoutMode, RouteInfo, RouteHandler } from './typing';
1
+ import { LayoutMode, RouteGraph, RouteHandler, RouteInfo } from '../Route';
2
2
  export interface StackGraph extends RouteGraph {
3
3
  layout: 'stack';
4
4
  sceneId: string;
@@ -1,4 +1,4 @@
1
- import { RouteGraph, LayoutMode, RouteHandler, RouteInfo } from './typing';
1
+ import { LayoutMode, RouteGraph, RouteHandler, RouteInfo } from '../Route';
2
2
  export interface TabsGraph extends RouteGraph {
3
3
  layout: 'tabs';
4
4
  sceneId: string;
package/lib/store.d.ts CHANGED
@@ -1,19 +1,10 @@
1
1
  import { Navigator } from './Navigator';
2
- import { EmitterSubscription } from 'react-native';
3
2
  declare function addNavigator(sceneId: string, navigator: Navigator): void;
4
3
  declare function removeNavigator(sceneId: string): void;
5
4
  declare function getNavigator(sceneId: string): Navigator | undefined;
6
- declare function addBarButtonItemClickEvent(event: EmitterSubscription): void;
7
- declare function removeBarButtonItemClickEvent(event: EmitterSubscription): void;
8
- declare function filterBarButtonItemClickEvent(callback: (event: EmitterSubscription) => boolean): EmitterSubscription[];
9
- declare function clear(): void;
10
5
  declare const _default: {
11
6
  addNavigator: typeof addNavigator;
12
7
  removeNavigator: typeof removeNavigator;
13
8
  getNavigator: typeof getNavigator;
14
- addBarButtonItemClickEvent: typeof addBarButtonItemClickEvent;
15
- removeBarButtonItemClickEvent: typeof removeBarButtonItemClickEvent;
16
- filterBarButtonItemClickEvent: typeof filterBarButtonItemClickEvent;
17
- clear: typeof clear;
18
9
  };
19
10
  export default _default;
package/lib/store.js CHANGED
@@ -1,5 +1,4 @@
1
1
  const navigators = new Map();
2
- let events = [];
3
2
  function addNavigator(sceneId, navigator) {
4
3
  navigators.set(sceneId, navigator);
5
4
  }
@@ -9,29 +8,8 @@ function removeNavigator(sceneId) {
9
8
  function getNavigator(sceneId) {
10
9
  return navigators.get(sceneId);
11
10
  }
12
- function addBarButtonItemClickEvent(event) {
13
- events.push(event);
14
- }
15
- function removeBarButtonItemClickEvent(event) {
16
- event.remove();
17
- events = events.filter(e => e !== event);
18
- }
19
- function filterBarButtonItemClickEvent(callback) {
20
- return events.filter(callback);
21
- }
22
- function clear() {
23
- navigators.clear();
24
- events.forEach(event => {
25
- event.remove();
26
- });
27
- events = [];
28
- }
29
11
  export default {
30
12
  addNavigator,
31
13
  removeNavigator,
32
14
  getNavigator,
33
- addBarButtonItemClickEvent,
34
- removeBarButtonItemClickEvent,
35
- filterBarButtonItemClickEvent,
36
- clear,
37
15
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hybrid-navigation",
3
3
  "description": "React Native Navigation that supports seamless navigation between Native and React.",
4
- "version": "2.13.0-beta.2",
4
+ "version": "2.13.0",
5
5
  "main": "./lib/index.js",
6
6
  "typings": "./lib/index.d.ts",
7
7
  "react-native": "src/index",
package/src/Event.ts ADDED
@@ -0,0 +1,123 @@
1
+ import { NativeModules, NativeEventEmitter, NativeModule } from 'react-native'
2
+ import GardenModule from './GardenModule'
3
+ import type { Visibility } from './Route'
4
+
5
+ function listenStatusBarHeightChange(listener: (statusBarHeight: number) => void) {
6
+ const GardenEventReceiver = new NativeEventEmitter(GardenModule)
7
+ const { EVENT_STATUSBAR_FRAME_CHANGE } = GardenModule.getConstants()
8
+ return GardenEventReceiver.addListener(EVENT_STATUSBAR_FRAME_CHANGE, ({ statusBarHeight }) => {
9
+ listener(statusBarHeight)
10
+ })
11
+ }
12
+
13
+ interface HBDEventEmitter extends NativeModule {
14
+ getConstants: () => {
15
+ EVENT_NAVIGATION: string
16
+ EVENT_SWITCH_TAB: string
17
+ EVENT_DID_SET_ROOT: string
18
+ EVENT_WILL_SET_ROOT: string
19
+ ON_COMPONENT_RESULT: string
20
+ ON_BAR_BUTTON_ITEM_CLICK: string
21
+ ON_COMPONENT_APPEAR: string
22
+ ON_COMPONENT_DISAPPEAR: string
23
+ KEY_REQUEST_CODE: string
24
+ KEY_RESULT_CODE: string
25
+ KEY_RESULT_DATA: string
26
+ KEY_SCENE_ID: string
27
+ KEY_MODULE_NAME: string
28
+ KEY_INDEX: string
29
+ KEY_ACTION: string
30
+ KEY_ON: string
31
+ }
32
+ }
33
+
34
+ const HBDEventEmitter: HBDEventEmitter = NativeModules.HBDEventEmitter
35
+ const HBDEventReceiver = new NativeEventEmitter(HBDEventEmitter)
36
+
37
+ function listenComponentResult(
38
+ listener: (sceneId: string, requestCode: number, resultCode: number, resultData: object) => void,
39
+ ) {
40
+ const {
41
+ EVENT_NAVIGATION,
42
+ KEY_ON,
43
+ ON_COMPONENT_RESULT,
44
+ KEY_REQUEST_CODE,
45
+ KEY_RESULT_CODE,
46
+ KEY_RESULT_DATA,
47
+ KEY_SCENE_ID,
48
+ } = HBDEventEmitter.getConstants()
49
+
50
+ return HBDEventReceiver.addListener(EVENT_NAVIGATION, data => {
51
+ if (data[KEY_ON] === ON_COMPONENT_RESULT) {
52
+ const requestCode = data[KEY_REQUEST_CODE]
53
+ const resultCode = data[KEY_RESULT_CODE]
54
+ const resultData = data[KEY_RESULT_DATA]
55
+ const sceneId = data[KEY_SCENE_ID]
56
+
57
+ listener(sceneId, requestCode, resultCode, resultData)
58
+ }
59
+ })
60
+ }
61
+
62
+ function listenComponentVisibility(listener: (sceneId: string, visibility: Visibility) => void) {
63
+ const { EVENT_NAVIGATION, KEY_ON, ON_COMPONENT_APPEAR, ON_COMPONENT_DISAPPEAR, KEY_SCENE_ID } =
64
+ HBDEventEmitter.getConstants()
65
+
66
+ return HBDEventReceiver.addListener(EVENT_NAVIGATION, data => {
67
+ if (data[KEY_ON] === ON_COMPONENT_APPEAR) {
68
+ listener(data[KEY_SCENE_ID], 'visible')
69
+ }
70
+
71
+ if (data[KEY_ON] === ON_COMPONENT_DISAPPEAR) {
72
+ listener(data[KEY_SCENE_ID], 'invisible')
73
+ }
74
+ })
75
+ }
76
+
77
+ function listenBarButtonItemClick(listener: (sceneId: string, action: string) => void) {
78
+ const { EVENT_NAVIGATION, KEY_ON, ON_BAR_BUTTON_ITEM_CLICK, KEY_ACTION, KEY_SCENE_ID } =
79
+ HBDEventEmitter.getConstants()
80
+
81
+ return HBDEventReceiver.addListener(
82
+ EVENT_NAVIGATION,
83
+ data => {
84
+ if (data[KEY_ON] === ON_BAR_BUTTON_ITEM_CLICK) {
85
+ listener(data[KEY_SCENE_ID], data[KEY_ACTION])
86
+ }
87
+ },
88
+ {},
89
+ )
90
+ }
91
+
92
+ function listenTabSwitch(listener: (sceneId: string, from: number, to: number) => void) {
93
+ const { EVENT_SWITCH_TAB, KEY_INDEX, KEY_SCENE_ID } = HBDEventEmitter.getConstants()
94
+ return HBDEventReceiver.addListener(EVENT_SWITCH_TAB, event => {
95
+ const index = event[KEY_INDEX]
96
+ const [from, to] = index.split('-')
97
+ listener(event[KEY_SCENE_ID], parseInt(from, 10), parseInt(to, 10))
98
+ })
99
+ }
100
+
101
+ function listenWillSetRoot(willSetRoot: () => void) {
102
+ const { EVENT_WILL_SET_ROOT } = HBDEventEmitter.getConstants()
103
+ return HBDEventReceiver.addListener(EVENT_WILL_SET_ROOT, _ => {
104
+ willSetRoot()
105
+ })
106
+ }
107
+
108
+ function listenDidSetRoot(didSetRoot: (tag: number) => void) {
109
+ const { EVENT_DID_SET_ROOT } = HBDEventEmitter.getConstants()
110
+ return HBDEventReceiver.addListener(EVENT_DID_SET_ROOT, (event: { tag: number }) => {
111
+ didSetRoot(event.tag)
112
+ })
113
+ }
114
+
115
+ export default {
116
+ listenStatusBarHeightChange,
117
+ listenBarButtonItemClick,
118
+ listenComponentResult,
119
+ listenComponentVisibility,
120
+ listenTabSwitch,
121
+ listenWillSetRoot,
122
+ listenDidSetRoot,
123
+ }
package/src/Garden.ts CHANGED
@@ -1,185 +1,99 @@
1
- import { NativeEventEmitter, NativeModules, Platform } from 'react-native'
2
- import { bindBarButtonItemClickEvent } from './utils'
3
- import { NavigationOption, ImageSource, Color, BarStyle, TitleAlignment, BarButtonItem, TitleItem } from './typing'
4
-
5
- export interface ShadowImage {
6
- image?: ImageSource
7
- color?: Color
8
- }
9
-
10
- export interface Style {
11
- screenBackgroundColor?: Color // 页面背景,默认是白色
12
- topBarStyle?: BarStyle // TopBar 样式,决定了状态栏的颜色,可选项有 `BarStyleLightContent` 和 `BarStyleDarkContent`
13
- topBarColor?: Color // TopBar 背景颜色,默认根据 topBarStyle 来计算
14
- topBarColorDarkContent?: Color // TopBar 背景颜色,当 topBarStyle 的值为 BarStyleDarkContent 时生效,覆盖 topBarColor 的值
15
- topBarColorLightContent?: Color // TopBar 背景颜色,当 topBarStyle 的值为 BarStyleLightContent 时生效,覆盖 topBarColor 的值
16
- statusBarColorAndroid?: Color // 状态栏背景颜色,默认取 topBarColor 的值
17
- navigationBarColorAndroid?: Color // 底部虚拟键背景颜色,仅对 Android 8.0 以上版本生效
18
- hideBackTitleIOS?: boolean // 是否隐藏返回按钮旁边的文字,默认是 false, 仅对 iOS 生效
19
- elevationAndroid?: number // TopBar 阴影高度,默认值为 4 dp
20
- shadowImage?: ShadowImage // TopBar 阴影图片,仅对 iOS 生效
21
- backIcon?: ImageSource // 返回按钮图片
22
- topBarTintColor?: Color // TopBar 按钮的颜色。默认根据 topBarStyle 来计算
23
- topBarTintColorDarkContent?: Color // TopBar 按钮颜色,当 topBarStyle 的值为 BarStyleDarkContent 时生效,覆盖 topBarTintColor 的值
24
- topBarTintColorLightContent?: Color // TopBar 按钮颜色,当 topBarStyle 的值为 BarStyleLightContent 时生效,覆盖 topBarTintColor 的值
25
- titleTextColor?: Color // TopBar 标题颜色,默认根据 topBarStyle 来计算
26
- titleTextColorDarkContent?: Color // TopBar 标题颜色,当 topBarStyle 的值为 BarStyleDarkContent 时生效,覆盖 titleTextColor 的值
27
- titleTextColorLightContent?: Color // TopBar 标题颜色,当 topBarStyle 的值为 BarStyleLightContent 时生效,覆盖 titleTextColor 的值
28
- titleTextSize?: number // TopBar 标题字体大小,默认是 17 dp(pt)
29
- titleAlignmentAndroid?: TitleAlignment // TopBar 标题的位置,可选项有 `TitleAlignmentLeft` 和 `TitleAlignmentCenter` ,仅对 Android 生效
30
- barButtonItemTextSize?: number // TopBar 按钮字体大小,默认是 15 dp(pt)
31
- swipeBackEnabledAndroid?: boolean // Android 是否开启右滑返回,默认是 false
32
- splitTopBarTransitionIOS?: boolean // iOS 侧滑返回时,是否总是割裂导航栏背景
33
- scrimAlphaAndroid?: number // Android 侧滑返回遮罩效果 [0 - 255]
34
- displayCutoutWhenLandscapeAndroid?: boolean // 横屏时,是否将界面延伸至刘海区域,默认 true
35
-
36
- tabBarColor?: Color // 底部 TabBar 背景颜色,请勿使用带透明度的颜色。
37
- tabBarShadowImage?: ShadowImage // 底部 TabBar 阴影图片。对于 iOS, 只有同时设置了 tabBarColor 才会生效
38
- tabBarItemColor?: Color // 底部 TabBarItem icon 选中颜色
39
- tabBarUnselectedItemColor?: Color // 底部 TabBarItem icon 未选中颜色,默认为 #BDBDBD
40
- tabBarBadgeColor?: Color // Tab badge 颜色
41
- }
42
-
43
- export type TabBarStyle = Pick<
44
- Style,
45
- 'tabBarColor' | 'tabBarShadowImage' | 'tabBarItemColor' | 'tabBarUnselectedItemColor'
46
- >
47
-
48
- export interface TabBadge {
49
- index: number
50
- text?: string
51
- hidden: boolean
52
- dot?: boolean
53
- }
54
-
55
- export interface TabItemInfo {
56
- index: number
57
- title?: string
58
- badge?: {
59
- text?: string
60
- hidden: boolean
61
- dot?: boolean
62
- }
63
- icon?: {
64
- selected: ImageSource
65
- unselected?: ImageSource
66
- }
67
- }
68
-
69
- export interface TabIcon {
70
- index: number
71
- icon: ImageSource
72
- unselectedIcon?: ImageSource
73
- }
1
+ import Navigation from './Navigation'
2
+ import type {
3
+ BarButtonItem,
4
+ DefaultOptions,
5
+ NavigationOption,
6
+ TabBarStyle,
7
+ TabItemInfo,
8
+ TitleItem,
9
+ } from './Options'
74
10
 
75
11
  type Nullable<T> = {
76
12
  [P in keyof T]: T[P] extends T[P] | undefined ? T[P] | null : T[P]
77
13
  }
78
14
 
79
- const GardenModule = NativeModules.GardenModule
80
- const { STATUSBAR_HEIGHT, EVENT_STATUSBAR_FRAME_CHANGE, TOOLBAR_HEIGHT } = GardenModule.getConstants()
81
-
82
- if (Platform.OS === 'ios') {
83
- const GardenEventEmitter: NativeEventEmitter = new NativeEventEmitter(GardenModule)
84
- GardenEventEmitter.addListener(EVENT_STATUSBAR_FRAME_CHANGE, ({ statusBarHeight }) => {
85
- Garden.statusBarHeight = statusBarHeight
86
- Garden.topBarHeight = statusBarHeight + TOOLBAR_HEIGHT
87
- })
88
- }
89
-
90
- export class Garden {
91
- static setStyle(style: Style = {}) {
92
- GardenModule.setStyle(style)
15
+ export interface Garden {}
16
+ export class Garden implements Garden {
17
+ /**
18
+ * @deprecated Use Navigation.setDefaultOptions() instead.
19
+ * @param style
20
+ */
21
+ static setStyle(style: DefaultOptions) {
22
+ Navigation.setDefaultOptions(style)
93
23
  }
94
24
 
95
- static statusBarHeight: number = STATUSBAR_HEIGHT
96
- static toolbarHeight: number = TOOLBAR_HEIGHT
97
- static topBarHeight: number = TOOLBAR_HEIGHT + STATUSBAR_HEIGHT
98
-
99
25
  constructor(public sceneId: string) {}
100
26
 
101
- // --------------- instance method --------------
102
-
27
+ /**
28
+ * @deprecated Use Navigation.setLeftBarButtonItem() instead.
29
+ * @param buttonItem
30
+ */
103
31
  setLeftBarButtonItem(buttonItem: Nullable<BarButtonItem> | null) {
104
- const options = bindBarButtonItemClickEvent(buttonItem, { sceneId: this.sceneId })
105
- GardenModule.setLeftBarButtonItem(this.sceneId, options)
32
+ Navigation.setLeftBarButtonItem(this.sceneId, buttonItem)
106
33
  }
107
34
 
35
+ /**
36
+ * @deprecated Use Navigation.setRightBarButtonItem() instead.
37
+ * @param buttonItem
38
+ */
108
39
  setRightBarButtonItem(buttonItem: Nullable<BarButtonItem> | null) {
109
- const options = bindBarButtonItemClickEvent(buttonItem, { sceneId: this.sceneId })
110
- GardenModule.setRightBarButtonItem(this.sceneId, options)
40
+ Navigation.setRightBarButtonItem(this.sceneId, buttonItem)
111
41
  }
112
42
 
43
+ /**
44
+ *
45
+ * @deprecated Use Navigation.setLeftBarButtonItems() instead.
46
+ * @param buttonItems
47
+ */
113
48
  setLeftBarButtonItems(buttonItems: Array<Nullable<BarButtonItem>> | null) {
114
- const options = bindBarButtonItemClickEvent(buttonItems, { sceneId: this.sceneId })
115
- GardenModule.setLeftBarButtonItems(this.sceneId, options)
49
+ Navigation.setLeftBarButtonItems(this.sceneId, buttonItems)
116
50
  }
117
51
 
52
+ /**
53
+ * @deprecated Use Navigation.setRightBarButtonItems() instead.
54
+ * @param buttonItems
55
+ */
118
56
  setRightBarButtonItems(buttonItems: Array<Nullable<BarButtonItem>> | null) {
119
- const options = bindBarButtonItemClickEvent(buttonItems, { sceneId: this.sceneId })
120
- GardenModule.setRightBarButtonItems(this.sceneId, options)
57
+ Navigation.setRightBarButtonItems(this.sceneId, buttonItems)
121
58
  }
122
59
 
60
+ /**
61
+ * @deprecated Use Navigation.setTitleItem() instead.
62
+ * @param titleItem
63
+ */
123
64
  setTitleItem(titleItem: TitleItem) {
124
- GardenModule.setTitleItem(this.sceneId, titleItem)
65
+ Navigation.setTitleItem(this.sceneId, titleItem)
125
66
  }
126
67
 
68
+ /**
69
+ * @deprecated Use Navigation.updateOptions() instead.
70
+ * @param options
71
+ */
127
72
  updateOptions(options: NavigationOption) {
128
- GardenModule.updateOptions(this.sceneId, options)
73
+ Navigation.updateOptions(this.sceneId, options)
129
74
  }
130
75
 
76
+ /**
77
+ * @deprecated Use Navigation.updateTabBar() instead.
78
+ * @param options
79
+ */
131
80
  updateTabBar(options: TabBarStyle) {
132
- GardenModule.updateTabBar(this.sceneId, options)
81
+ Navigation.updateTabBar(this.sceneId, options)
133
82
  }
134
83
 
84
+ /**
85
+ * @deprecated Use Navigation.setTabItem() instead.
86
+ * @param item
87
+ */
135
88
  setTabItem(item: TabItemInfo | TabItemInfo[]) {
136
- if (!Array.isArray(item)) {
137
- item = [item]
138
- }
139
- GardenModule.setTabItem(this.sceneId, item)
140
- }
141
-
142
- setTabIcon(icon: TabIcon | TabIcon[]) {
143
- console.warn(`Garden#setTabIcon is deprecated, use Garden#setTabItem instead.`)
144
- if (!Array.isArray(icon)) {
145
- icon = [icon]
146
- }
147
- const icons = icon
148
- const items: Array<TabItemInfo> = []
149
- for (const i of icons) {
150
- items.push({
151
- index: i.index,
152
- icon: {
153
- selected: i.icon,
154
- unselected: i.unselectedIcon,
155
- },
156
- })
157
- }
158
- this.setTabItem(items)
159
- }
160
-
161
- setTabBadge(badge: TabBadge | TabBadge[]) {
162
- console.warn(`Garden#setTabBadge is deprecated, use Garden#setTabItem instead.`)
163
- if (!Array.isArray(badge)) {
164
- badge = [badge]
165
- }
166
-
167
- const badges = badge
168
- const items: Array<TabItemInfo> = []
169
- for (const b of badges) {
170
- items.push({
171
- index: b.index,
172
- badge: {
173
- hidden: b.hidden,
174
- text: b.text,
175
- dot: b.dot,
176
- },
177
- })
178
- }
179
- this.setTabItem(items)
89
+ Navigation.setTabItem(this.sceneId, item)
180
90
  }
181
91
 
92
+ /**
93
+ * @deprecated Use Navigation.setMenuInteractive() instead.
94
+ * @param enabled
95
+ */
182
96
  setMenuInteractive(enabled: boolean) {
183
- GardenModule.setMenuInteractive(this.sceneId, enabled)
97
+ Navigation.setMenuInteractive(this.sceneId, enabled)
184
98
  }
185
99
  }
@@ -0,0 +1,24 @@
1
+ import { NativeModules, NativeModule } from 'react-native'
2
+
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
20
+ }
21
+
22
+ const GardenModule: GardenModule = NativeModules.GardenModule
23
+
24
+ export default GardenModule