hybrid-navigation 2.4.3 → 2.7.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 (34) hide show
  1. package/CHANGELOG.md +25 -1
  2. package/android/build.gradle +1 -1
  3. package/android/src/main/java/com/reactnative/hybridnavigation/Constants.java +1 -2
  4. package/android/src/main/java/com/reactnative/hybridnavigation/Garden.java +13 -2
  5. package/android/src/main/java/com/reactnative/hybridnavigation/GardenModule.java +29 -84
  6. package/android/src/main/java/com/reactnative/hybridnavigation/GlobalStyle.java +1 -3
  7. package/android/src/main/java/com/reactnative/hybridnavigation/HybridFragment.java +5 -5
  8. package/android/src/main/java/com/reactnative/hybridnavigation/NavigationModule.java +57 -94
  9. package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivity.java +12 -8
  10. package/android/src/main/java/com/reactnative/hybridnavigation/ReactFragment.java +10 -17
  11. package/android/src/main/java/com/reactnative/hybridnavigation/{ReactNavigationFragment.java → ReactStackFragment.java} +2 -2
  12. package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBar.java +0 -3
  13. package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarFragment.java +49 -51
  14. package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarProvider.java +39 -59
  15. package/android/src/main/java/com/reactnative/hybridnavigation/navigator/NavigatorRegistry.java +2 -2
  16. package/android/src/main/java/com/reactnative/hybridnavigation/navigator/ScreenNavigator.java +7 -7
  17. package/android/src/main/java/com/reactnative/hybridnavigation/navigator/StackNavigator.java +24 -24
  18. package/android/src/main/java/com/reactnative/hybridnavigation/navigator/TabNavigator.java +4 -4
  19. package/docs/integration-native.md +3 -3
  20. package/docs/pass-and-return-value.md +4 -4
  21. package/docs/qa.md +17 -0
  22. package/docs/style.md +48 -63
  23. package/ios/HybridNavigation/Bridge/HBDGardenModule.m +3 -13
  24. package/ios/HybridNavigation/Bridge/HBDNavigationModule.m +1 -1
  25. package/ios/HybridNavigation/ViewController/HBDTabBarController.h +1 -3
  26. package/ios/HybridNavigation/ViewController/HBDTabBarController.m +34 -33
  27. package/ios/HybridNavigation/ViewController/HBDViewController.m +5 -0
  28. package/ios/HybridNavigation/ViewController/UIViewController+HBD.m +38 -12
  29. package/lib/Garden.d.ts +14 -0
  30. package/lib/Garden.js +33 -2
  31. package/lib/Navigator.js +1 -1
  32. package/lib/typing.d.ts +1 -0
  33. package/package.json +7 -7
  34. package/android/src/main/java/com/reactnative/hybridnavigation/UiTaskExecutor.java +0 -81
package/docs/style.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  1. 加载静态图片
8
8
 
9
- ```javascript
9
+ ```ts
10
10
  import { Image } from 'react-native';
11
11
 
12
12
  icon: Image.resolveAssetSource(require('./images/ic_settings.png')),
@@ -14,7 +14,7 @@ icon: Image.resolveAssetSource(require('./images/ic_settings.png')),
14
14
 
15
15
  2. 加载原生图片
16
16
 
17
- ```javascript
17
+ ```ts
18
18
  import { PixelRatio } from 'react-native';
19
19
 
20
20
  icon: { uri: 'flower', scale: PixelRatio.get() },
@@ -22,7 +22,7 @@ icon: { uri: 'flower', scale: PixelRatio.get() },
22
22
 
23
23
  3. 加载网络图片(不推荐)
24
24
 
25
- ```javascript
25
+ ```ts
26
26
  icon: {
27
27
  uri: 'http://xxx.xx/?width=24&height=24&scale=3'
28
28
  }
@@ -32,7 +32,7 @@ icon: {
32
32
 
33
33
  4. 使用 icon font
34
34
 
35
- ```javascript
35
+ ```ts
36
36
  icon: { uri: fontUri('FontAwesome', 'navicon', 24)},
37
37
  ```
38
38
 
@@ -119,7 +119,7 @@ export type TitleAlignment = TitleAlignmentCenter | TitleAlignmentLeft
119
119
 
120
120
  3.双击打开 values-v21 目录中的 styles.xml 文件,把 App 主题样式 `andriod:statusBarColor` 的值设置成和你用 Garden 设置的一样。
121
121
 
122
- ```javascript
122
+ ```ts
123
123
  import { Garden } from 'hybrid-navigation'
124
124
 
125
125
  Garden.setStyle({
@@ -142,7 +142,7 @@ Garden.setStyle({
142
142
 
143
143
  导航栏阴影图片,仅对 iOS 生效。
144
144
 
145
- ```javascript
145
+ ```ts
146
146
  // index.js
147
147
 
148
148
  import { Image } from 'react-native'
@@ -159,7 +159,7 @@ Garden.setStyle({
159
159
 
160
160
  shadowImage 会有一个默认值,如果你想去掉,可以这样设置
161
161
 
162
- ```javascript
162
+ ```ts
163
163
  Garden.setStyle({
164
164
  shadowImage: {},
165
165
  })
@@ -169,7 +169,7 @@ Garden.setStyle({
169
169
 
170
170
  配置返回按钮的图标。如果不配置,则采用平台默认的图标。配置方式如下
171
171
 
172
- ```javascript
172
+ ```ts
173
173
  // index.js
174
174
 
175
175
  import { Image } from 'react-native'
@@ -206,7 +206,7 @@ UITabBar(iOS)、BottomNavigationBar(Android) 的阴影图片。对于 iOS, 只
206
206
 
207
207
  我们需要在页面实现 `navigationItem` 这个静态字段,完整的可配置项如下:
208
208
 
209
- ```javascript
209
+ ```ts
210
210
  class Screen extends Component {
211
211
  static navigationItem = {
212
212
  passThroughTouches: false, // 触摸事件是否可以穿透到下一层页面,很少用。
@@ -317,8 +317,8 @@ layoutFitting 配合 moduleName 使用,自定义标题栏的布局模式,有
317
317
 
318
318
  标题栏和所属页面共享同一个 navigator 对象,你可以在所属页面通过以下方式传递参数给标题栏使用
319
319
 
320
- ```javascript
321
- this.props.navigator.setParams({})
320
+ ```ts
321
+ navigator.setParams({})
322
322
  ```
323
323
 
324
324
  详情请参考 example 中 TopBarTitleView.js 这个文件。
@@ -351,7 +351,7 @@ hideTabBarWhenPush 表示当 stack 嵌套在 tabs 的时候,push 到另一个
351
351
 
352
352
  譬如以下是 B 页面的静态配置
353
353
 
354
- ```javascript
354
+ ```ts
355
355
  // B.js
356
356
  class B extends Component {
357
357
  static navigationItem = {
@@ -370,7 +370,7 @@ class B extends Component {
370
370
 
371
371
  从 A 页面跳转到 B 页面时,我们可以改变 B 页面中的静态设置
372
372
 
373
- ```javascript
373
+ ```ts
374
374
  // A.js
375
375
  this.props.navigator.push(
376
376
  'B',
@@ -430,7 +430,7 @@ export interface TitleItem {
430
430
  ```
431
431
 
432
432
  ```ts
433
- this.props.garden.setTitleItem({
433
+ garden.setTitleItem({
434
434
  title: '新的标题',
435
435
  })
436
436
  ```
@@ -451,8 +451,8 @@ export interface BarButtonItem {
451
451
  }
452
452
  ```
453
453
 
454
- ```javascript
455
- this.props.garden.setLeftBarButtonItem({
454
+ ```ts
455
+ garden.setLeftBarButtonItem({
456
456
  title: 'Cancel',
457
457
  insetsIOS: { top: -1, left: -8, bottom: 0, right: 8 },
458
458
  action: navigator => {
@@ -465,8 +465,8 @@ this.props.garden.setLeftBarButtonItem({
465
465
 
466
466
  更改右侧按钮
467
467
 
468
- ```javascript
469
- this.props.garden.setRightBarButtonItem({
468
+ ```ts
469
+ garden.setRightBarButtonItem({
470
470
  enabled: false,
471
471
  })
472
472
  ```
@@ -475,8 +475,8 @@ this.props.garden.setRightBarButtonItem({
475
475
 
476
476
  动态改变 tabBar 样式, 可配置项如下
477
477
 
478
- ```javascript
479
- this.props.garden.updateTabBar({
478
+ ```ts
479
+ garden.updateTabBar({
480
480
  tabBarColor: '#FFFFFF',
481
481
  tabBarShadowImage: {
482
482
  color: '#DDDDDD',
@@ -487,62 +487,47 @@ this.props.garden.updateTabBar({
487
487
  })
488
488
  ```
489
489
 
490
- - **setTabIcon(icon: TabIcon | TabIcon[])**
490
+ - **setTabItem(item: TabItemInfo | TabItemInfo[])**
491
491
 
492
- 替换 tab 图标
492
+ 动态设置 tab 的图标、文字、徽章
493
493
 
494
494
  ```ts
495
- export interface TabIcon {
495
+ export interface TabItemInfo {
496
496
  index: number
497
- icon: Image
498
- unselectedIcon?: Image
497
+ title?: string
498
+ badge?: {
499
+ text?: string
500
+ hidden: boolean
501
+ dot?: boolean
502
+ }
503
+ icon?: {
504
+ selected: ImageSource
505
+ unselected?: ImageSource
506
+ }
499
507
  }
500
508
  ```
501
509
 
502
- ```javascript
503
- this.props.garden.setTabIcon({
510
+ ```ts
511
+ garden.setTabItem({
504
512
  index: 1,
505
- icon: { uri: fontUri('FontAwesome', 'leaf', 24) },
513
+ icon: {
514
+ selected: Image.resolveAssetSource(require('./images/ic_settings.png')),
515
+ },
516
+ title: '选项',
506
517
  })
507
518
  ```
508
519
 
509
- - **setTabBadge(badge: TabBadge | TabBadge[])**
510
-
511
- 设置 badge
512
-
513
- ```ts
514
- export interface TabBadge {
515
- index: number
516
- text?: string
517
- hidden: boolean
518
- dot?: boolean // 是否作为红点显示
519
- }
520
- ```
521
-
522
- ```javascript
523
- if (hideBadge) {
524
- this.props.garden.setTabBadge([
525
- { index: 0, hidden: true },
526
- { index: 1, hidden: true },
527
- ])
528
- } else {
529
- this.props.garden.setTabBadge([
530
- { index: 0, hidden: false, dot: true },
531
- { index: 1, hidden: false, text: '99' },
532
- ])
533
- }
534
- ```
535
-
536
520
  - **setMenuInteractive(enabled: boolean)**
537
521
 
538
522
  是否允许侧滑打开抽屉
539
523
 
540
- ```javascript
541
- componentDidAppear() {
542
- this.props.garden.setMenuInteractive(true);
543
- }
544
-
545
- componentDidDisappear() {
546
- this.props.garden.setMenuInteractive(false);
547
- }
524
+ ```ts
525
+ useVisibleEffect(
526
+ useCallback(() => {
527
+ garden.setMenuInteractive(true)
528
+ return () => {
529
+ garden.setMenuInteractive(false)
530
+ }
531
+ }, [garden]),
532
+ )
548
533
  ```
@@ -97,24 +97,14 @@ RCT_EXPORT_METHOD(updateTabBar:(NSString *)sceneId item:(NSDictionary *)item) {
97
97
  }
98
98
  }
99
99
 
100
- RCT_EXPORT_METHOD(setTabBadge:(NSString *)sceneId options:(NSArray<NSDictionary *> *)options) {
100
+ RCT_EXPORT_METHOD(setTabItem:(NSString *)sceneId options:(NSArray<NSDictionary *> *)options) {
101
+ RCTLogInfo(@"[Navigator] setTabItem: %@", options);
101
102
  UIViewController *vc = [self.bridgeManager controllerForSceneId:sceneId];
102
103
  UITabBarController *tabBarController = [self tabBarControllerWithViewController:vc];
103
104
  if ([tabBarController isKindOfClass:[HBDTabBarController class]]) {
104
105
  HBDTabBarController *tabBarVC = (HBDTabBarController *)tabBarController;
105
- [tabBarVC setTabBadge:options];
106
+ [tabBarVC setTabItem:options];
106
107
  }
107
- RCTLogInfo(@"[Navigator] setTabBadge: %@", options);
108
- }
109
-
110
- RCT_EXPORT_METHOD(setTabIcon:(NSString *)sceneId options:(NSArray<NSDictionary *> *)options) {
111
- UIViewController *vc = [self.bridgeManager controllerForSceneId:sceneId];
112
- UITabBarController *tabBarController = [self tabBarControllerWithViewController:vc];
113
- if ([tabBarController isKindOfClass:[HBDTabBarController class]]) {
114
- HBDTabBarController *tabBarVC = (HBDTabBarController *)tabBarController;
115
- [tabBarVC setTabIcon:options];
116
- }
117
- RCTLogInfo(@"[Navigator] setTabIcon: %@", options);
118
108
  }
119
109
 
120
110
  RCT_EXPORT_METHOD(setMenuInteractive:(NSString *)sceneId enabled:(BOOL)enabled) {
@@ -123,7 +123,7 @@ RCT_EXPORT_METHOD(currentTab:(NSString *)sceneId resolver:(RCTPromiseResolveBloc
123
123
  }
124
124
  }
125
125
 
126
- RCT_EXPORT_METHOD(isNavigationRoot:(NSString *)sceneId resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
126
+ RCT_EXPORT_METHOD(isStackRoot:(NSString *)sceneId resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
127
127
  UIViewController *vc = [self.bridgeManager controllerForSceneId:sceneId];
128
128
  UINavigationController *nav = vc.navigationController;
129
129
  if (nav) {
@@ -16,8 +16,6 @@
16
16
 
17
17
  - (void)updateTabBar:(NSDictionary *)options;
18
18
 
19
- - (void)setTabBadge:(NSArray<NSDictionary *> *)options;
20
-
21
- - (void)setTabIcon:(NSArray<NSDictionary *> *)options;
19
+ - (void)setTabItem:(NSArray<NSDictionary *> *)options;
22
20
 
23
21
  @end
@@ -116,42 +116,11 @@
116
116
  }
117
117
  }
118
118
 
119
- - (void)setTabBadge:(NSArray<NSDictionary *> *)options {
119
+ - (void)setTabItem:(NSArray<NSDictionary *> *)options {
120
120
  for (NSDictionary *option in options) {
121
121
  NSUInteger index = option[@"index"] ? [option[@"index"] integerValue] : 0;
122
- BOOL hidden = option[@"hidden"] ? [option[@"hidden"] boolValue] : YES;
123
-
124
- NSString *text = hidden ? nil : (option[@"text"] ? option[@"text"] : nil);
125
- BOOL dot = hidden ? NO : (option[@"dot"] ? [option[@"dot"] boolValue] : NO);
126
-
127
122
  if (self.hasCustomTabBar) {
128
- NSMutableDictionary *tab = [self tabAtIndex:index];
129
- tab[@"dot"] = @(dot);
130
- tab[@"badgeText"] = RCTNullIfNil(text);
131
- } else {
132
- UIViewController *vc = self.viewControllers[index];
133
- vc.tabBarItem.badgeValue = text;
134
- UITabBar *tabBar = self.tabBar;
135
- if (dot) {
136
- [tabBar showDotBadgeAtIndex:index];
137
- } else {
138
- [tabBar hideDotBadgeAtIndex:index];
139
- }
140
- }
141
- }
142
-
143
- if (self.hasCustomTabBar) {
144
- self.rootView.appProperties = [self props];
145
- }
146
- }
147
-
148
- - (void)setTabIcon:(NSArray<NSDictionary *> *)options {
149
- for (NSDictionary *option in options) {
150
- NSUInteger index = option[@"index"] ? [option[@"index"] integerValue] : 0;
151
- if (self.hasCustomTabBar) {
152
- NSMutableDictionary *tab = [self tabAtIndex:index];
153
- tab[@"icon"] = [HBDUtils iconUriFromUri:option[@"icon"][@"uri"]];
154
- tab[@"unselectedIcon"] = RCTNullIfNil([HBDUtils iconUriFromUri:option[@"unselectedIcon"][@"uri"]]);
123
+ [self updateCustomTabItem:option atIndex:index];
155
124
  } else {
156
125
  UIViewController *tab = [self.viewControllers objectAtIndex:index];
157
126
  [tab hbd_updateTabBarItem:option];
@@ -173,6 +142,38 @@
173
142
  return tab;
174
143
  }
175
144
 
145
+ - (void)updateCustomTabItem:(NSDictionary *)option atIndex:(NSUInteger)index {
146
+ NSMutableDictionary *tab = [self tabAtIndex:index];
147
+
148
+ // title
149
+ NSString *title = option[@"title"];
150
+ if (title != nil) {
151
+ tab[@"title"] = title;
152
+ }
153
+
154
+ // icon title
155
+ NSDictionary *icon = option[@"icon"];
156
+ if (icon != nil) {
157
+ NSDictionary *selected = icon[@"selected"];
158
+ tab[@"icon"] = [HBDUtils iconUriFromUri:selected[@"uri"]];
159
+
160
+ NSDictionary *unselected = icon[@"unselected"];
161
+ if (unselected != nil) {
162
+ tab[@"unselectedIcon"] = RCTNullIfNil([HBDUtils iconUriFromUri:unselected[@"uri"]]);
163
+ }
164
+ }
165
+
166
+ // badge
167
+ NSDictionary *badge = option[@"badge"];
168
+ if (badge != nil) {
169
+ BOOL hidden = badge[@"hidden"] ? [badge[@"hidden"] boolValue] : YES;
170
+ NSString *text = hidden ? nil : (badge[@"text"] ? badge[@"text"] : nil);
171
+ BOOL dot = hidden ? NO : (badge[@"dot"] ? [badge[@"dot"] boolValue] : NO);
172
+ tab[@"dot"] = @(dot);
173
+ tab[@"badgeText"] = RCTNullIfNil(text);
174
+ }
175
+ }
176
+
176
177
  - (void)updateTabBar:(NSDictionary *)options {
177
178
  UITabBar *tabBar = self.tabBar;
178
179
  NSString *tabBarColor = [options objectForKey:@"tabBarColor"];
@@ -285,6 +285,11 @@
285
285
  }
286
286
 
287
287
  [self applyNavigationBarOptions:target];
288
+
289
+ NSString *screenColor = options[@"screenBackgroundColor"];
290
+ if (screenColor && [self isViewLoaded]) {
291
+ self.view.backgroundColor = [HBDUtils colorWithHexString:screenColor];
292
+ }
288
293
 
289
294
  NSNumber *statusBarHidden = [options objectForKey:@"statusBarHidden"];
290
295
  if (statusBarHidden) {
@@ -13,6 +13,7 @@
13
13
  #import "HBDModalViewController.h"
14
14
  #import <React/RCTLog.h>
15
15
  #import "HBDGarden.h"
16
+ #import "UITabBar+Badge.h"
16
17
 
17
18
  @implementation UIViewController (HBD)
18
19
 
@@ -368,19 +369,44 @@
368
369
  return nil;
369
370
  }
370
371
 
371
- - (void)hbd_updateTabBarItem:(NSDictionary *)options {
372
- NSDictionary *unselectedIcon = options[@"unselectedIcon"];
373
- NSDictionary *icon = options[@"icon"];
374
- UITabBarItem *tabBarItem = nil;
375
- if (unselectedIcon) {
376
- UIImage *selectedImage = [[HBDUtils UIImage:icon] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
377
- UIImage *image = [[HBDUtils UIImage:unselectedIcon] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
378
- tabBarItem = [[UITabBarItem alloc] initWithTitle:self.tabBarItem.title image:image selectedImage:selectedImage];
379
- } else {
380
- tabBarItem = [[UITabBarItem alloc] initWithTitle:self.tabBarItem.title image:[HBDUtils UIImage:icon] selectedImage:nil];
372
+ - (void)hbd_updateTabBarItem:(NSDictionary *)option {
373
+ UITabBarItem *tabBarItem = self.tabBarItem;
374
+ NSUInteger index = option[@"index"] ? [option[@"index"] integerValue] : 0;
375
+
376
+ // title
377
+ NSString *title = option[@"title"];
378
+ if (title != nil) {
379
+ tabBarItem.title = title;
380
+ }
381
+
382
+ // icon
383
+ NSDictionary *icon = option[@"icon"];
384
+ if (icon != nil) {
385
+ NSDictionary *unselected = icon[@"unselected"];
386
+ NSDictionary *selected = icon[@"selected"];
387
+ if (unselected) {
388
+ tabBarItem.selectedImage = [[HBDUtils UIImage:selected] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
389
+ tabBarItem.image = [[HBDUtils UIImage:unselected] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
390
+ } else {
391
+ tabBarItem.image = [HBDUtils UIImage:selected];
392
+ }
393
+ }
394
+
395
+ // badge
396
+ NSDictionary *badge = option[@"badge"];
397
+ if (badge != nil) {
398
+ BOOL hidden = badge[@"hidden"] ? [badge[@"hidden"] boolValue] : YES;
399
+ NSString *text = hidden ? nil : (badge[@"text"] ? badge[@"text"] : nil);
400
+ BOOL dot = hidden ? NO : (badge[@"dot"] ? [badge[@"dot"] boolValue] : NO);
401
+
402
+ tabBarItem.badgeValue = text;
403
+ UITabBar *tabBar = self.tabBarController.tabBar;
404
+ if (dot) {
405
+ [tabBar showDotBadgeAtIndex:index];
406
+ } else {
407
+ [tabBar hideDotBadgeAtIndex:index];
408
+ }
381
409
  }
382
- tabBarItem.badgeValue = self.tabBarItem.badgeValue;
383
- self.tabBarItem = tabBarItem;
384
410
  }
385
411
 
386
412
  - (NSString *)hbd_mode {
package/lib/Garden.d.ts CHANGED
@@ -41,6 +41,19 @@ export interface TabBadge {
41
41
  hidden: boolean;
42
42
  dot?: boolean;
43
43
  }
44
+ export interface TabItemInfo {
45
+ index: number;
46
+ title?: string;
47
+ badge?: {
48
+ text?: string;
49
+ hidden: boolean;
50
+ dot?: boolean;
51
+ };
52
+ icon?: {
53
+ selected: ImageSource;
54
+ unselected?: ImageSource;
55
+ };
56
+ }
44
57
  export interface TabIcon {
45
58
  index: number;
46
59
  icon: ImageSource;
@@ -60,6 +73,7 @@ export declare class Garden {
60
73
  setTitleItem(titleItem: TitleItem): void;
61
74
  updateOptions(options: NavigationOption): void;
62
75
  updateTabBar(options: TabBarStyle): void;
76
+ setTabItem(item: TabItemInfo | TabItemInfo[]): void;
63
77
  setTabIcon(icon: TabIcon | TabIcon[]): void;
64
78
  setTabBadge(badge: TabBadge | TabBadge[]): void;
65
79
  setMenuInteractive(enabled: boolean): void;
package/lib/Garden.js CHANGED
@@ -35,17 +35,48 @@ export class Garden {
35
35
  updateTabBar(options) {
36
36
  GardenModule.updateTabBar(this.sceneId, options);
37
37
  }
38
+ setTabItem(item) {
39
+ if (!Array.isArray(item)) {
40
+ item = [item];
41
+ }
42
+ GardenModule.setTabItem(this.sceneId, item);
43
+ }
38
44
  setTabIcon(icon) {
45
+ console.warn(`Garden#setTabIcon is deprecated, use Garden#setTabItem instead.`);
39
46
  if (!Array.isArray(icon)) {
40
47
  icon = [icon];
41
48
  }
42
- GardenModule.setTabIcon(this.sceneId, icon);
49
+ const icons = icon;
50
+ const items = [];
51
+ for (const i of icons) {
52
+ items.push({
53
+ index: i.index,
54
+ icon: {
55
+ selected: i.icon,
56
+ unselected: i.unselectedIcon,
57
+ },
58
+ });
59
+ }
60
+ this.setTabItem(items);
43
61
  }
44
62
  setTabBadge(badge) {
63
+ console.warn(`Garden#setTabBadge is deprecated, use Garden#setTabItem instead.`);
45
64
  if (!Array.isArray(badge)) {
46
65
  badge = [badge];
47
66
  }
48
- GardenModule.setTabBadge(this.sceneId, badge);
67
+ const badges = badge;
68
+ const items = [];
69
+ for (const b of badges) {
70
+ items.push({
71
+ index: b.index,
72
+ badge: {
73
+ hidden: b.hidden,
74
+ text: b.text,
75
+ dot: b.dot,
76
+ },
77
+ });
78
+ }
79
+ this.setTabItem(items);
49
80
  }
50
81
  setMenuInteractive(enabled) {
51
82
  GardenModule.setMenuInteractive(this.sceneId, enabled);
package/lib/Navigator.js CHANGED
@@ -233,7 +233,7 @@ export class Navigator {
233
233
  });
234
234
  }
235
235
  isStackRoot() {
236
- return NavigationModule.isNavigationRoot(this.sceneId);
236
+ return NavigationModule.isStackRoot(this.sceneId);
237
237
  }
238
238
  async present(moduleName, props = {}, options = {}) {
239
239
  const requestCode = --tag;
package/lib/typing.d.ts CHANGED
@@ -38,6 +38,7 @@ export declare const LayoutFittingCompressed = "compressed";
38
38
  export declare type LayoutFittingCompressed = typeof LayoutFittingCompressed;
39
39
  export declare type LayoutFitting = LayoutFittingExpanded | LayoutFittingCompressed;
40
40
  export interface NavigationOption {
41
+ screenBackgroundColor?: Color;
41
42
  passThroughTouches?: boolean;
42
43
  statusBarHidden?: boolean;
43
44
  statusBarColorAndroid?: Color;
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.4.3",
4
+ "version": "2.7.0",
5
5
  "keywords": [
6
6
  "react-native",
7
7
  "navigation",
@@ -40,13 +40,13 @@
40
40
  "path-to-regexp": "^6.1.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@babel/core": "^7.13.10",
44
- "@babel/runtime": "^7.13.10",
43
+ "@babel/core": "^7.16.0",
44
+ "@babel/runtime": "^7.16.0",
45
45
  "@gfez/eslint-config-react-native": "^1.0.0",
46
- "@react-native-community/hooks": "^2.7.0",
46
+ "@react-native-community/hooks": "^2.8.0",
47
47
  "@types/jest": "^27.0.1",
48
48
  "@types/react": "^17.0.1",
49
- "@types/react-native": "^0.65.3",
49
+ "@types/react-native": "^0.66.2",
50
50
  "@types/react-redux": "^7.1.9",
51
51
  "@types/react-test-renderer": "17.0.1",
52
52
  "babel-jest": "^27.2.0",
@@ -54,10 +54,10 @@
54
54
  "jest": "^27.2.0",
55
55
  "metro-react-native-babel-preset": "^0.66.2",
56
56
  "react": "17.0.2",
57
- "react-native": "^0.66.1",
57
+ "react-native": "^0.66.2",
58
58
  "react-native-fast-image": "^8.5.11",
59
59
  "react-native-iphone-x-helper": "^1.2.0",
60
- "react-native-keyboard-aware-scroll-view": "^0.9.3",
60
+ "react-native-keyboard-aware-scroll-view": "^0.9.5",
61
61
  "react-native-toast-hybrid": "^2.4.4",
62
62
  "react-redux": "^7.2.5",
63
63
  "react-test-renderer": "17.0.2",
@@ -1,81 +0,0 @@
1
- package com.reactnative.hybridnavigation;
2
-
3
- import android.os.Handler;
4
- import android.os.Looper;
5
-
6
- import androidx.lifecycle.Lifecycle;
7
- import androidx.lifecycle.LifecycleObserver;
8
- import androidx.lifecycle.LifecycleOwner;
9
- import androidx.lifecycle.OnLifecycleEvent;
10
-
11
- import java.util.LinkedList;
12
- import java.util.Queue;
13
-
14
- public class UiTaskExecutor implements LifecycleObserver {
15
-
16
- private final Queue<Runnable> tasks = new LinkedList<>();
17
-
18
- private final LifecycleOwner lifecycleOwner;
19
- private final Handler handler;
20
-
21
- public UiTaskExecutor(LifecycleOwner lifecycleOwner, Handler handler) {
22
- this.lifecycleOwner = lifecycleOwner;
23
- this.handler = handler;
24
- getLifecycle().addObserver(this);
25
- }
26
-
27
- public void submit(Runnable task) {
28
- if (getLifecycle().getCurrentState() != Lifecycle.State.DESTROYED) {
29
- handler.post(() -> {
30
- tasks.add(task);
31
- considerExecute();
32
- });
33
- }
34
- }
35
-
36
- @OnLifecycleEvent(Lifecycle.Event.ON_ANY)
37
- void onStateChange() {
38
- if (getLifecycle().getCurrentState() == Lifecycle.State.DESTROYED) {
39
- getLifecycle().removeObserver(this);
40
- handler.removeCallbacks(executeTask);
41
- } else {
42
- handler.post(executeTask);
43
- }
44
- }
45
-
46
- private boolean executing;
47
-
48
- void considerExecute() {
49
- if (isAtLeastStarted() && !executing) {
50
- assertMainThread();
51
- executing = true;
52
- Runnable runnable = tasks.poll();
53
- while (runnable != null) {
54
- runnable.run();
55
- runnable = tasks.poll();
56
- }
57
- executing = false;
58
- }
59
- }
60
-
61
- private final Runnable executeTask = this::considerExecute;
62
-
63
- boolean isAtLeastStarted() {
64
- return getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED);
65
- }
66
-
67
- private Lifecycle getLifecycle() {
68
- return lifecycleOwner.getLifecycle();
69
- }
70
-
71
- private void assertMainThread() {
72
- if (!isMainThread()) {
73
- throw new IllegalStateException("You should perform the task at main thread.");
74
- }
75
- }
76
-
77
- static boolean isMainThread() {
78
- return Looper.getMainLooper().getThread() == Thread.currentThread();
79
- }
80
-
81
- }