hybrid-navigation 2.13.0-beta.1 → 2.13.0-beta.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.
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactFragment.java +3 -20
- package/ios/HybridNavigation/HBDAnimationObserver.h +24 -0
- package/ios/HybridNavigation/HBDAnimationObserver.m +45 -0
- package/ios/HybridNavigation/HBDUtils.h +3 -6
- package/ios/HybridNavigation/HBDUtils.m +34 -0
- package/ios/HybridNavigation/Navigator/HBDScreenNavigator.m +5 -0
- package/ios/HybridNavigation/Navigator/HBDStackNavigator.m +11 -2
- package/ios/HybridNavigation/ReactBridge/HBDGardenModule.m +1 -1
- package/ios/HybridNavigation/ReactBridge/HBDNavigationModule.m +3 -1
- package/ios/HybridNavigation/View/HBDRootView.m +9 -3
- package/ios/HybridNavigation/ViewController/HBDNavigationController.m +0 -30
- package/ios/HybridNavigation/ViewController/HBDViewController.m +13 -5
- package/ios/HybridNavigation/ViewController/UINavigationController+HBD.m +0 -3
- package/lib/Event.d.ts +18 -0
- package/lib/Event.js +71 -0
- package/lib/Garden.d.ts +46 -68
- package/lib/Garden.js +53 -70
- package/lib/GardenModule.d.ts +20 -0
- package/lib/GardenModule.js +3 -0
- package/lib/Navigation.d.ts +74 -0
- package/lib/Navigation.js +182 -0
- package/lib/NavigationComponentWrap.d.ts +19 -0
- package/lib/NavigationComponentWrap.js +46 -0
- package/lib/NavigationModule.d.ts +33 -22
- package/lib/NavigationModule.js +79 -22
- package/lib/Navigator.d.ts +55 -28
- package/lib/Navigator.js +122 -263
- package/lib/{typing.d.ts → Options.d.ts} +46 -50
- package/lib/{typing.js → Options.js} +0 -0
- package/lib/ReactRegistry.d.ts +16 -14
- package/lib/ReactRegistry.js +18 -93
- package/lib/Route.d.ts +74 -0
- package/lib/{router/typing.js → Route.js} +0 -0
- package/lib/handler/BarButtonEventHandler.d.ts +10 -0
- package/lib/handler/BarButtonEventHandler.js +38 -0
- package/lib/handler/DispatchCommandHandler.d.ts +24 -0
- package/lib/handler/DispatchCommandHandler.js +28 -0
- package/lib/handler/LayoutCommandHandler.d.ts +11 -0
- package/lib/handler/LayoutCommandHandler.js +39 -0
- package/lib/handler/ResultEventHandler.d.ts +15 -0
- package/lib/handler/ResultEventHandler.js +47 -0
- package/lib/handler/VisibilityEventHandler.d.ts +13 -0
- package/lib/handler/VisibilityEventHandler.js +32 -0
- package/lib/hooks.d.ts +0 -1
- package/lib/hooks.js +14 -29
- package/lib/index.d.ts +10 -2
- package/lib/index.js +17 -2
- package/lib/router/drawer.d.ts +1 -1
- package/lib/router/index.d.ts +4 -7
- package/lib/router/index.js +13 -6
- package/lib/router/screen.d.ts +1 -1
- package/lib/router/stack.d.ts +1 -1
- package/lib/router/tabs.d.ts +1 -1
- package/lib/store.d.ts +0 -9
- package/lib/store.js +0 -22
- package/package.json +1 -1
- package/src/Event.ts +123 -0
- package/src/Garden.ts +63 -149
- package/src/GardenModule.ts +24 -0
- package/src/Navigation.ts +278 -0
- package/src/NavigationComponentWrap.tsx +73 -0
- package/src/NavigationModule.ts +118 -29
- package/src/Navigator.ts +147 -319
- package/src/{typing.ts → Options.ts} +51 -57
- package/src/ReactRegistry.tsx +25 -127
- package/src/Route.ts +88 -0
- package/src/handler/BarButtonEventHandler.ts +50 -0
- package/src/handler/DispatchCommandHandler.ts +56 -0
- package/src/handler/LayoutCommandHandler.ts +49 -0
- package/src/handler/ResultEventHandler.ts +67 -0
- package/src/handler/VisibilityEventHandler.ts +44 -0
- package/src/hooks.ts +13 -38
- package/src/index.ts +38 -3
- package/src/router/drawer.ts +1 -1
- package/src/router/index.ts +36 -12
- package/src/router/screen.ts +1 -1
- package/src/router/stack.ts +1 -1
- package/src/router/tabs.ts +1 -1
- package/src/store.ts +0 -28
- package/lib/router/typing.d.ts +0 -37
- package/lib/utils.d.ts +0 -9
- package/lib/utils.js +0 -50
- package/src/router/typing.ts +0 -45
- package/src/utils.ts +0 -83
|
@@ -28,7 +28,6 @@ import com.facebook.react.bridge.ReactContext;
|
|
|
28
28
|
import com.facebook.react.common.LifecycleState;
|
|
29
29
|
import com.navigation.androidx.FragmentHelper;
|
|
30
30
|
import com.navigation.androidx.Style;
|
|
31
|
-
import com.navigation.androidx.TransitionAnimation;
|
|
32
31
|
|
|
33
32
|
public class ReactFragment extends HybridFragment implements ReactRootViewHolder.VisibilityObserver, ReactBridgeManager.ReactBridgeReloadListener {
|
|
34
33
|
|
|
@@ -49,11 +48,8 @@ public class ReactFragment extends HybridFragment implements ReactRootViewHolder
|
|
|
49
48
|
reactRootViewHolder = (ReactRootViewHolder) containerLayout;
|
|
50
49
|
reactRootViewHolder.setVisibilityObserver(this);
|
|
51
50
|
}
|
|
52
|
-
|
|
51
|
+
|
|
53
52
|
if (!FragmentHelper.isHidden(this) || getShowsDialog()) {
|
|
54
|
-
if (getAnimation() != TransitionAnimation.None) {
|
|
55
|
-
postponeEnterTransition();
|
|
56
|
-
}
|
|
57
53
|
initReactRootView();
|
|
58
54
|
}
|
|
59
55
|
|
|
@@ -201,8 +197,7 @@ public class ReactFragment extends HybridFragment implements ReactRootViewHolder
|
|
|
201
197
|
return;
|
|
202
198
|
}
|
|
203
199
|
firstRenderCompleted = true;
|
|
204
|
-
|
|
205
|
-
|
|
200
|
+
|
|
206
201
|
if (isViewReady() && isResumed()) {
|
|
207
202
|
sendViewAppearEvent(true);
|
|
208
203
|
reactRootView.addOnGlobalLayoutListener();
|
|
@@ -301,17 +296,5 @@ public class ReactFragment extends HybridFragment implements ReactRootViewHolder
|
|
|
301
296
|
}
|
|
302
297
|
return new Toolbar.LayoutParams(WRAP_CONTENT, WRAP_CONTENT, Gravity.CENTER);
|
|
303
298
|
}
|
|
304
|
-
|
|
305
|
-
@Override
|
|
306
|
-
public void postponeEnterTransition() {
|
|
307
|
-
super.postponeEnterTransition();
|
|
308
|
-
requireActivity().supportPostponeEnterTransition();
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
@Override
|
|
312
|
-
public void startPostponedEnterTransition() {
|
|
313
|
-
super.startPostponedEnterTransition();
|
|
314
|
-
requireActivity().supportStartPostponedEnterTransition();
|
|
315
|
-
}
|
|
316
|
-
|
|
299
|
+
|
|
317
300
|
}
|
|
@@ -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
|
-
|
|
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
|
|
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
|
|
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
|
}
|
|
@@ -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
|
|
|
@@ -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 *)
|
|
64
|
+
[(HBDReactViewController *)vc signalFirstRenderComplete];
|
|
63
65
|
}
|
|
64
66
|
}
|
|
65
67
|
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
@implementation HBDRootView
|
|
10
10
|
|
|
11
11
|
- (instancetype)initWithRootView:(RCTRootView *)rootView {
|
|
12
|
-
if (self = [super
|
|
12
|
+
if (self = [super initWithFrame:[UIScreen mainScreen].bounds]) {
|
|
13
13
|
_rootView = rootView;
|
|
14
14
|
}
|
|
15
15
|
return self;
|
|
@@ -17,8 +17,14 @@
|
|
|
17
17
|
|
|
18
18
|
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
|
|
19
19
|
UIView *hitView = [super hitTest:point withEvent:event];
|
|
20
|
-
if (self.rootView.passThroughTouches
|
|
21
|
-
|
|
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;
|
|
27
|
+
}
|
|
22
28
|
}
|
|
23
29
|
return hitView;
|
|
24
30
|
}
|
|
@@ -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;
|
|
@@ -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
|
-
|
|
64
|
-
|
|
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
|
-
|
|
201
|
-
|
|
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,18 @@
|
|
|
1
|
+
import type { Visibility } from './Route';
|
|
2
|
+
declare function listenStatusBarHeightChange(listener: (statusBarHeight: number) => void): import("react-native").EmitterSubscription;
|
|
3
|
+
declare function listenComponentResult(listener: (sceneId: string, requestCode: number, resultCode: number, resultData: object) => void): import("react-native").EmitterSubscription;
|
|
4
|
+
declare function listenComponentVisibility(listener: (sceneId: string, visibility: Visibility) => void): import("react-native").EmitterSubscription;
|
|
5
|
+
declare function listenBarButtonItemClick(listener: (sceneId: string, action: string) => void): import("react-native").EmitterSubscription;
|
|
6
|
+
declare function listenTabSwitch(listener: (sceneId: string, from: number, to: number) => void): import("react-native").EmitterSubscription;
|
|
7
|
+
declare function listenWillSetRoot(willSetRoot: () => void): import("react-native").EmitterSubscription;
|
|
8
|
+
declare function listenDidSetRoot(didSetRoot: (tag: number) => void): import("react-native").EmitterSubscription;
|
|
9
|
+
declare const _default: {
|
|
10
|
+
listenStatusBarHeightChange: typeof listenStatusBarHeightChange;
|
|
11
|
+
listenBarButtonItemClick: typeof listenBarButtonItemClick;
|
|
12
|
+
listenComponentResult: typeof listenComponentResult;
|
|
13
|
+
listenComponentVisibility: typeof listenComponentVisibility;
|
|
14
|
+
listenTabSwitch: typeof listenTabSwitch;
|
|
15
|
+
listenWillSetRoot: typeof listenWillSetRoot;
|
|
16
|
+
listenDidSetRoot: typeof listenDidSetRoot;
|
|
17
|
+
};
|
|
18
|
+
export default _default;
|
package/lib/Event.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { NativeModules, NativeEventEmitter } from 'react-native';
|
|
2
|
+
import GardenModule from './GardenModule';
|
|
3
|
+
function listenStatusBarHeightChange(listener) {
|
|
4
|
+
const GardenEventReceiver = new NativeEventEmitter(GardenModule);
|
|
5
|
+
const { EVENT_STATUSBAR_FRAME_CHANGE } = GardenModule.getConstants();
|
|
6
|
+
return GardenEventReceiver.addListener(EVENT_STATUSBAR_FRAME_CHANGE, ({ statusBarHeight }) => {
|
|
7
|
+
listener(statusBarHeight);
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
const HBDEventEmitter = NativeModules.HBDEventEmitter;
|
|
11
|
+
const HBDEventReceiver = new NativeEventEmitter(HBDEventEmitter);
|
|
12
|
+
function listenComponentResult(listener) {
|
|
13
|
+
const { EVENT_NAVIGATION, KEY_ON, ON_COMPONENT_RESULT, KEY_REQUEST_CODE, KEY_RESULT_CODE, KEY_RESULT_DATA, KEY_SCENE_ID, } = HBDEventEmitter.getConstants();
|
|
14
|
+
return HBDEventReceiver.addListener(EVENT_NAVIGATION, data => {
|
|
15
|
+
if (data[KEY_ON] === ON_COMPONENT_RESULT) {
|
|
16
|
+
const requestCode = data[KEY_REQUEST_CODE];
|
|
17
|
+
const resultCode = data[KEY_RESULT_CODE];
|
|
18
|
+
const resultData = data[KEY_RESULT_DATA];
|
|
19
|
+
const sceneId = data[KEY_SCENE_ID];
|
|
20
|
+
listener(sceneId, requestCode, resultCode, resultData);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function listenComponentVisibility(listener) {
|
|
25
|
+
const { EVENT_NAVIGATION, KEY_ON, ON_COMPONENT_APPEAR, ON_COMPONENT_DISAPPEAR, KEY_SCENE_ID } = HBDEventEmitter.getConstants();
|
|
26
|
+
return HBDEventReceiver.addListener(EVENT_NAVIGATION, data => {
|
|
27
|
+
if (data[KEY_ON] === ON_COMPONENT_APPEAR) {
|
|
28
|
+
listener(data[KEY_SCENE_ID], 'visible');
|
|
29
|
+
}
|
|
30
|
+
if (data[KEY_ON] === ON_COMPONENT_DISAPPEAR) {
|
|
31
|
+
listener(data[KEY_SCENE_ID], 'invisible');
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function listenBarButtonItemClick(listener) {
|
|
36
|
+
const { EVENT_NAVIGATION, KEY_ON, ON_BAR_BUTTON_ITEM_CLICK, KEY_ACTION, KEY_SCENE_ID } = HBDEventEmitter.getConstants();
|
|
37
|
+
return HBDEventReceiver.addListener(EVENT_NAVIGATION, data => {
|
|
38
|
+
if (data[KEY_ON] === ON_BAR_BUTTON_ITEM_CLICK) {
|
|
39
|
+
listener(data[KEY_SCENE_ID], data[KEY_ACTION]);
|
|
40
|
+
}
|
|
41
|
+
}, {});
|
|
42
|
+
}
|
|
43
|
+
function listenTabSwitch(listener) {
|
|
44
|
+
const { EVENT_SWITCH_TAB, KEY_INDEX, KEY_SCENE_ID } = HBDEventEmitter.getConstants();
|
|
45
|
+
return HBDEventReceiver.addListener(EVENT_SWITCH_TAB, event => {
|
|
46
|
+
const index = event[KEY_INDEX];
|
|
47
|
+
const [from, to] = index.split('-');
|
|
48
|
+
listener(event[KEY_SCENE_ID], parseInt(from, 10), parseInt(to, 10));
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function listenWillSetRoot(willSetRoot) {
|
|
52
|
+
const { EVENT_WILL_SET_ROOT } = HBDEventEmitter.getConstants();
|
|
53
|
+
return HBDEventReceiver.addListener(EVENT_WILL_SET_ROOT, _ => {
|
|
54
|
+
willSetRoot();
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function listenDidSetRoot(didSetRoot) {
|
|
58
|
+
const { EVENT_DID_SET_ROOT } = HBDEventEmitter.getConstants();
|
|
59
|
+
return HBDEventReceiver.addListener(EVENT_DID_SET_ROOT, (event) => {
|
|
60
|
+
didSetRoot(event.tag);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
export default {
|
|
64
|
+
listenStatusBarHeightChange,
|
|
65
|
+
listenBarButtonItemClick,
|
|
66
|
+
listenComponentResult,
|
|
67
|
+
listenComponentVisibility,
|
|
68
|
+
listenTabSwitch,
|
|
69
|
+
listenWillSetRoot,
|
|
70
|
+
listenDidSetRoot,
|
|
71
|
+
};
|
package/lib/Garden.d.ts
CHANGED
|
@@ -1,84 +1,62 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface ShadowImage {
|
|
3
|
-
image?: ImageSource;
|
|
4
|
-
color?: Color;
|
|
5
|
-
}
|
|
6
|
-
export interface Style {
|
|
7
|
-
screenBackgroundColor?: Color;
|
|
8
|
-
topBarStyle?: BarStyle;
|
|
9
|
-
topBarColor?: Color;
|
|
10
|
-
topBarColorDarkContent?: Color;
|
|
11
|
-
topBarColorLightContent?: Color;
|
|
12
|
-
statusBarColorAndroid?: Color;
|
|
13
|
-
navigationBarColorAndroid?: Color;
|
|
14
|
-
hideBackTitleIOS?: boolean;
|
|
15
|
-
elevationAndroid?: number;
|
|
16
|
-
shadowImage?: ShadowImage;
|
|
17
|
-
backIcon?: ImageSource;
|
|
18
|
-
topBarTintColor?: Color;
|
|
19
|
-
topBarTintColorDarkContent?: Color;
|
|
20
|
-
topBarTintColorLightContent?: Color;
|
|
21
|
-
titleTextColor?: Color;
|
|
22
|
-
titleTextColorDarkContent?: Color;
|
|
23
|
-
titleTextColorLightContent?: Color;
|
|
24
|
-
titleTextSize?: number;
|
|
25
|
-
titleAlignmentAndroid?: TitleAlignment;
|
|
26
|
-
barButtonItemTextSize?: number;
|
|
27
|
-
swipeBackEnabledAndroid?: boolean;
|
|
28
|
-
splitTopBarTransitionIOS?: boolean;
|
|
29
|
-
scrimAlphaAndroid?: number;
|
|
30
|
-
displayCutoutWhenLandscapeAndroid?: boolean;
|
|
31
|
-
tabBarColor?: Color;
|
|
32
|
-
tabBarShadowImage?: ShadowImage;
|
|
33
|
-
tabBarItemColor?: Color;
|
|
34
|
-
tabBarUnselectedItemColor?: Color;
|
|
35
|
-
tabBarBadgeColor?: Color;
|
|
36
|
-
}
|
|
37
|
-
export declare type TabBarStyle = Pick<Style, 'tabBarColor' | 'tabBarShadowImage' | 'tabBarItemColor' | 'tabBarUnselectedItemColor'>;
|
|
38
|
-
export interface TabBadge {
|
|
39
|
-
index: number;
|
|
40
|
-
text?: string;
|
|
41
|
-
hidden: boolean;
|
|
42
|
-
dot?: boolean;
|
|
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
|
-
}
|
|
57
|
-
export interface TabIcon {
|
|
58
|
-
index: number;
|
|
59
|
-
icon: ImageSource;
|
|
60
|
-
unselectedIcon?: ImageSource;
|
|
61
|
-
}
|
|
1
|
+
import type { BarButtonItem, DefaultOptions, NavigationOption, TabBarStyle, TabItemInfo, TitleItem } from './Options';
|
|
62
2
|
declare type Nullable<T> = {
|
|
63
3
|
[P in keyof T]: T[P] extends T[P] | undefined ? T[P] | null : T[P];
|
|
64
4
|
};
|
|
65
|
-
export
|
|
5
|
+
export interface Garden {
|
|
6
|
+
}
|
|
7
|
+
export declare class Garden implements Garden {
|
|
66
8
|
sceneId: string;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Use Navigation.setDefaultOptions() instead.
|
|
11
|
+
* @param style
|
|
12
|
+
*/
|
|
13
|
+
static setStyle(style: DefaultOptions): void;
|
|
71
14
|
constructor(sceneId: string);
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated Use Navigation.setLeftBarButtonItem() instead.
|
|
17
|
+
* @param buttonItem
|
|
18
|
+
*/
|
|
72
19
|
setLeftBarButtonItem(buttonItem: Nullable<BarButtonItem> | null): void;
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated Use Navigation.setRightBarButtonItem() instead.
|
|
22
|
+
* @param buttonItem
|
|
23
|
+
*/
|
|
73
24
|
setRightBarButtonItem(buttonItem: Nullable<BarButtonItem> | null): void;
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @deprecated Use Navigation.setLeftBarButtonItems() instead.
|
|
28
|
+
* @param buttonItems
|
|
29
|
+
*/
|
|
74
30
|
setLeftBarButtonItems(buttonItems: Array<Nullable<BarButtonItem>> | null): void;
|
|
31
|
+
/**
|
|
32
|
+
* @deprecated Use Navigation.setRightBarButtonItems() instead.
|
|
33
|
+
* @param buttonItems
|
|
34
|
+
*/
|
|
75
35
|
setRightBarButtonItems(buttonItems: Array<Nullable<BarButtonItem>> | null): void;
|
|
36
|
+
/**
|
|
37
|
+
* @deprecated Use Navigation.setTitleItem() instead.
|
|
38
|
+
* @param titleItem
|
|
39
|
+
*/
|
|
76
40
|
setTitleItem(titleItem: TitleItem): void;
|
|
41
|
+
/**
|
|
42
|
+
* @deprecated Use Navigation.updateOptions() instead.
|
|
43
|
+
* @param options
|
|
44
|
+
*/
|
|
77
45
|
updateOptions(options: NavigationOption): void;
|
|
46
|
+
/**
|
|
47
|
+
* @deprecated Use Navigation.updateTabBar() instead.
|
|
48
|
+
* @param options
|
|
49
|
+
*/
|
|
78
50
|
updateTabBar(options: TabBarStyle): void;
|
|
51
|
+
/**
|
|
52
|
+
* @deprecated Use Navigation.setTabItem() instead.
|
|
53
|
+
* @param item
|
|
54
|
+
*/
|
|
79
55
|
setTabItem(item: TabItemInfo | TabItemInfo[]): void;
|
|
80
|
-
|
|
81
|
-
|
|
56
|
+
/**
|
|
57
|
+
* @deprecated Use Navigation.setMenuInteractive() instead.
|
|
58
|
+
* @param enabled
|
|
59
|
+
*/
|
|
82
60
|
setMenuInteractive(enabled: boolean): void;
|
|
83
61
|
}
|
|
84
62
|
export {};
|