hybrid-navigation 2.18.3 → 2.18.5
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/LICENSE +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/HBDReactRootView.java +4 -54
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactFragment.java +0 -3
- package/{lib → dist}/Navigation.js +3 -2
- package/{lib → dist}/NavigationComponentWrap.js +6 -5
- package/{lib → dist}/Navigator.d.ts +0 -1
- package/{lib → dist}/Navigator.js +15 -4
- package/{lib → dist}/hooks.js +2 -1
- package/{lib → dist}/router/index.js +6 -2
- package/{lib → dist}/router/stack.js +1 -1
- package/ios/HybridNavigation/HBDUtils.h +2 -0
- package/ios/HybridNavigation/HBDUtils.m +12 -3
- package/ios/HybridNavigation/ReactBridge/HBDGardenModule.m +2 -6
- package/ios/HybridNavigation/ReactBridge/HBDNavigationModule.m +11 -12
- package/ios/HybridNavigation/ViewController/HBDDrawerController.m +1 -1
- package/ios/HybridNavigation/ViewController/HBDNavigationController.m +1 -1
- package/ios/HybridNavigation/ViewController/HBDViewController.m +1 -1
- package/package.json +47 -78
- package/src/DeepLink.ts +52 -52
- package/src/Event.ts +88 -83
- package/src/GardenModule.ts +30 -30
- package/src/Navigation.ts +293 -281
- package/src/NavigationComponentWrap.tsx +52 -47
- package/src/NavigationModule.ts +77 -77
- package/src/Navigator.ts +212 -201
- package/src/Options.ts +120 -112
- package/src/Route.ts +59 -59
- package/src/handler/BarButtonEventHandler.ts +50 -46
- package/src/handler/DispatchCommandHandler.ts +56 -52
- package/src/handler/LayoutCommandHandler.ts +21 -21
- package/src/handler/ResultEventHandler.ts +63 -49
- package/src/handler/VisibilityEventHandler.ts +57 -40
- package/src/hooks.ts +23 -21
- package/src/index.ts +15 -15
- package/src/router/drawer.ts +24 -24
- package/src/router/index.ts +206 -198
- package/src/router/screen.ts +28 -28
- package/src/router/stack.ts +76 -76
- package/src/router/tabs.ts +28 -28
- package/src/store.ts +9 -9
- package/README.md +0 -79
- /package/{lib → dist}/DeepLink.d.ts +0 -0
- /package/{lib → dist}/DeepLink.js +0 -0
- /package/{lib → dist}/Event.d.ts +0 -0
- /package/{lib → dist}/Event.js +0 -0
- /package/{lib → dist}/GardenModule.d.ts +0 -0
- /package/{lib → dist}/GardenModule.js +0 -0
- /package/{lib → dist}/Navigation.d.ts +0 -0
- /package/{lib → dist}/NavigationComponentWrap.d.ts +0 -0
- /package/{lib → dist}/NavigationModule.d.ts +0 -0
- /package/{lib → dist}/NavigationModule.js +0 -0
- /package/{lib → dist}/Options.d.ts +0 -0
- /package/{lib → dist}/Options.js +0 -0
- /package/{lib → dist}/Route.d.ts +0 -0
- /package/{lib → dist}/Route.js +0 -0
- /package/{lib → dist}/handler/BarButtonEventHandler.d.ts +0 -0
- /package/{lib → dist}/handler/BarButtonEventHandler.js +0 -0
- /package/{lib → dist}/handler/DispatchCommandHandler.d.ts +0 -0
- /package/{lib → dist}/handler/DispatchCommandHandler.js +0 -0
- /package/{lib → dist}/handler/LayoutCommandHandler.d.ts +0 -0
- /package/{lib → dist}/handler/LayoutCommandHandler.js +0 -0
- /package/{lib → dist}/handler/ResultEventHandler.d.ts +0 -0
- /package/{lib → dist}/handler/ResultEventHandler.js +0 -0
- /package/{lib → dist}/handler/VisibilityEventHandler.d.ts +0 -0
- /package/{lib → dist}/handler/VisibilityEventHandler.js +0 -0
- /package/{lib → dist}/hooks.d.ts +0 -0
- /package/{lib → dist}/index.d.ts +0 -0
- /package/{lib → dist}/index.js +0 -0
- /package/{lib → dist}/router/drawer.d.ts +0 -0
- /package/{lib → dist}/router/drawer.js +0 -0
- /package/{lib → dist}/router/index.d.ts +0 -0
- /package/{lib → dist}/router/screen.d.ts +0 -0
- /package/{lib → dist}/router/screen.js +0 -0
- /package/{lib → dist}/router/stack.d.ts +0 -0
- /package/{lib → dist}/router/tabs.d.ts +0 -0
- /package/{lib → dist}/router/tabs.js +0 -0
- /package/{lib → dist}/store.d.ts +0 -0
- /package/{lib → dist}/store.js +0 -0
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2025 listen <listenzz@163.com>
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
package com.reactnative.hybridnavigation;
|
|
2
2
|
|
|
3
|
+
import android.annotation.SuppressLint;
|
|
3
4
|
import android.content.Context;
|
|
4
5
|
import android.os.Bundle;
|
|
5
6
|
import android.util.AttributeSet;
|
|
6
7
|
import android.view.MotionEvent;
|
|
7
|
-
import android.view.ViewTreeObserver;
|
|
8
8
|
|
|
9
9
|
import androidx.annotation.Nullable;
|
|
10
10
|
|
|
11
|
-
import com.facebook.react.ReactInstanceManager;
|
|
12
11
|
import com.facebook.react.ReactRootView;
|
|
13
12
|
|
|
14
|
-
import java.lang.reflect.Method;
|
|
15
|
-
|
|
16
13
|
public class HBDReactRootView extends ReactRootView {
|
|
17
14
|
|
|
18
15
|
protected static final String TAG = "Navigation";
|
|
@@ -35,7 +32,8 @@ public class HBDReactRootView extends ReactRootView {
|
|
|
35
32
|
this.shouldConsumeTouchEvent = consume;
|
|
36
33
|
}
|
|
37
34
|
|
|
38
|
-
@
|
|
35
|
+
@SuppressLint("ClickableViewAccessibility")
|
|
36
|
+
@Override
|
|
39
37
|
public boolean onTouchEvent(MotionEvent ev) {
|
|
40
38
|
int action = ev.getAction() & MotionEvent.ACTION_MASK;
|
|
41
39
|
if (action == MotionEvent.ACTION_DOWN) {
|
|
@@ -44,24 +42,6 @@ public class HBDReactRootView extends ReactRootView {
|
|
|
44
42
|
return shouldConsumeTouchEvent;
|
|
45
43
|
}
|
|
46
44
|
|
|
47
|
-
@Override
|
|
48
|
-
protected void onAttachedToWindow() {
|
|
49
|
-
super.onAttachedToWindow();
|
|
50
|
-
removeOnGlobalLayoutListener();
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
@Override
|
|
54
|
-
protected void onDetachedFromWindow() {
|
|
55
|
-
super.onDetachedFromWindow();
|
|
56
|
-
removeOnGlobalLayoutListener();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
@Override
|
|
60
|
-
public void startReactApplication(ReactInstanceManager reactInstanceManager, String moduleName, @Nullable Bundle initialProperties) {
|
|
61
|
-
super.startReactApplication(reactInstanceManager, moduleName, initialProperties);
|
|
62
|
-
removeOnGlobalLayoutListener();
|
|
63
|
-
}
|
|
64
|
-
|
|
65
45
|
// 避免 reload 时,重复 run 的问题
|
|
66
46
|
private boolean shouldRunApplication = true;
|
|
67
47
|
|
|
@@ -72,7 +52,7 @@ public class HBDReactRootView extends ReactRootView {
|
|
|
72
52
|
super.runApplication();
|
|
73
53
|
}
|
|
74
54
|
}
|
|
75
|
-
|
|
55
|
+
|
|
76
56
|
private boolean hbd_isAttachedToReactInstance;
|
|
77
57
|
|
|
78
58
|
@Override
|
|
@@ -88,34 +68,4 @@ public class HBDReactRootView extends ReactRootView {
|
|
|
88
68
|
super.setAppProperties(appProperties);
|
|
89
69
|
}
|
|
90
70
|
}
|
|
91
|
-
|
|
92
|
-
@Override
|
|
93
|
-
public void unmountReactApplication() {
|
|
94
|
-
super.unmountReactApplication();
|
|
95
|
-
removeOnGlobalLayoutListener();
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
private ViewTreeObserver.OnGlobalLayoutListener mGlobalLayoutListener;
|
|
99
|
-
|
|
100
|
-
private ViewTreeObserver.OnGlobalLayoutListener getGlobalLayoutListener() {
|
|
101
|
-
if (mGlobalLayoutListener == null) {
|
|
102
|
-
try {
|
|
103
|
-
Method method = ReactRootView.class.getDeclaredMethod("getCustomGlobalLayoutListener");
|
|
104
|
-
method.setAccessible(true);
|
|
105
|
-
mGlobalLayoutListener = (ViewTreeObserver.OnGlobalLayoutListener) method.invoke(this);
|
|
106
|
-
} catch (Exception e) {
|
|
107
|
-
e.printStackTrace();
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
return mGlobalLayoutListener;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
void addOnGlobalLayoutListener() {
|
|
114
|
-
removeOnGlobalLayoutListener();
|
|
115
|
-
getViewTreeObserver().addOnGlobalLayoutListener(getGlobalLayoutListener());
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
void removeOnGlobalLayoutListener() {
|
|
119
|
-
getViewTreeObserver().removeOnGlobalLayoutListener(getGlobalLayoutListener());
|
|
120
|
-
}
|
|
121
71
|
}
|
|
@@ -84,7 +84,6 @@ public class ReactFragment extends HybridFragment implements ReactBridgeManager.
|
|
|
84
84
|
public void onResume() {
|
|
85
85
|
super.onResume();
|
|
86
86
|
if (isViewReady()) {
|
|
87
|
-
reactRootView.addOnGlobalLayoutListener();
|
|
88
87
|
sendViewAppearEvent(true);
|
|
89
88
|
}
|
|
90
89
|
}
|
|
@@ -94,7 +93,6 @@ public class ReactFragment extends HybridFragment implements ReactBridgeManager.
|
|
|
94
93
|
super.onPause();
|
|
95
94
|
if (isViewReady()) {
|
|
96
95
|
sendViewAppearEvent(false);
|
|
97
|
-
reactRootView.removeOnGlobalLayoutListener();
|
|
98
96
|
}
|
|
99
97
|
}
|
|
100
98
|
|
|
@@ -206,7 +204,6 @@ public class ReactFragment extends HybridFragment implements ReactBridgeManager.
|
|
|
206
204
|
|
|
207
205
|
if (isViewReady() && isResumed()) {
|
|
208
206
|
sendViewAppearEvent(true);
|
|
209
|
-
reactRootView.addOnGlobalLayoutListener();
|
|
210
207
|
}
|
|
211
208
|
}
|
|
212
209
|
|
|
@@ -30,7 +30,7 @@ class NavigationImpl {
|
|
|
30
30
|
}
|
|
31
31
|
endRegisterComponent() {
|
|
32
32
|
if (this.registerEnded) {
|
|
33
|
-
console.warn(
|
|
33
|
+
console.warn("Please don't call ReactRegistry#endRegisterComponent multiple times.");
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
36
|
this.registerEnded = true;
|
|
@@ -45,7 +45,8 @@ class NavigationImpl {
|
|
|
45
45
|
WrappedComponent = this.hoc(WrappedComponent);
|
|
46
46
|
}
|
|
47
47
|
// build static options
|
|
48
|
-
let options = this.bindBarButtonClickEvent('permanent', WrappedComponent.navigationItem) ||
|
|
48
|
+
let options = this.bindBarButtonClickEvent('permanent', WrappedComponent.navigationItem) ||
|
|
49
|
+
{};
|
|
49
50
|
NavigationModule.registerReactComponent(appKey, options);
|
|
50
51
|
let RootComponent = this.wrap(appKey)(WrappedComponent);
|
|
51
52
|
AppRegistry.registerComponent(appKey, () => RootComponent);
|
|
@@ -22,8 +22,8 @@ export function withNavigation(moduleName) {
|
|
|
22
22
|
navigator,
|
|
23
23
|
};
|
|
24
24
|
return (<NavigationContext.Provider value={navigator}>
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
<WrappedComponent ref={ref} {...props} {...injected}/>
|
|
26
|
+
</NavigationContext.Provider>);
|
|
27
27
|
});
|
|
28
28
|
FC.displayName = `withNavigation(${getDisplayName(WrappedComponent)})`;
|
|
29
29
|
return FC;
|
|
@@ -33,11 +33,12 @@ export function withNavigationItem(item) {
|
|
|
33
33
|
return function (WrappedComponent) {
|
|
34
34
|
let navigationItem = WrappedComponent.navigationItem;
|
|
35
35
|
if (navigationItem) {
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
WrappedComponent.navigationItem = {
|
|
37
|
+
...navigationItem,
|
|
38
|
+
...item,
|
|
39
|
+
};
|
|
38
40
|
}
|
|
39
41
|
else {
|
|
40
|
-
;
|
|
41
42
|
WrappedComponent.navigationItem = item;
|
|
42
43
|
}
|
|
43
44
|
return WrappedComponent;
|
|
@@ -13,7 +13,7 @@ Navigation.setBarButtonClickEventListener((sceneId, value) => {
|
|
|
13
13
|
const navigator = Navigator.of(sceneId);
|
|
14
14
|
value(navigator);
|
|
15
15
|
});
|
|
16
|
-
|
|
16
|
+
class Navigator {
|
|
17
17
|
sceneId;
|
|
18
18
|
moduleName;
|
|
19
19
|
static of(sceneId) {
|
|
@@ -73,7 +73,11 @@ export class Navigator {
|
|
|
73
73
|
return Navigation.result(this.sceneId, 0);
|
|
74
74
|
};
|
|
75
75
|
pop = () => Navigation.dispatch(this.sceneId, 'pop', { from: this.moduleName });
|
|
76
|
-
popTo = (moduleName, inclusive = false) => Navigation.dispatch(this.sceneId, 'popTo', {
|
|
76
|
+
popTo = (moduleName, inclusive = false) => Navigation.dispatch(this.sceneId, 'popTo', {
|
|
77
|
+
moduleName,
|
|
78
|
+
inclusive,
|
|
79
|
+
from: this.moduleName,
|
|
80
|
+
});
|
|
77
81
|
popToRoot = () => Navigation.dispatch(this.sceneId, 'popToRoot', { from: this.moduleName });
|
|
78
82
|
redirectTo = (moduleName, props = {}, options = {}) => Navigation.dispatch(this.sceneId, 'redirectTo', {
|
|
79
83
|
moduleName,
|
|
@@ -145,10 +149,17 @@ export class Navigator {
|
|
|
145
149
|
setResult = (resultCode, data = null) => Navigation.setResult(this.sceneId, resultCode, data);
|
|
146
150
|
switchTab = async (index, popToRoot = false) => {
|
|
147
151
|
const from = await Navigation.currentTab(this.sceneId);
|
|
148
|
-
return Navigation.dispatch(this.sceneId, 'switchTab', {
|
|
152
|
+
return Navigation.dispatch(this.sceneId, 'switchTab', {
|
|
153
|
+
from,
|
|
154
|
+
to: index,
|
|
155
|
+
popToRoot,
|
|
156
|
+
});
|
|
149
157
|
};
|
|
150
|
-
toggleMenu = () => Navigation.dispatch(this.sceneId, 'toggleMenu', {
|
|
158
|
+
toggleMenu = () => Navigation.dispatch(this.sceneId, 'toggleMenu', {
|
|
159
|
+
from: this.moduleName,
|
|
160
|
+
});
|
|
151
161
|
openMenu = () => Navigation.dispatch(this.sceneId, 'openMenu', { from: this.moduleName });
|
|
152
162
|
closeMenu = () => Navigation.dispatch(this.sceneId, 'closeMenu', { from: this.moduleName });
|
|
153
163
|
isStackRoot = () => Navigation.isStackRoot(this.sceneId);
|
|
154
164
|
}
|
|
165
|
+
export { Navigator };
|
package/{lib → dist}/hooks.js
RENAMED
|
@@ -22,8 +22,9 @@ export function useVisible() {
|
|
|
22
22
|
export function useVisibleEffect(effect) {
|
|
23
23
|
const visible = useVisible();
|
|
24
24
|
useEffect(() => {
|
|
25
|
-
if (!visible)
|
|
25
|
+
if (!visible) {
|
|
26
26
|
return;
|
|
27
|
+
}
|
|
27
28
|
const destructor = effect();
|
|
28
29
|
return () => destructor && destructor();
|
|
29
30
|
}, [effect, visible]);
|
|
@@ -134,10 +134,14 @@ class Router {
|
|
|
134
134
|
const { mode: layoutMode } = graphArray[index];
|
|
135
135
|
const { sceneId, moduleName } = await Navigation.currentRoute();
|
|
136
136
|
if (layoutMode === 'present') {
|
|
137
|
-
await Navigation.dispatch(sceneId, 'dismiss', {
|
|
137
|
+
await Navigation.dispatch(sceneId, 'dismiss', {
|
|
138
|
+
from: moduleName,
|
|
139
|
+
});
|
|
138
140
|
}
|
|
139
141
|
else if (layoutMode === 'modal') {
|
|
140
|
-
await Navigation.dispatch(sceneId, 'hideModal', {
|
|
142
|
+
await Navigation.dispatch(sceneId, 'hideModal', {
|
|
143
|
+
from: moduleName,
|
|
144
|
+
});
|
|
141
145
|
}
|
|
142
146
|
else {
|
|
143
147
|
console.warn('尚未处理的 layout mode:' + layoutMode);
|
|
@@ -30,7 +30,7 @@ export class StackRouteHandler {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
navigateTo(childGraph, target) {
|
|
33
|
-
const {
|
|
33
|
+
const { moduleName, dependencies, props } = target;
|
|
34
34
|
const expectations = [...dependencies, moduleName];
|
|
35
35
|
const index = expectations.findIndex(name => name === childGraph.moduleName);
|
|
36
36
|
const pendings = expectations.slice(index + 1);
|
|
@@ -166,18 +166,27 @@
|
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
+ (BOOL)isIphoneX {
|
|
169
|
-
|
|
169
|
+
UIWindow *window = RCTKeyWindow();
|
|
170
|
+
return window.safeAreaInsets.bottom > 0.0;
|
|
170
171
|
}
|
|
171
172
|
|
|
172
173
|
+ (BOOL)isInCall {
|
|
173
174
|
if ([HBDUtils isIphoneX]) {
|
|
174
175
|
return NO;
|
|
175
176
|
} else {
|
|
176
|
-
|
|
177
|
-
return statusBarHeight == 40;
|
|
177
|
+
return [self statusBarHeight] == 40;
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
+
+ (CGFloat)statusBarHeight {
|
|
182
|
+
if (@available(iOS 13.0, *)) {
|
|
183
|
+
UIStatusBarManager *statusBarManager = RCTKeyWindow().windowScene.statusBarManager;
|
|
184
|
+
return statusBarManager.statusBarFrame.size.height;
|
|
185
|
+
} else {
|
|
186
|
+
return [[UIApplication sharedApplication] statusBarFrame].size.height;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
181
190
|
+ (void)printViewHierarchy:(UIView *)view withPrefix:(NSString *)prefix {
|
|
182
191
|
NSString *viewName = [[[view classForCoder] description] stringByReplacingOccurrencesOfString:@"_" withString:@""];
|
|
183
192
|
NSLog(@"%@%@ %@", prefix, viewName, NSStringFromCGRect(view.frame));
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
#import "HBDReactBridgeManager.h"
|
|
4
4
|
#import "HBDTabBarController.h"
|
|
5
5
|
#import "GlobalStyle.h"
|
|
6
|
+
#import "HBDUtils.h"
|
|
6
7
|
|
|
7
8
|
#import <React/RCTLog.h>
|
|
8
9
|
|
|
@@ -51,12 +52,7 @@ RCT_EXPORT_MODULE(GardenModule)
|
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
- (CGFloat)currentStatusBarHeight {
|
|
54
|
-
|
|
55
|
-
UIStatusBarManager *statusBarManager = [UIApplication sharedApplication].keyWindow.windowScene.statusBarManager;
|
|
56
|
-
return statusBarManager.statusBarFrame.size.height;
|
|
57
|
-
} else {
|
|
58
|
-
return [[UIApplication sharedApplication] statusBarFrame].size.height;
|
|
59
|
-
}
|
|
55
|
+
return [HBDUtils statusBarHeight];
|
|
60
56
|
}
|
|
61
57
|
|
|
62
58
|
- (void)handleStatusBarFrameChange {
|
|
@@ -159,17 +159,16 @@ RCT_EXPORT_METHOD(findSceneIdByModuleName:(NSString *)moduleName callback:(RCTRe
|
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
- (NSString *)findSceneIdByModuleName:(NSString *)moduleName {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
162
|
+
UIWindow *keyWindow = RCTKeyWindow();
|
|
163
|
+
if (keyWindow) {
|
|
164
|
+
NSString *sceneId = [self findSceneIdByModuleName:moduleName withViewController:keyWindow.rootViewController];
|
|
165
|
+
if (sceneId != nil) {
|
|
166
|
+
RCTLogInfo(@"[Navigation] The sceneId found by %@ : %@", moduleName, sceneId);
|
|
167
|
+
return sceneId;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
RCTLogInfo(@"[Navigation] KeyWindow NOT found.");
|
|
173
172
|
|
|
174
173
|
return nil;
|
|
175
174
|
}
|
|
@@ -182,7 +181,7 @@ RCT_EXPORT_METHOD(findSceneIdByModuleName:(NSString *)moduleName callback:(RCTRe
|
|
|
182
181
|
}
|
|
183
182
|
}
|
|
184
183
|
|
|
185
|
-
|
|
184
|
+
if (vc.presentedViewController && vc != vc.presentedViewController && !vc.presentedViewController.isBeingDismissed) {
|
|
186
185
|
NSString *sceneId = [self findSceneIdByModuleName:moduleName withViewController:vc.presentedViewController];
|
|
187
186
|
if (sceneId) {
|
|
188
187
|
return sceneId;
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
- (void)statusBarFrameWillChange:(NSNotification *)notification {
|
|
87
|
-
|
|
87
|
+
CGFloat statusBarHeight = [HBDUtils statusBarHeight];
|
|
88
88
|
if (UIDeviceOrientationIsPortrait([UIDevice currentDevice].orientation) && statusBarHeight != 0) {
|
|
89
89
|
if (self.menuOpened) {
|
|
90
90
|
[UIView animateWithDuration:0.35 animations:^{
|
|
@@ -422,7 +422,7 @@
|
|
|
422
422
|
|
|
423
423
|
// RCTLogInfo(@"[Navigation] safeAreaInsets:%@, additionalInsets:%@", NSStringFromUIEdgeInsets(safeAreaInsets), NSStringFromUIEdgeInsets(additionalInsets));
|
|
424
424
|
|
|
425
|
-
|
|
425
|
+
BOOL statusBarHidden = RCTKeyWindow().windowScene.statusBarManager.statusBarHidden;
|
|
426
426
|
|
|
427
427
|
if (statusBarHidden && safeAreaInsets.top == 0) {
|
|
428
428
|
self.additionalSafeAreaInsets = UIEdgeInsetsMake(20, additionalInsets.left, additionalInsets.bottom, additionalInsets.right);
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
} else {
|
|
78
78
|
UIView *statusBar = [[UIApplication sharedApplication] valueForKey:@"statusBarWindow"];
|
|
79
79
|
BOOL hidden = [self hbd_statusBarHidden] && ![HBDUtils isInCall];
|
|
80
|
-
|
|
80
|
+
CGFloat statusBarHeight = [HBDUtils statusBarHeight];
|
|
81
81
|
[UIView animateWithDuration:0.2 animations:^{
|
|
82
82
|
statusBar.transform = hidden ? CGAffineTransformTranslate(CGAffineTransformIdentity, 0, -statusBarHeight) : CGAffineTransformIdentity;
|
|
83
83
|
statusBar.alpha = hidden ? 0 : 1.0;
|
package/package.json
CHANGED
|
@@ -1,80 +1,49 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
},
|
|
50
|
-
"dependencies": {
|
|
51
|
-
"path-to-regexp": "^6.1.0"
|
|
52
|
-
},
|
|
53
|
-
"devDependencies": {
|
|
54
|
-
"@babel/core": "^7.20.0",
|
|
55
|
-
"@babel/preset-env": "^7.20.0",
|
|
56
|
-
"@babel/runtime": "^7.20.0",
|
|
57
|
-
"@gfez/eslint-config-react-native": "^1.0.0",
|
|
58
|
-
"@react-native-community/hooks": "^2.8.0",
|
|
59
|
-
"@react-native-community/slider": "^4.4.2",
|
|
60
|
-
"@sdcx/keyboard-insets": "^0.5.0",
|
|
61
|
-
"@types/jest": "^29.2.1",
|
|
62
|
-
"@types/react": "^18.0.24",
|
|
63
|
-
"@types/react-redux": "^7.1.9",
|
|
64
|
-
"@types/react-test-renderer": "^18.0.0",
|
|
65
|
-
"babel-jest": "^29.2.1",
|
|
66
|
-
"jest": "^29.2.1",
|
|
67
|
-
"metro-react-native-babel-preset": "0.73.7",
|
|
68
|
-
"react": "18.2.0",
|
|
69
|
-
"react-native": "^0.71.3",
|
|
70
|
-
"react-native-fast-image": "^8.5.11",
|
|
71
|
-
"react-native-safe-area-context": "^4.7.1",
|
|
72
|
-
"react-native-toast-hybrid": "^2.5.0",
|
|
73
|
-
"react-redux": "^7.2.5",
|
|
74
|
-
"react-test-renderer": "18.2.0",
|
|
75
|
-
"redux": "^4.1.1",
|
|
76
|
-
"typescript": "^4.6.4",
|
|
77
|
-
"vuepress": "2.0.0-beta.51",
|
|
78
|
-
"zustand": "^3.7.1"
|
|
79
|
-
}
|
|
2
|
+
"name": "hybrid-navigation",
|
|
3
|
+
"description": "React Native Navigation that supports seamless navigation between Native and React.",
|
|
4
|
+
"version": "2.18.5",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"typings": "./dist/index.d.ts",
|
|
7
|
+
"react-native": "src/index",
|
|
8
|
+
"nativePackage": true,
|
|
9
|
+
"files": [
|
|
10
|
+
"src",
|
|
11
|
+
"dist",
|
|
12
|
+
"android",
|
|
13
|
+
"ios",
|
|
14
|
+
"HybridNavigation.podspec",
|
|
15
|
+
"!android/build",
|
|
16
|
+
"!android/.gradle",
|
|
17
|
+
"!android/.idea",
|
|
18
|
+
"!android/local.properties",
|
|
19
|
+
"!ios/build",
|
|
20
|
+
"!**/__tests__"
|
|
21
|
+
],
|
|
22
|
+
"repository": "https://github.com/listenzz/hybrid-navigation",
|
|
23
|
+
"homepage": "https://github.com/listenzz/hybrid-navigation#readme",
|
|
24
|
+
"author": "listen <listenzz@163.com> (https://github.com/listenzz)",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"licenseFilename": "LICENSE",
|
|
27
|
+
"keywords": [
|
|
28
|
+
"react-native",
|
|
29
|
+
"navigation",
|
|
30
|
+
"navigator",
|
|
31
|
+
"router",
|
|
32
|
+
"hybrid"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "rm -rf ./dist && tsc -p tsconfig.json",
|
|
36
|
+
"prepare": "npm run build",
|
|
37
|
+
"test": "jest",
|
|
38
|
+
"tsc": "tsc",
|
|
39
|
+
"lint": "eslint . --fix --ext .js,.jsx,.ts,.tsx"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"react": ">=16.8",
|
|
43
|
+
"react-native": ">=0.60"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"path-to-regexp": "^6.1.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {}
|
|
80
49
|
}
|
package/src/DeepLink.ts
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {EmitterSubscription, Linking} from 'react-native';
|
|
2
|
+
import {router} from './router';
|
|
3
3
|
|
|
4
4
|
class DeepLinkImpl {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
private active = 0;
|
|
6
|
+
private uriPrefix = '';
|
|
7
|
+
private hasHandleInitialURL = false;
|
|
8
|
+
private subscription: EmitterSubscription | null = null;
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
10
|
+
activate(uriPrefix: string) {
|
|
11
|
+
if (!uriPrefix) {
|
|
12
|
+
throw new Error('must pass `uriPrefix` when activate router.');
|
|
13
|
+
}
|
|
14
|
+
if (this.active === 0) {
|
|
15
|
+
this.uriPrefix = uriPrefix;
|
|
16
|
+
if (!this.hasHandleInitialURL) {
|
|
17
|
+
this.hasHandleInitialURL = true;
|
|
18
|
+
Linking.getInitialURL()
|
|
19
|
+
.then(url => {
|
|
20
|
+
if (url) {
|
|
21
|
+
console.info(`deeplink:${url}`);
|
|
22
|
+
const path = url.replace(this.uriPrefix, '');
|
|
23
|
+
return router.open(path);
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
.catch(err => console.error('An error occurred', err));
|
|
27
|
+
}
|
|
28
|
+
this.subscription = Linking.addEventListener('url', this.handleLinking);
|
|
29
|
+
}
|
|
30
|
+
this.active++;
|
|
31
|
+
}
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
deactivate() {
|
|
34
|
+
this.active--;
|
|
35
|
+
if (this.active === 0) {
|
|
36
|
+
if (this.subscription) {
|
|
37
|
+
this.subscription.remove();
|
|
38
|
+
this.subscription = null;
|
|
39
|
+
} else {
|
|
40
|
+
//@ts-ignore
|
|
41
|
+
Linking.removeEventListener('url', this.handleLinking);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
if (this.active < 0) {
|
|
46
|
+
this.active = 0;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
50
|
+
private handleLinking = (event: {url: string}) => {
|
|
51
|
+
console.info(`deeplink:${event.url}`);
|
|
52
|
+
let path = event.url.replace(this.uriPrefix, '');
|
|
53
|
+
if (!path.startsWith('/')) {
|
|
54
|
+
path = '/' + path;
|
|
55
|
+
}
|
|
56
|
+
router.open(path);
|
|
57
|
+
};
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
export const DeepLink = new DeepLinkImpl()
|
|
60
|
+
export const DeepLink = new DeepLinkImpl();
|