hybrid-navigation 2.13.0-beta.1 → 2.13.0-beta.2

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.
@@ -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
@@ -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,27 @@
177
178
  }
178
179
  }
179
180
 
181
+ static void (*__SWZ_didMoveToWindow_orig)(id self, SEL _cmd);
182
+
183
+ static void __HBD_didMoveToWindow(UIView *self, SEL _cmd) {
184
+ if (![[HBDAnimationObserver sharedObserver] isAnimating] || !self.window) {
185
+ __SWZ_didMoveToWindow_orig(self, _cmd);
186
+ } else {
187
+ [[HBDAnimationObserver sharedObserver] registerAnimationEndedBlock:^{
188
+ __SWZ_didMoveToWindow_orig(self, _cmd);
189
+ }];
190
+ }
191
+ }
192
+
193
+ + (void)load {
194
+ Class clazz = NSClassFromString(@"RCTBaseTextInputView");
195
+ if (clazz == NULL) {
196
+ return;
197
+ }
198
+ Method method = class_getInstanceMethod(clazz, NSSelectorFromString(@"didMoveToWindow"));
199
+ __SWZ_didMoveToWindow_orig = (void *)method_getImplementation(method);
200
+ method_setImplementation(method, (IMP)__HBD_didMoveToWindow);
201
+ }
202
+
203
+
180
204
  @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
 
@@ -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
  }
@@ -176,6 +178,7 @@
176
178
  return;
177
179
  }
178
180
 
181
+ [[HBDAnimationObserver sharedObserver] beginAnimation];
179
182
  [nav redirectToViewController:vc target:target animated:YES];
180
183
  [self animateAlongsideTransition:nav callback:callback];
181
184
  }
@@ -189,6 +192,7 @@
189
192
  }
190
193
 
191
194
  vc.hidesBottomBarWhenPushed = nav.hidesBottomBarWhenPushed;
195
+ [[HBDAnimationObserver sharedObserver] beginAnimation];
192
196
  [nav pushViewController:vc animated:YES];
193
197
  [self animateAlongsideTransition:nav callback:callback];
194
198
  }
@@ -60,7 +60,7 @@ RCT_EXPORT_MODULE(GardenModule)
60
60
  }
61
61
 
62
62
  - (void)handleStatusBarFrameChange {
63
- RCTLogInfo(@"handleStatusBarFrameChange: %f", [self currentStatusBarHeight]);
63
+ RCTLogInfo(@"[Navigator] handleStatusBarFrameChange: %f", [self currentStatusBarHeight]);
64
64
  if ([self.bridge isValid]) {
65
65
  [self sendEventWithName:EVENT_STATUSBAR_FRAME_CHANGE body:@{
66
66
  @"statusBarHeight": @([self currentStatusBarHeight])
@@ -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
 
@@ -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
  }
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.1",
4
+ "version": "2.13.0-beta.2",
5
5
  "main": "./lib/index.js",
6
6
  "typings": "./lib/index.d.ts",
7
7
  "react-native": "src/index",