hybrid-navigation 2.13.0-beta.0 → 2.13.0-beta.3

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 (67) hide show
  1. package/android/src/main/java/com/reactnative/hybridnavigation/GardenModule.java +4 -0
  2. package/ios/HybridNavigation/HBDAnimationObserver.h +24 -0
  3. package/ios/HybridNavigation/HBDAnimationObserver.m +45 -0
  4. package/ios/HybridNavigation/HBDUtils.h +3 -6
  5. package/ios/HybridNavigation/HBDUtils.m +34 -0
  6. package/ios/HybridNavigation/Navigator/HBDScreenNavigator.m +5 -0
  7. package/ios/HybridNavigation/Navigator/HBDStackNavigator.m +11 -2
  8. package/ios/HybridNavigation/ReactBridge/HBDGardenModule.h +2 -1
  9. package/ios/HybridNavigation/ReactBridge/HBDGardenModule.m +37 -4
  10. package/ios/HybridNavigation/ReactBridge/HBDNavigationModule.m +3 -1
  11. package/ios/HybridNavigation/View/HBDRootView.h +3 -1
  12. package/ios/HybridNavigation/View/HBDRootView.m +20 -17
  13. package/ios/HybridNavigation/ViewController/HBDNavigationController.m +0 -30
  14. package/ios/HybridNavigation/ViewController/HBDReactViewController.m +2 -2
  15. package/ios/HybridNavigation/ViewController/HBDTabBarController.m +3 -2
  16. package/ios/HybridNavigation/ViewController/HBDViewController.m +13 -5
  17. package/ios/HybridNavigation/ViewController/UINavigationController+HBD.m +0 -3
  18. package/lib/Event.d.ts +22 -0
  19. package/lib/Event.js +117 -0
  20. package/lib/Garden.d.ts +5 -64
  21. package/lib/Garden.js +17 -44
  22. package/lib/GardenModule.d.ts +20 -0
  23. package/lib/GardenModule.js +3 -0
  24. package/lib/NavigationModule.d.ts +33 -24
  25. package/lib/NavigationModule.js +79 -25
  26. package/lib/Navigator.d.ts +33 -17
  27. package/lib/Navigator.js +106 -170
  28. package/lib/{typing.d.ts → Options.d.ts} +46 -50
  29. package/lib/{typing.js → Options.js} +0 -0
  30. package/lib/ReactRegistry.d.ts +2 -3
  31. package/lib/ReactRegistry.js +8 -28
  32. package/lib/Route.d.ts +74 -0
  33. package/lib/{router/typing.js → Route.js} +0 -0
  34. package/lib/hooks.d.ts +0 -1
  35. package/lib/hooks.js +18 -24
  36. package/lib/index.d.ts +3 -2
  37. package/lib/index.js +4 -2
  38. package/lib/router/drawer.d.ts +1 -1
  39. package/lib/router/index.d.ts +4 -7
  40. package/lib/router/index.js +1 -6
  41. package/lib/router/screen.d.ts +1 -1
  42. package/lib/router/stack.d.ts +1 -1
  43. package/lib/router/tabs.d.ts +1 -1
  44. package/lib/store.d.ts +0 -9
  45. package/lib/store.js +0 -22
  46. package/package.json +1 -2
  47. package/src/Event.ts +188 -0
  48. package/src/Garden.ts +28 -118
  49. package/src/GardenModule.ts +24 -0
  50. package/src/NavigationModule.ts +118 -33
  51. package/src/Navigator.ts +164 -209
  52. package/src/{typing.ts → Options.ts} +51 -57
  53. package/src/ReactRegistry.tsx +17 -40
  54. package/src/Route.ts +88 -0
  55. package/src/hooks.ts +23 -32
  56. package/src/index.ts +5 -2
  57. package/src/router/drawer.ts +1 -1
  58. package/src/router/index.ts +21 -12
  59. package/src/router/screen.ts +1 -1
  60. package/src/router/stack.ts +1 -1
  61. package/src/router/tabs.ts +1 -1
  62. package/src/store.ts +0 -28
  63. package/lib/router/typing.d.ts +0 -37
  64. package/lib/utils.d.ts +0 -9
  65. package/lib/utils.js +0 -50
  66. package/src/router/typing.ts +0 -45
  67. package/src/utils.ts +0 -83
@@ -25,9 +25,11 @@ import com.facebook.react.bridge.ReadableArray;
25
25
  import com.facebook.react.bridge.ReadableMap;
26
26
  import com.facebook.react.bridge.UiThreadUtil;
27
27
  import com.facebook.react.bridge.WritableMap;
28
+ import com.facebook.react.uimanager.PixelUtil;
28
29
  import com.navigation.androidx.AwesomeFragment;
29
30
  import com.navigation.androidx.DrawerFragment;
30
31
  import com.navigation.androidx.FragmentHelper;
32
+ import com.navigation.androidx.SystemUI;
31
33
  import com.navigation.androidx.TabBarFragment;
32
34
 
33
35
  import java.util.HashMap;
@@ -54,6 +56,8 @@ public class GardenModule extends ReactContextBaseJavaModule {
54
56
  public Map<String, Object> getConstants() {
55
57
  final Map<String, Object> constants = new HashMap<>();
56
58
  constants.put("TOOLBAR_HEIGHT", 56);
59
+ float statusBarHeight = PixelUtil.toDIPFromPixel(SystemUI.getStatusBarHeight(getReactApplicationContext()));
60
+ constants.put("STATUSBAR_HEIGHT", statusBarHeight);
57
61
  return constants;
58
62
  }
59
63
 
@@ -0,0 +1,24 @@
1
+ // fork from: https://github.com/wix/react-native-navigation/blob/master/lib/ios/AnimationObserver.h
2
+ #import <Foundation/Foundation.h>
3
+
4
+ typedef void (^HBDAnimationEndedBlock)(void);
5
+
6
+ NS_ASSUME_NONNULL_BEGIN
7
+
8
+ @interface HBDAnimationObserver : NSObject
9
+
10
+ + (HBDAnimationObserver *)sharedObserver;
11
+
12
+ @property(nonatomic) BOOL isAnimating;
13
+
14
+ - (void)registerAnimationEndedBlock:(HBDAnimationEndedBlock)block;
15
+
16
+ - (void)beginAnimation;
17
+
18
+ - (void)endAnimation;
19
+
20
+ - (void)invalidate;
21
+
22
+ @end
23
+
24
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,45 @@
1
+ #import "HBDAnimationObserver.h"
2
+
3
+ @implementation HBDAnimationObserver {
4
+ NSMutableArray<HBDAnimationEndedBlock> *_animationEndedBlocks;
5
+ }
6
+
7
+ - (instancetype)init {
8
+ self = [super init];
9
+ _animationEndedBlocks = [NSMutableArray array];
10
+ return self;
11
+ }
12
+
13
+ + (HBDAnimationObserver *)sharedObserver {
14
+ static HBDAnimationObserver *_sharedObserver = nil;
15
+ static dispatch_once_t onceToken;
16
+ dispatch_once(&onceToken, ^{
17
+ _sharedObserver = [[HBDAnimationObserver alloc] init];
18
+ });
19
+
20
+ return _sharedObserver;
21
+ }
22
+
23
+ - (void)registerAnimationEndedBlock:(HBDAnimationEndedBlock)block {
24
+ [_animationEndedBlocks addObject:block];
25
+ }
26
+
27
+ - (void)beginAnimation {
28
+ _isAnimating = YES;
29
+ }
30
+
31
+ - (void)endAnimation {
32
+ _isAnimating = NO;
33
+
34
+ for (HBDAnimationEndedBlock block in _animationEndedBlocks) {
35
+ block();
36
+ }
37
+
38
+ [_animationEndedBlocks removeAllObjects];
39
+ }
40
+
41
+ - (void)invalidate {
42
+ [_animationEndedBlocks removeAllObjects];
43
+ }
44
+
45
+ @end
@@ -5,12 +5,7 @@ UIKIT_STATIC_INLINE BOOL colorHasAlphaComponent(UIColor *color) {
5
5
  if (!color) {
6
6
  return YES;
7
7
  }
8
- CGFloat red = 0;
9
- CGFloat green = 0;
10
- CGFloat blue = 0;
11
- CGFloat alpha = 0;
12
- [color getRed:&red green:&green blue:&blue alpha:&alpha];
13
- return alpha < 1.0;
8
+ return CGColorGetAlpha(color.CGColor) < 1.0;
14
9
  }
15
10
 
16
11
  UIKIT_STATIC_INLINE BOOL imageHasAlphaChannel(UIImage *image) {
@@ -51,4 +46,6 @@ UIKIT_STATIC_INLINE void hbd_exchangeImplementations(Class clazz, SEL originalSe
51
46
 
52
47
  + (BOOL)isInCall;
53
48
 
49
+ + (void)printViewHierarchy:(UIView *)view withPrefix:(NSString *)prefix;
50
+
54
51
  @end
@@ -1,5 +1,6 @@
1
1
  #import "HBDUtils.h"
2
2
 
3
+ #import "HBDAnimationObserver.h"
3
4
  #import <React/RCTConvert.h>
4
5
 
5
6
  @implementation HBDUtils
@@ -177,4 +178,37 @@
177
178
  }
178
179
  }
179
180
 
181
+ + (void)printViewHierarchy:(UIView *)view withPrefix:(NSString *)prefix {
182
+ NSString *viewName = [[[view classForCoder] description] stringByReplacingOccurrencesOfString:@"_" withString:@""];
183
+ NSLog(@"%@%@ %@", prefix, viewName, NSStringFromCGRect(view.frame));
184
+ if (view.subviews.count > 0) {
185
+ for (UIView *sub in view.subviews) {
186
+ [self printViewHierarchy:sub withPrefix:[NSString stringWithFormat:@"--%@", prefix]];
187
+ }
188
+ }
189
+ }
190
+
191
+ static void (*__SWZ_didMoveToWindow_orig)(id self, SEL _cmd);
192
+
193
+ static void __HBD_didMoveToWindow(UIView *self, SEL _cmd) {
194
+ if (![[HBDAnimationObserver sharedObserver] isAnimating] || !self.window) {
195
+ __SWZ_didMoveToWindow_orig(self, _cmd);
196
+ } else {
197
+ [[HBDAnimationObserver sharedObserver] registerAnimationEndedBlock:^{
198
+ __SWZ_didMoveToWindow_orig(self, _cmd);
199
+ }];
200
+ }
201
+ }
202
+
203
+ + (void)load {
204
+ Class clazz = NSClassFromString(@"RCTBaseTextInputView");
205
+ if (clazz == NULL) {
206
+ return;
207
+ }
208
+ Method method = class_getInstanceMethod(clazz, NSSelectorFromString(@"didMoveToWindow"));
209
+ __SWZ_didMoveToWindow_orig = (void *)method_getImplementation(method);
210
+ method_setImplementation(method, (IMP)__HBD_didMoveToWindow);
211
+ }
212
+
213
+
180
214
  @end
@@ -2,6 +2,7 @@
2
2
 
3
3
  #import "HBDReactBridgeManager.h"
4
4
  #import "HBDNavigationController.h"
5
+ #import "HBDAnimationObserver.h"
5
6
 
6
7
  #import <React/RCTLog.h>
7
8
 
@@ -101,6 +102,7 @@
101
102
  HBDNavigationController *nav = [[HBDNavigationController alloc] initWithRootViewController:vc];
102
103
  nav.modalPresentationStyle = UIModalPresentationCurrentContext;
103
104
  [nav setRequestCode:requestCode];
105
+ [[HBDAnimationObserver sharedObserver] beginAnimation];
104
106
  [presenting presentViewController:nav animated:YES completion:^{
105
107
  callback(@[NSNull.null, @YES]);
106
108
  }];
@@ -118,6 +120,7 @@
118
120
  vc.modalPresentationStyle = UIModalPresentationOverFullScreen;
119
121
  vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
120
122
  [vc setRequestCode:requestCode];
123
+ [[HBDAnimationObserver sharedObserver] beginAnimation];
121
124
  [presenting presentViewController:vc animated:YES completion:^{
122
125
  callback(@[NSNull.null, @YES]);
123
126
  }];
@@ -129,6 +132,7 @@
129
132
  UIViewController *vc = [[HBDReactBridgeManager get] viewControllerWithLayout:layout];
130
133
  [vc setRequestCode:requestCode];
131
134
  vc.modalPresentationStyle = UIModalPresentationCurrentContext;
135
+ [[HBDAnimationObserver sharedObserver] beginAnimation];
132
136
  [presenting presentViewController:vc animated:YES completion:^{
133
137
  callback(@[NSNull.null, @YES]);
134
138
  }];
@@ -141,6 +145,7 @@
141
145
  vc.modalPresentationStyle = UIModalPresentationOverFullScreen;
142
146
  vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
143
147
  [vc setRequestCode:requestCode];
148
+ [[HBDAnimationObserver sharedObserver] beginAnimation];
144
149
  [presenting presentViewController:vc animated:YES completion:^{
145
150
  callback(@[NSNull.null, @YES]);
146
151
  }];
@@ -3,6 +3,7 @@
3
3
  #import "HBDReactBridgeManager.h"
4
4
  #import "HBDNavigationController.h"
5
5
  #import "UINavigationController+HBD.h"
6
+ #import "HBDAnimationObserver.h"
6
7
 
7
8
  @implementation HBDStackNavigator
8
9
 
@@ -117,7 +118,7 @@
117
118
  }
118
119
  }
119
120
 
120
- - (void)handlePushWithNavigationController:(UINavigationController *)nav extras:(NSDictionary *)extras callback:(RCTResponseSenderBlock)callback {
121
+ - (void)handlePushWithNavigationController:(UINavigationController *)nav extras:(NSDictionary *)extras callback:(RCTResponseSenderBlock)callback {
121
122
  UIViewController *vc = [self viewControllerWithExtras:extras];
122
123
  if (!vc) {
123
124
  callback(@[NSNull.null, @NO]);
@@ -125,6 +126,7 @@
125
126
  }
126
127
 
127
128
  vc.hidesBottomBarWhenPushed = nav.hidesBottomBarWhenPushed;
129
+ [[HBDAnimationObserver sharedObserver] beginAnimation];
128
130
  [nav pushViewController:vc animated:YES];
129
131
  [self animateAlongsideTransition:nav callback:callback];
130
132
  }
@@ -134,7 +136,7 @@
134
136
  [self animateAlongsideTransition:nav callback:callback];
135
137
  }
136
138
 
137
- - (void)handlePopToWithNavigationController:(UINavigationController *)nav extras:(NSDictionary *)extras callback:(RCTResponseSenderBlock)callback {
139
+ - (void)handlePopToWithNavigationController:(UINavigationController *)nav extras:(NSDictionary *)extras callback:(RCTResponseSenderBlock)callback {
138
140
  UIViewController *vc = [self findViewControllerWithNavigationController:nav extras:extras];
139
141
  if (!vc) {
140
142
  callback(@[NSNull.null, @NO]);
@@ -170,12 +172,18 @@
170
172
  }
171
173
 
172
174
  - (void)handleRedirectToWithNavigationController:(UINavigationController *)nav target:(UIViewController *)target extras:(NSDictionary *)extras callback:(RCTResponseSenderBlock)callback {
175
+ if (![nav.childViewControllers containsObject:target]) {
176
+ callback(@[NSNull.null, @NO]);
177
+ return;
178
+ }
179
+
173
180
  UIViewController *vc = [self viewControllerWithExtras:extras];
174
181
  if (!vc) {
175
182
  callback(@[NSNull.null, @NO]);
176
183
  return;
177
184
  }
178
185
 
186
+ [[HBDAnimationObserver sharedObserver] beginAnimation];
179
187
  [nav redirectToViewController:vc target:target animated:YES];
180
188
  [self animateAlongsideTransition:nav callback:callback];
181
189
  }
@@ -189,6 +197,7 @@
189
197
  }
190
198
 
191
199
  vc.hidesBottomBarWhenPushed = nav.hidesBottomBarWhenPushed;
200
+ [[HBDAnimationObserver sharedObserver] beginAnimation];
192
201
  [nav pushViewController:vc animated:YES];
193
202
  [self animateAlongsideTransition:nav callback:callback];
194
203
  }
@@ -1,5 +1,6 @@
1
1
  #import <React/RCTBridgeModule.h>
2
+ #import <React/RCTEventEmitter.h>
2
3
 
3
- @interface HBDGardenModule : NSObject <RCTBridgeModule>
4
+ @interface HBDGardenModule : RCTEventEmitter <RCTBridgeModule>
4
5
 
5
6
  @end
@@ -6,6 +6,8 @@
6
6
 
7
7
  #import <React/RCTLog.h>
8
8
 
9
+ static NSString *const EVENT_STATUSBAR_FRAME_CHANGE = @"EVENT_STATUSBAR_FRAME_CHANGE";
10
+
9
11
  @interface HBDGardenModule ()
10
12
 
11
13
  @property(nonatomic, strong, readonly) HBDReactBridgeManager *bridgeManager;
@@ -14,25 +16,56 @@
14
16
 
15
17
  @implementation HBDGardenModule
16
18
 
19
+ RCT_EXPORT_MODULE(GardenModule)
20
+
17
21
  + (BOOL)requiresMainQueueSetup {
18
22
  return YES;
19
23
  }
20
24
 
21
- RCT_EXPORT_MODULE(GardenModule)
25
+ - (dispatch_queue_t)methodQueue {
26
+ return dispatch_get_main_queue();
27
+ }
22
28
 
23
29
  - (instancetype)init {
24
30
  if (self = [super init]) {
25
31
  _bridgeManager = [HBDReactBridgeManager get];
32
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleStatusBarFrameChange) name:UIApplicationDidChangeStatusBarFrameNotification object:nil];
26
33
  }
27
34
  return self;
28
35
  }
29
36
 
30
- - (dispatch_queue_t)methodQueue {
31
- return dispatch_get_main_queue();
37
+ - (void)dealloc {
38
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidChangeStatusBarFrameNotification object:nil];
32
39
  }
33
40
 
34
41
  - (NSDictionary *)constantsToExport {
35
- return @{@"TOOLBAR_HEIGHT": @(44)};
42
+ return @{
43
+ @"TOOLBAR_HEIGHT": @(44),
44
+ @"STATUSBAR_HEIGHT": @([self currentStatusBarHeight]),
45
+ @"EVENT_STATUSBAR_FRAME_CHANGE": EVENT_STATUSBAR_FRAME_CHANGE,
46
+ };
47
+ }
48
+
49
+ - (NSArray<NSString *> *)supportedEvents {
50
+ return @[EVENT_STATUSBAR_FRAME_CHANGE];
51
+ }
52
+
53
+ - (CGFloat)currentStatusBarHeight {
54
+ if (@available(iOS 13.0, *)) {
55
+ UIStatusBarManager *statusBarManager = [UIApplication sharedApplication].keyWindow.windowScene.statusBarManager;
56
+ return statusBarManager.statusBarFrame.size.height;
57
+ } else {
58
+ return [[UIApplication sharedApplication] statusBarFrame].size.height;
59
+ }
60
+ }
61
+
62
+ - (void)handleStatusBarFrameChange {
63
+ RCTLogInfo(@"[Navigator] handleStatusBarFrameChange: %f", [self currentStatusBarHeight]);
64
+ if ([self.bridge isValid]) {
65
+ [self sendEventWithName:EVENT_STATUSBAR_FRAME_CHANGE body:@{
66
+ @"statusBarHeight": @([self currentStatusBarHeight])
67
+ }];
68
+ }
36
69
  }
37
70
 
38
71
  RCT_EXPORT_METHOD(setStyle:(NSDictionary *) style) {
@@ -2,6 +2,7 @@
2
2
 
3
3
  #import "HBDReactBridgeManager.h"
4
4
  #import "HBDReactViewController.h"
5
+ #import "HBDAnimationObserver.h"
5
6
 
6
7
  #import <React/RCTLog.h>
7
8
 
@@ -29,6 +30,7 @@ RCT_EXPORT_MODULE(NavigationModule)
29
30
  - (void)invalidate {
30
31
  RCTLogInfo(@"[Navigator] NavigationModule#invalidate");
31
32
  [NSObject cancelPreviousPerformRequestsWithTarget:self];
33
+ [[HBDAnimationObserver sharedObserver] invalidate];
32
34
  [self.bridgeManager invalidate];
33
35
  }
34
36
 
@@ -59,7 +61,7 @@ RCT_EXPORT_METHOD(signalFirstRenderComplete:(NSString *) sceneId) {
59
61
  // RCTLogInfo(@"[Navigator] signalFirstRenderComplete sceneId:%@", sceneId);
60
62
  UIViewController *vc = [self.bridgeManager viewControllerWithSceneId:sceneId];
61
63
  if ([vc isKindOfClass:[HBDReactViewController class]]) {
62
- [(HBDReactViewController *) vc signalFirstRenderComplete];
64
+ [(HBDReactViewController *)vc signalFirstRenderComplete];
63
65
  }
64
66
  }
65
67
 
@@ -1,5 +1,7 @@
1
1
  #import <React/RCTRootView.h>
2
2
 
3
- @interface HBDRootView : RCTRootView
3
+ @interface HBDRootView : UIView
4
+
5
+ - (instancetype)initWithRootView:(RCTRootView *)rootView;
4
6
 
5
7
  @end
@@ -1,28 +1,31 @@
1
1
  #import "HBDRootView.h"
2
2
 
3
+ @interface HBDRootView ()
4
+
5
+ @property (nonatomic, strong, readonly) RCTRootView *rootView;
6
+
7
+ @end
8
+
3
9
  @implementation HBDRootView
4
10
 
11
+ - (instancetype)initWithRootView:(RCTRootView *)rootView {
12
+ if (self = [super initWithFrame:[UIScreen mainScreen].bounds]) {
13
+ _rootView = rootView;
14
+ }
15
+ return self;
16
+ }
17
+
5
18
  - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
6
19
  UIView *hitView = [super hitTest:point withEvent:event];
7
- if (self.passThroughTouches && hitView) {
8
- UIView *view = self.contentView.subviews.firstObject;
9
- while (view) {
10
- if (view == hitView) {
11
- if (CGRectEqualToRect(view.frame, self.bounds)) {
12
- return nil;
13
- } else {
14
- break;
15
- }
16
- } else {
17
- view = view.subviews.firstObject;
18
- }
20
+ if (self.rootView.passThroughTouches) {
21
+ if (hitView == self) {
22
+ return nil;
23
+ }
24
+
25
+ if (hitView && CGRectEqualToRect(hitView.frame, self.rootView.bounds)) {
26
+ return nil;
19
27
  }
20
28
  }
21
-
22
- if (!hitView.window) {
23
- return nil;
24
- }
25
-
26
29
  return hitView;
27
30
  }
28
31
 
@@ -11,36 +11,6 @@
11
11
 
12
12
  #define hairlineWidth (1.f/[UIScreen mainScreen].scale)
13
13
 
14
- UIColor *blendColor(UIColor *from, UIColor *to, CGFloat percent) {
15
- CGFloat fromRed = 0;
16
- CGFloat fromGreen = 0;
17
- CGFloat fromBlue = 0;
18
- CGFloat fromAlpha = 0;
19
- [from getRed:&fromRed green:&fromGreen blue:&fromBlue alpha:&fromAlpha];
20
-
21
- CGFloat toRed = 0;
22
- CGFloat toGreen = 0;
23
- CGFloat toBlue = 0;
24
- CGFloat toAlpha = 0;
25
- [to getRed:&toRed green:&toGreen blue:&toBlue alpha:&toAlpha];
26
-
27
- CGFloat newRed = fromRed + (toRed - fromRed) * fminf(1, (float) (percent * 4));
28
- CGFloat newGreen = fromGreen + (toGreen - fromGreen) * fminf(1, (float) (percent * 4));
29
- CGFloat newBlue = fromBlue + (toBlue - fromBlue) * fminf(1, (float) (percent * 4));
30
- CGFloat newAlpha = fromAlpha + (toAlpha - fromAlpha) * fminf(1, (float) (percent * 4));
31
- return [UIColor colorWithRed:newRed green:newGreen blue:newBlue alpha:newAlpha];
32
- }
33
-
34
- void printViewHierarchy(UIView *view, NSString *prefix) {
35
- NSString *viewName = [[[view classForCoder] description] stringByReplacingOccurrencesOfString:@"_" withString:@""];
36
- NSLog(@"%@%@ %@", prefix, viewName, NSStringFromCGRect(view.frame));
37
- if (view.subviews.count > 0) {
38
- for (UIView *sub in view.subviews) {
39
- printViewHierarchy(sub, [NSString stringWithFormat:@"--%@", prefix]);
40
- }
41
- }
42
- }
43
-
44
14
  @interface HBDNavigationControllerDelegate : UIScreenEdgePanGestureRecognizer <UINavigationControllerDelegate, UIGestureRecognizerDelegate>
45
15
 
46
16
  @property(nonatomic, weak) id <UINavigationControllerDelegate> proxyDelegate;
@@ -37,14 +37,14 @@
37
37
  }
38
38
 
39
39
  - (void)loadView {
40
- RCTRootView *rootView = [[HBDRootView alloc] initWithBridge:[HBDReactBridgeManager get].bridge moduleName:self.moduleName initialProperties:[self propsWithSceneId]];
40
+ RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:[HBDReactBridgeManager get].bridge moduleName:self.moduleName initialProperties:[self propsWithSceneId]];
41
41
  self.rootView = rootView;
42
42
 
43
43
  BOOL passThroughTouches = [self.options[@"passThroughTouches"] boolValue];
44
44
  rootView.passThroughTouches = passThroughTouches;
45
45
  rootView.backgroundColor = UIColor.clearColor;
46
46
  rootView.translatesAutoresizingMaskIntoConstraints = NO;
47
- self.view = [UIView new];
47
+ self.view = [[HBDRootView alloc] initWithRootView:rootView];
48
48
  [self.view addSubview:rootView];
49
49
  [self updateReactViewConstraints];
50
50
  }
@@ -5,12 +5,13 @@
5
5
  #import "HBDUtils.h"
6
6
  #import "HBDEventEmitter.h"
7
7
  #import "HBDReactTabBar.h"
8
- #import "HBDRootView.h"
9
8
  #import "HBDFadeAnimation.h"
10
9
 
10
+ #import <React/RCTRootView.h>
11
11
  #import <React/RCTRootViewDelegate.h>
12
12
  #import <React/RCTLog.h>
13
13
 
14
+
14
15
  @interface HBDTabBarController () <UITabBarControllerDelegate, RCTRootViewDelegate>
15
16
 
16
17
  @property(nonatomic, strong) RCTRootView *rootView;
@@ -58,7 +59,7 @@
58
59
  NSString *moduleName = self.tabBarOptions[@"tabBarModuleName"];
59
60
  NSMutableDictionary *props = [[self props] mutableCopy];
60
61
  props[@"selectedIndex"] = self.tabBarOptions[@"selectedIndex"];
61
- RCTRootView *rootView = [[HBDRootView alloc] initWithBridge:[HBDReactBridgeManager get].bridge moduleName:moduleName initialProperties:props];
62
+ RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:[HBDReactBridgeManager get].bridge moduleName:moduleName initialProperties:props];
62
63
  rootView.backgroundColor = UIColor.clearColor;
63
64
 
64
65
  BOOL sizeIndeterminate = [self.tabBarOptions[@"sizeIndeterminate"] boolValue];
@@ -2,6 +2,7 @@
2
2
 
3
3
  #import "HBDViewController+Garden.h"
4
4
  #import "HBDUtils.h"
5
+ #import "HBDAnimationObserver.h"
5
6
  #import "GlobalStyle.h"
6
7
 
7
8
  #import <React/RCTLog.h>
@@ -60,8 +61,10 @@
60
61
  UIView *statusBar = [[UIApplication sharedApplication] valueForKey:@"statusBarWindow"];
61
62
  BOOL hidden = [self hbd_statusBarHidden] && ![HBDUtils isInCall];
62
63
  CGFloat statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height;
63
- statusBar.transform = hidden ? CGAffineTransformTranslate(CGAffineTransformIdentity, 0, -statusBarHeight) : CGAffineTransformIdentity;
64
- statusBar.alpha = hidden ? 0 : 1.0;
64
+ [UIView animateWithDuration:0.2 animations:^{
65
+ statusBar.transform = hidden ? CGAffineTransformTranslate(CGAffineTransformIdentity, 0, -statusBarHeight) : CGAffineTransformIdentity;
66
+ statusBar.alpha = hidden ? 0 : 1.0;
67
+ }];
65
68
  return NO;
66
69
  }
67
70
  }
@@ -75,6 +78,7 @@
75
78
 
76
79
  - (void)viewDidAppear:(BOOL)animated {
77
80
  [super viewDidAppear:animated];
81
+ [[HBDAnimationObserver sharedObserver] endAnimation];
78
82
  if (![HBDUtils isIphoneX]) {
79
83
  [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarFrameWillChange:) name:UIApplicationWillChangeStatusBarFrameNotification object:nil];
80
84
  }
@@ -197,8 +201,12 @@
197
201
  }
198
202
 
199
203
  if ([GlobalStyle globalStyle].isBackTitleHidden) {
200
- UIBarButtonItem *buttonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:NULL];
201
- self.navigationItem.backBarButtonItem = buttonItem;
204
+ if (@available(iOS 14.0, *)) {
205
+ self.navigationItem.backButtonDisplayMode = UINavigationItemBackButtonDisplayModeMinimal;
206
+ } else {
207
+ UIBarButtonItem *buttonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:NULL];
208
+ self.navigationItem.backBarButtonItem = buttonItem;
209
+ }
202
210
  }
203
211
 
204
212
  NSDictionary *backItem = options[@"backItemIOS"];
@@ -211,7 +219,7 @@
211
219
  }
212
220
  self.navigationItem.backBarButtonItem = backButton;
213
221
  }
214
-
222
+
215
223
  NSNumber *swipeBackEnabled = options[@"swipeBackEnabled"];
216
224
  if (swipeBackEnabled) {
217
225
  self.hbd_swipeBackEnabled = [swipeBackEnabled boolValue];
@@ -9,9 +9,6 @@
9
9
  - (void)redirectToViewController:(UIViewController *)controller target:(UIViewController *)target animated:(BOOL)animated {
10
10
  NSMutableArray *children = [self.childViewControllers mutableCopy];
11
11
  NSUInteger index = [children indexOfObject:target];
12
- if (index == NSNotFound) {
13
- return;
14
- }
15
12
  NSUInteger count = self.childViewControllers.count;
16
13
  [children removeObjectsInRange:NSMakeRange(index, count - index)];
17
14
  [children addObject:controller];
package/lib/Event.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ declare function listenStatusBarHeightChanged(listener: (statusBarHeight: number) => void): import("react-native").EmitterSubscription;
2
+ declare function listenComponentResult(listener: (sceneId: string, requestCode: number, resultCode: number, resultData: object) => void): import("react-native").EmitterSubscription;
3
+ declare function listenComponentVisibility(componentDidAppear: (sceneId: string) => void, componentDidDisappear: (sceneId: string) => void): import("react-native").EmitterSubscription;
4
+ declare function listenSwitchTab(listener: (sceneId: string, from: number, to: number) => void): import("react-native").EmitterSubscription;
5
+ declare function listenSetRoot(willSetRoot: () => void, didSetRoot: (tag: number) => void): {
6
+ remove: () => void;
7
+ };
8
+ declare let barButtonClickHandlerFactory: () => (sceneId: string, value: Function) => void;
9
+ declare function setBarButtonClickHandlerFactory(generator: typeof barButtonClickHandlerFactory): void;
10
+ declare function bindBarButtonClickEvent(sceneId: string, item: object | null | undefined): object | null;
11
+ declare function removeBarButtonClickEvent(sceneId: string): void;
12
+ declare const _default: {
13
+ listenStatusBarHeightChanged: typeof listenStatusBarHeightChanged;
14
+ listenComponentResult: typeof listenComponentResult;
15
+ listenComponentVisibility: typeof listenComponentVisibility;
16
+ listenSwitchTab: typeof listenSwitchTab;
17
+ listenSetRoot: typeof listenSetRoot;
18
+ bindBarButtonClickEvent: typeof bindBarButtonClickEvent;
19
+ removeBarButtonClickEvent: typeof removeBarButtonClickEvent;
20
+ setBarButtonClickHandlerFactory: typeof setBarButtonClickHandlerFactory;
21
+ };
22
+ export default _default;