hybrid-navigation 4.0.8 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +1 -0
- package/android/proguard-rules.pro +17 -0
- package/android/src/main/java/com/navigation/androidx/AwesomeFragment.java +1 -1
- package/android/src/main/java/com/navigation/androidx/DrawerFragment.java +7 -3
- package/android/src/main/java/com/navigation/androidx/LifecycleDelegate.java +12 -7
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactFragment.java +2 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactSurfaceCleanup.java +3 -1
- package/dist/handler/VisibilityEventHandler.js +2 -2
- package/ios/GlobalStyle.mm +2 -0
- package/ios/React/HBDNativeNavigation.mm +1 -1
- package/ios/React/HBDReactBridgeManager.h +2 -0
- package/ios/React/HBDReactBridgeManager.mm +54 -2
- package/ios/ViewController/HBDDrawerController.mm +1 -1
- package/ios/ViewController/HBDViewController.mm +16 -4
- package/package.json +1 -1
- package/src/handler/VisibilityEventHandler.ts +4 -4
package/android/build.gradle
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
-keepclassmembers class androidx.drawerlayout.widget.DrawerLayout {
|
|
2
|
+
androidx.customview.widget.ViewDragHelper mLeftDragger;
|
|
3
|
+
float getDrawerViewOffset(android.view.View);
|
|
4
|
+
void moveDrawerToOffset(android.view.View, float);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
-keepclassmembers class androidx.customview.widget.ViewDragHelper {
|
|
8
|
+
int mEdgeSize;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
-keepclassmembers class * implements com.facebook.react.interfaces.fabric.ReactSurface {
|
|
12
|
+
public void updateInitProps(android.os.Bundle);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
-keep class * implements com.navigation.androidx.TabBarProvider {
|
|
16
|
+
public <init>();
|
|
17
|
+
}
|
|
@@ -169,7 +169,7 @@ public abstract class AwesomeFragment extends InternalFragment {
|
|
|
169
169
|
@CallSuper
|
|
170
170
|
public void onResume() {
|
|
171
171
|
super.onResume();
|
|
172
|
-
if (isLeafAwesomeFragment()) {
|
|
172
|
+
if (isLeafAwesomeFragment() && !isResumingForRedirect()) {
|
|
173
173
|
// Log.i(TAG, getDebugTag() + "#onResume");
|
|
174
174
|
setNeedsLayoutInDisplayCutoutModeUpdate();
|
|
175
175
|
setNeedsStatusBarAppearanceUpdate();
|
|
@@ -75,10 +75,11 @@ public class DrawerFragment extends AwesomeFragment implements DrawerLayout.Draw
|
|
|
75
75
|
} else if (margin1 < 0) {
|
|
76
76
|
margin1 = 0;
|
|
77
77
|
}
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
int maxDrawerWidth = AppUtils.dp2px(requireContext(), mMaxDrawerWidth);
|
|
79
|
+
if (maxDrawerWidth <= 0 || maxDrawerWidth > screenWidth) {
|
|
80
|
+
maxDrawerWidth = screenWidth;
|
|
80
81
|
}
|
|
81
|
-
int margin2 = screenWidth -
|
|
82
|
+
int margin2 = screenWidth - maxDrawerWidth;
|
|
82
83
|
int margin = Math.max(margin1, margin2);
|
|
83
84
|
layoutParams.rightMargin = margin - AppUtils.dp2px(requireContext(), 64);
|
|
84
85
|
mMenuLayout.setLayoutParams(layoutParams);
|
|
@@ -130,6 +131,9 @@ public class DrawerFragment extends AwesomeFragment implements DrawerLayout.Draw
|
|
|
130
131
|
@Override
|
|
131
132
|
public void onResume() {
|
|
132
133
|
super.onResume();
|
|
134
|
+
if (isResumingForRedirect()) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
133
137
|
opened = opening = isMenuOpened();
|
|
134
138
|
closed = !isMenuOpened();
|
|
135
139
|
requestMenuGestureStateUpdate();
|
|
@@ -55,14 +55,19 @@ public class LifecycleDelegate implements LifecycleObserver {
|
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
runnable
|
|
62
|
-
|
|
58
|
+
mExecuting = true;
|
|
59
|
+
try {
|
|
60
|
+
Runnable runnable = mTasks.poll();
|
|
61
|
+
while (runnable != null) {
|
|
62
|
+
runnable.run();
|
|
63
|
+
if (!isAtLeastStarted()) {
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
runnable = mTasks.poll();
|
|
67
|
+
}
|
|
68
|
+
} finally {
|
|
69
|
+
mExecuting = false;
|
|
63
70
|
}
|
|
64
|
-
|
|
65
|
-
mExecuting = false;
|
|
66
71
|
}
|
|
67
72
|
|
|
68
73
|
boolean isAtLeastStarted() {
|
|
@@ -143,6 +143,8 @@ public class ReactFragment extends HybridFragment implements ReactManager.ReactB
|
|
|
143
143
|
|
|
144
144
|
private void unmountReactView() {
|
|
145
145
|
getReactManager().removeReactBridgeReloadListener(this);
|
|
146
|
+
firstRenderCompleted = false;
|
|
147
|
+
reactViewAppeared = false;
|
|
146
148
|
|
|
147
149
|
if (reactSurface != null) {
|
|
148
150
|
FLog.w(TAG, "销毁页面-:" + getModuleName());
|
|
@@ -11,9 +11,11 @@ import com.facebook.react.interfaces.fabric.ReactSurface;
|
|
|
11
11
|
|
|
12
12
|
import java.util.concurrent.ExecutorService;
|
|
13
13
|
import java.util.concurrent.Executors;
|
|
14
|
+
import java.util.concurrent.TimeUnit;
|
|
14
15
|
|
|
15
16
|
final class ReactSurfaceCleanup {
|
|
16
17
|
|
|
18
|
+
private static final long CLEANUP_TIMEOUT_MS = 5000L;
|
|
17
19
|
private static final Handler MAIN_HANDLER = new Handler(Looper.getMainLooper());
|
|
18
20
|
private static final ExecutorService EXECUTOR = Executors.newSingleThreadExecutor(runnable -> {
|
|
19
21
|
Thread thread = new Thread(runnable, "ReactSurfaceCleanup");
|
|
@@ -46,7 +48,7 @@ final class ReactSurfaceCleanup {
|
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
try {
|
|
49
|
-
task.waitForCompletion();
|
|
51
|
+
task.waitForCompletion(CLEANUP_TIMEOUT_MS, TimeUnit.MILLISECONDS);
|
|
50
52
|
} catch (InterruptedException ignored) {
|
|
51
53
|
Thread.currentThread().interrupt();
|
|
52
54
|
}
|
|
@@ -5,18 +5,18 @@ export default class VisibilityEventHandler {
|
|
|
5
5
|
constructor() { }
|
|
6
6
|
handleComponentVisibility() {
|
|
7
7
|
NativeEvent.onComponentAppear(({ sceneId }) => {
|
|
8
|
+
this.globalListeners.forEach(listener => listener(sceneId, 'visible'));
|
|
8
9
|
const listeners = this.listeners[sceneId];
|
|
9
10
|
if (listeners) {
|
|
10
11
|
listeners.forEach(listener => listener('visible'));
|
|
11
12
|
}
|
|
12
|
-
this.globalListeners.forEach(listener => listener(sceneId, 'visible'));
|
|
13
13
|
});
|
|
14
14
|
NativeEvent.onComponentDisappear(({ sceneId }) => {
|
|
15
|
+
this.globalListeners.forEach(listener => listener(sceneId, 'invisible'));
|
|
15
16
|
const listeners = this.listeners[sceneId];
|
|
16
17
|
if (listeners) {
|
|
17
18
|
listeners.forEach(listener => listener('invisible'));
|
|
18
19
|
}
|
|
19
|
-
this.globalListeners.forEach(listener => listener(sceneId, 'invisible'));
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
22
|
addGlobalVisibilityEventListener(listener) {
|
package/ios/GlobalStyle.mm
CHANGED
|
@@ -19,7 +19,9 @@
|
|
|
19
19
|
static GlobalStyle *globalStyle;
|
|
20
20
|
|
|
21
21
|
+ (void)createWithOptions:(NSDictionary *)options {
|
|
22
|
+
UIInterfaceOrientationMask interfaceOrientation = globalStyle ? globalStyle.interfaceOrientation : UIInterfaceOrientationMaskPortrait;
|
|
22
23
|
globalStyle = [[GlobalStyle alloc] initWithOptions:options];
|
|
24
|
+
globalStyle.interfaceOrientation = interfaceOrientation;
|
|
23
25
|
[globalStyle inflateTabBar:[UITabBar appearance]];
|
|
24
26
|
}
|
|
25
27
|
|
|
@@ -202,7 +202,7 @@
|
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
- (NSString *)findSceneIdByModuleName:(NSString *)moduleName {
|
|
205
|
-
UIWindow *keyWindow = RCTKeyWindow();
|
|
205
|
+
UIWindow *keyWindow = RCTKeyWindow() ?: [self.bridgeManager mainWindow];
|
|
206
206
|
if (keyWindow) {
|
|
207
207
|
NSString *sceneId = [self findSceneIdByModuleName:moduleName withViewController:keyWindow.rootViewController];
|
|
208
208
|
if (sceneId != nil) {
|
|
@@ -43,12 +43,64 @@ const NSInteger ResultBlock = -2;
|
|
|
43
43
|
return self;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
- (UIWindowScene *)activeWindowScene {
|
|
47
|
+
UIWindowScene *fallbackScene = nil;
|
|
48
|
+
for (UIScene *scene in RCTSharedApplication().connectedScenes) {
|
|
49
|
+
if (![scene isKindOfClass:[UIWindowScene class]]) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
UIWindowScene *windowScene = (UIWindowScene *)scene;
|
|
53
|
+
if (windowScene.activationState == UISceneActivationStateForegroundActive) {
|
|
54
|
+
return windowScene;
|
|
55
|
+
}
|
|
56
|
+
if (windowScene.activationState == UISceneActivationStateForegroundInactive) {
|
|
57
|
+
fallbackScene = windowScene;
|
|
58
|
+
} else if (!fallbackScene) {
|
|
59
|
+
fallbackScene = windowScene;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return fallbackScene;
|
|
63
|
+
}
|
|
64
|
+
|
|
46
65
|
- (UIWindow *)mainWindow {
|
|
47
|
-
|
|
66
|
+
UIWindowScene *windowScene = [self activeWindowScene];
|
|
67
|
+
if (windowScene) {
|
|
68
|
+
id<UISceneDelegate> sceneDelegate = windowScene.delegate;
|
|
69
|
+
if ([sceneDelegate respondsToSelector:@selector(window)]) {
|
|
70
|
+
UIWindow *sceneWindow = [(id<UIWindowSceneDelegate>)sceneDelegate window];
|
|
71
|
+
if (sceneWindow) {
|
|
72
|
+
return sceneWindow;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (@available(iOS 15.0, *)) {
|
|
76
|
+
if (windowScene.keyWindow) {
|
|
77
|
+
return windowScene.keyWindow;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
for (UIWindow *window in windowScene.windows) {
|
|
81
|
+
if (window.isKeyWindow) {
|
|
82
|
+
return window;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (windowScene.windows.firstObject) {
|
|
86
|
+
return windowScene.windows.firstObject;
|
|
87
|
+
}
|
|
88
|
+
UIWindow *mainWindow = [[UIWindow alloc] initWithWindowScene:windowScene];
|
|
89
|
+
mainWindow.backgroundColor = UIColor.whiteColor;
|
|
90
|
+
if ([sceneDelegate respondsToSelector:@selector(setWindow:)]) {
|
|
91
|
+
[(id<UIWindowSceneDelegate>)sceneDelegate setWindow:mainWindow];
|
|
92
|
+
}
|
|
93
|
+
return mainWindow;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
id<UIApplicationDelegate> appDelegate = RCTSharedApplication().delegate;
|
|
97
|
+
UIWindow *mainWindow = [appDelegate respondsToSelector:@selector(window)] ? appDelegate.window : nil;
|
|
48
98
|
if (!mainWindow) {
|
|
49
99
|
mainWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
|
50
100
|
mainWindow.backgroundColor = UIColor.whiteColor;
|
|
51
|
-
|
|
101
|
+
if ([appDelegate respondsToSelector:@selector(setWindow:)]) {
|
|
102
|
+
appDelegate.window = mainWindow;
|
|
103
|
+
}
|
|
52
104
|
}
|
|
53
105
|
return mainWindow;
|
|
54
106
|
}
|
|
@@ -557,7 +557,7 @@ static const CGFloat HBDDrawerMenuOverlayMaxAlpha = 0.34;
|
|
|
557
557
|
|
|
558
558
|
CGPoint translation = [recognizer translationInView:self.view];
|
|
559
559
|
CGFloat width = [self menuWidth];
|
|
560
|
-
CGFloat progress = MIN(1, MAX(0, self.drawerPanStartProgress + translation.x / width));
|
|
560
|
+
CGFloat progress = width > 0 ? MIN(1, MAX(0, self.drawerPanStartProgress + translation.x / width)) : self.drawerPanStartProgress;
|
|
561
561
|
if (recognizer.state == UIGestureRecognizerStateBegan) {
|
|
562
562
|
if ([recognizer isKindOfClass:[UIScreenEdgePanGestureRecognizer class]] ||
|
|
563
563
|
[self isDrawerVisible] ||
|
|
@@ -112,9 +112,15 @@
|
|
|
112
112
|
[GlobalStyle globalStyle].interfaceOrientation = mask;
|
|
113
113
|
if (@available(iOS 16.0, *)) {
|
|
114
114
|
// Ensure orientation capability is updated before geometry request.
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
UIViewController *controller = self;
|
|
116
|
+
while (controller != nil) {
|
|
117
|
+
[controller setNeedsUpdateOfSupportedInterfaceOrientations];
|
|
118
|
+
controller = controller.parentViewController;
|
|
119
|
+
}
|
|
120
|
+
UIViewController *rootViewController = self.view.window.rootViewController ?: windowScene.keyWindow.rootViewController;
|
|
121
|
+
if (rootViewController != nil) {
|
|
122
|
+
[rootViewController setNeedsUpdateOfSupportedInterfaceOrientations];
|
|
123
|
+
}
|
|
118
124
|
|
|
119
125
|
if (windowScene != nil) {
|
|
120
126
|
UIWindowSceneGeometryPreferencesIOS *geometryPreferences = [[UIWindowSceneGeometryPreferencesIOS alloc] initWithInterfaceOrientations:mask];
|
|
@@ -141,15 +147,21 @@
|
|
|
141
147
|
}
|
|
142
148
|
|
|
143
149
|
NSArray *array = [[[UIApplication sharedApplication] connectedScenes] allObjects];
|
|
150
|
+
UIWindowScene *fallbackScene = nil;
|
|
144
151
|
for (id connectedScene in array) {
|
|
145
152
|
if ([connectedScene isKindOfClass:[UIWindowScene class]]) {
|
|
146
153
|
UIWindowScene *scene = (UIWindowScene *)connectedScene;
|
|
147
154
|
if (scene.activationState == UISceneActivationStateForegroundActive) {
|
|
148
155
|
return scene;
|
|
149
156
|
}
|
|
157
|
+
if (scene.activationState == UISceneActivationStateForegroundInactive) {
|
|
158
|
+
fallbackScene = scene;
|
|
159
|
+
} else if (!fallbackScene) {
|
|
160
|
+
fallbackScene = scene;
|
|
161
|
+
}
|
|
150
162
|
}
|
|
151
163
|
}
|
|
152
|
-
return
|
|
164
|
+
return fallbackScene;
|
|
153
165
|
}
|
|
154
166
|
|
|
155
167
|
- (void)viewDidLoad {
|
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": "4.0
|
|
4
|
+
"version": "4.1.0",
|
|
5
5
|
"main": "./dist/index",
|
|
6
6
|
"module": "./dist/index",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -12,20 +12,20 @@ export default class VisibilityEventHandler {
|
|
|
12
12
|
|
|
13
13
|
handleComponentVisibility() {
|
|
14
14
|
NativeEvent.onComponentAppear(({ sceneId }) => {
|
|
15
|
+
this.globalListeners.forEach(listener => listener(sceneId, 'visible'));
|
|
16
|
+
|
|
15
17
|
const listeners = this.listeners[sceneId];
|
|
16
18
|
if (listeners) {
|
|
17
19
|
listeners.forEach(listener => listener('visible'));
|
|
18
20
|
}
|
|
19
|
-
|
|
20
|
-
this.globalListeners.forEach(listener => listener(sceneId, 'visible'));
|
|
21
21
|
});
|
|
22
22
|
NativeEvent.onComponentDisappear(({ sceneId }) => {
|
|
23
|
+
this.globalListeners.forEach(listener => listener(sceneId, 'invisible'));
|
|
24
|
+
|
|
23
25
|
const listeners = this.listeners[sceneId];
|
|
24
26
|
if (listeners) {
|
|
25
27
|
listeners.forEach(listener => listener('invisible'));
|
|
26
28
|
}
|
|
27
|
-
|
|
28
|
-
this.globalListeners.forEach(listener => listener(sceneId, 'invisible'));
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
|