hybrid-navigation 4.0.0 → 4.0.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.
- package/android/src/main/java/com/navigation/androidx/DrawerFragment.java +224 -12
- package/android/src/main/java/com/navigation/androidx/HybridDrawerLayout.java +636 -0
- package/android/src/main/java/com/navigation/androidx/StackFragment.java +4 -0
- package/android/src/main/java/com/navigation/androidx/TabBarFragment.java +4 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/HBDRootView.java +36 -10
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivity.java +9 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivityDelegate.java +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactFragment.java +2 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactSurfaceCleanup.java +54 -0
- package/android/src/main/res/layout/nav_fragment_drawer.xml +2 -2
- package/ios/Navigator/HBDStackNavigator.mm +1 -23
- package/ios/React/HBDNativeNavigation.mm +21 -5
- package/ios/ViewController/HBDDrawerController.mm +615 -87
- package/ios/ViewController/HBDNavigationController.mm +28 -1
- package/ios/ViewController/HBDViewController.mm +2 -2
- package/package.json +1 -1
- /package/dist/{src/DeepLink.d.ts → DeepLink.d.ts} +0 -0
- /package/dist/{src/DeepLink.js → DeepLink.js} +0 -0
- /package/dist/{src/NativeEvent.d.ts → NativeEvent.d.ts} +0 -0
- /package/dist/{src/NativeEvent.js → NativeEvent.js} +0 -0
- /package/dist/{src/NativeGarden.d.ts → NativeGarden.d.ts} +0 -0
- /package/dist/{src/NativeGarden.js → NativeGarden.js} +0 -0
- /package/dist/{src/NativeNavigation.d.ts → NativeNavigation.d.ts} +0 -0
- /package/dist/{src/NativeNavigation.js → NativeNavigation.js} +0 -0
- /package/dist/{src/Navigation.d.ts → Navigation.d.ts} +0 -0
- /package/dist/{src/Navigation.js → Navigation.js} +0 -0
- /package/dist/{src/NavigationComponentWrap.d.ts → NavigationComponentWrap.d.ts} +0 -0
- /package/dist/{src/NavigationComponentWrap.js → NavigationComponentWrap.js} +0 -0
- /package/dist/{src/Navigator.d.ts → Navigator.d.ts} +0 -0
- /package/dist/{src/Navigator.js → Navigator.js} +0 -0
- /package/dist/{src/Options.d.ts → Options.d.ts} +0 -0
- /package/dist/{src/Options.js → Options.js} +0 -0
- /package/dist/{src/Route.d.ts → Route.d.ts} +0 -0
- /package/dist/{src/Route.js → Route.js} +0 -0
- /package/dist/{src/handler → handler}/DispatchCommandHandler.d.ts +0 -0
- /package/dist/{src/handler → handler}/DispatchCommandHandler.js +0 -0
- /package/dist/{src/handler → handler}/LayoutCommandHandler.d.ts +0 -0
- /package/dist/{src/handler → handler}/LayoutCommandHandler.js +0 -0
- /package/dist/{src/handler → handler}/ResultEventHandler.d.ts +0 -0
- /package/dist/{src/handler → handler}/ResultEventHandler.js +0 -0
- /package/dist/{src/handler → handler}/VisibilityEventHandler.d.ts +0 -0
- /package/dist/{src/handler → handler}/VisibilityEventHandler.js +0 -0
- /package/dist/{src/hooks.d.ts → hooks.d.ts} +0 -0
- /package/dist/{src/hooks.js → hooks.js} +0 -0
- /package/dist/{src/index.d.ts → index.d.ts} +0 -0
- /package/dist/{src/index.js → index.js} +0 -0
- /package/dist/{src/router → router}/drawer.d.ts +0 -0
- /package/dist/{src/router → router}/drawer.js +0 -0
- /package/dist/{src/router → router}/index.d.ts +0 -0
- /package/dist/{src/router → router}/index.js +0 -0
- /package/dist/{src/router → router}/screen.d.ts +0 -0
- /package/dist/{src/router → router}/screen.js +0 -0
- /package/dist/{src/router → router}/stack.d.ts +0 -0
- /package/dist/{src/router → router}/stack.js +0 -0
- /package/dist/{src/router → router}/tabs.d.ts +0 -0
- /package/dist/{src/router → router}/tabs.js +0 -0
- /package/dist/{src/store.d.ts → store.d.ts} +0 -0
- /package/dist/{src/store.js → store.js} +0 -0
|
@@ -12,6 +12,7 @@ import android.widget.FrameLayout;
|
|
|
12
12
|
import androidx.annotation.NonNull;
|
|
13
13
|
import androidx.annotation.Nullable;
|
|
14
14
|
|
|
15
|
+
import com.facebook.react.interfaces.TaskInterface;
|
|
15
16
|
import com.facebook.react.interfaces.fabric.ReactSurface;
|
|
16
17
|
import com.facebook.react.runtime.ReactSurfaceView;
|
|
17
18
|
|
|
@@ -27,6 +28,9 @@ public class HBDRootView extends FrameLayout {
|
|
|
27
28
|
@Nullable
|
|
28
29
|
private ReactSurfaceView reactSurfaceView;
|
|
29
30
|
|
|
31
|
+
@Nullable
|
|
32
|
+
private TaskInterface<Void> startTask;
|
|
33
|
+
|
|
30
34
|
@Nullable
|
|
31
35
|
private Bundle appProperties;
|
|
32
36
|
|
|
@@ -75,7 +79,7 @@ public class HBDRootView extends FrameLayout {
|
|
|
75
79
|
applyAppProperties(appProperties);
|
|
76
80
|
}
|
|
77
81
|
|
|
78
|
-
reactSurface.start();
|
|
82
|
+
startTask = reactSurface.start();
|
|
79
83
|
}
|
|
80
84
|
|
|
81
85
|
public void clearSurface() {
|
|
@@ -83,18 +87,30 @@ public class HBDRootView extends FrameLayout {
|
|
|
83
87
|
}
|
|
84
88
|
|
|
85
89
|
public void clearSurface(boolean stopSurface) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
reactSurfaceView.setOnTouchListener(null);
|
|
90
|
+
ReactSurface oldSurface = surface;
|
|
91
|
+
ReactSurfaceView oldReactSurfaceView = reactSurfaceView;
|
|
92
|
+
TaskInterface<Void> oldStartTask = startTask;
|
|
93
|
+
View oldSurfaceRootView = oldReactSurfaceView;
|
|
94
|
+
|
|
95
|
+
if (oldSurfaceRootView == null && oldSurface != null) {
|
|
96
|
+
oldSurfaceRootView = oldSurface.getView();
|
|
94
97
|
}
|
|
98
|
+
|
|
95
99
|
surface = null;
|
|
96
100
|
reactSurfaceView = null;
|
|
97
|
-
|
|
101
|
+
startTask = null;
|
|
102
|
+
|
|
103
|
+
if (oldReactSurfaceView != null) {
|
|
104
|
+
oldReactSurfaceView.setOnTouchListener(null);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
View surfaceRootView = oldSurfaceRootView;
|
|
108
|
+
if (oldSurface != null && stopSurface) {
|
|
109
|
+
ReactSurfaceCleanup.stopThenRun(oldSurface, oldStartTask, () -> removeSurfaceRootView(surfaceRootView));
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
removeSurfaceRootView(surfaceRootView);
|
|
98
114
|
}
|
|
99
115
|
|
|
100
116
|
public void setAppProperties(@Nullable Bundle appProperties) {
|
|
@@ -133,4 +149,14 @@ public class HBDRootView extends FrameLayout {
|
|
|
133
149
|
InvocationTargetException ignored) {
|
|
134
150
|
}
|
|
135
151
|
}
|
|
152
|
+
|
|
153
|
+
private void removeSurfaceRootView(@Nullable View oldSurfaceRootView) {
|
|
154
|
+
if (oldSurfaceRootView == null) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (oldSurfaceRootView.getParent() == this) {
|
|
159
|
+
removeView(oldSurfaceRootView);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
136
162
|
}
|
|
@@ -99,6 +99,15 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
|
|
|
99
99
|
onCreateMainComponent();
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
protected void setNeedsSystemBarsAppearanceUpdate() {
|
|
103
|
+
Fragment fragment = getSupportFragmentManager().findFragmentById(android.R.id.content);
|
|
104
|
+
if (fragment instanceof AwesomeFragment awesomeFragment) {
|
|
105
|
+
awesomeFragment.setNeedsLayoutInDisplayCutoutModeUpdate();
|
|
106
|
+
awesomeFragment.setNeedsStatusBarAppearanceUpdate();
|
|
107
|
+
awesomeFragment.setNeedsNavigationBarAppearanceUpdate();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
102
111
|
protected void onCreateMainComponent() {
|
|
103
112
|
ReactManager reactManager = getReactManager();
|
|
104
113
|
if (getMainComponentName() != null) {
|
package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivityDelegate.java
CHANGED
|
@@ -133,7 +133,7 @@ public class ReactAppCompatActivityDelegate {
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
public void onConfigurationChanged(Configuration newConfig) {
|
|
136
|
-
DisplayMetricsHolder.
|
|
136
|
+
DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(getPlainActivity());
|
|
137
137
|
ReactHost reactHost = mReactManager.getReactHost();
|
|
138
138
|
reactHost.onConfigurationChanged(getPlainActivity());
|
|
139
139
|
}
|
|
@@ -16,6 +16,7 @@ import com.facebook.react.bridge.Arguments;
|
|
|
16
16
|
import com.facebook.react.bridge.ReactContext;
|
|
17
17
|
import com.facebook.react.common.LifecycleState;
|
|
18
18
|
import com.facebook.react.interfaces.fabric.ReactSurface;
|
|
19
|
+
import com.navigation.androidx.FragmentHelper;
|
|
19
20
|
|
|
20
21
|
public class ReactFragment extends HybridFragment implements ReactManager.ReactBridgeReloadListener {
|
|
21
22
|
|
|
@@ -47,7 +48,7 @@ public class ReactFragment extends HybridFragment implements ReactManager.ReactB
|
|
|
47
48
|
@Override
|
|
48
49
|
public void onStop() {
|
|
49
50
|
super.onStop();
|
|
50
|
-
if (isRemoving() && forceScreenLandscape()) {
|
|
51
|
+
if (FragmentHelper.isRemoving(this) && forceScreenLandscape()) {
|
|
51
52
|
unmountReactView();
|
|
52
53
|
}
|
|
53
54
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
package com.reactnative.hybridnavigation;
|
|
2
|
+
|
|
3
|
+
import android.os.Handler;
|
|
4
|
+
import android.os.Looper;
|
|
5
|
+
|
|
6
|
+
import androidx.annotation.NonNull;
|
|
7
|
+
import androidx.annotation.Nullable;
|
|
8
|
+
|
|
9
|
+
import com.facebook.react.interfaces.TaskInterface;
|
|
10
|
+
import com.facebook.react.interfaces.fabric.ReactSurface;
|
|
11
|
+
|
|
12
|
+
import java.util.concurrent.ExecutorService;
|
|
13
|
+
import java.util.concurrent.Executors;
|
|
14
|
+
|
|
15
|
+
final class ReactSurfaceCleanup {
|
|
16
|
+
|
|
17
|
+
private static final Handler MAIN_HANDLER = new Handler(Looper.getMainLooper());
|
|
18
|
+
private static final ExecutorService EXECUTOR = Executors.newSingleThreadExecutor(runnable -> {
|
|
19
|
+
Thread thread = new Thread(runnable, "ReactSurfaceCleanup");
|
|
20
|
+
thread.setDaemon(true);
|
|
21
|
+
return thread;
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
private ReactSurfaceCleanup() {
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
static void stopThenRun(
|
|
28
|
+
@NonNull ReactSurface surface,
|
|
29
|
+
@Nullable TaskInterface<Void> startTask,
|
|
30
|
+
@NonNull Runnable completion
|
|
31
|
+
) {
|
|
32
|
+
EXECUTOR.execute(() -> {
|
|
33
|
+
// RN 0.84/0.85 can ignore stopSurface if it runs before startSurface marks the surface running.
|
|
34
|
+
waitForTask(startTask);
|
|
35
|
+
try {
|
|
36
|
+
waitForTask(surface.stop());
|
|
37
|
+
} catch (RuntimeException ignored) {
|
|
38
|
+
}
|
|
39
|
+
MAIN_HANDLER.post(completion);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private static void waitForTask(@Nullable TaskInterface<Void> task) {
|
|
44
|
+
if (task == null) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
task.waitForCompletion();
|
|
50
|
+
} catch (InterruptedException ignored) {
|
|
51
|
+
Thread.currentThread().interrupt();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
<
|
|
2
|
+
<com.navigation.androidx.HybridDrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
3
|
android:id="@+id/drawer"
|
|
4
4
|
android:fitsSystemWindows="false"
|
|
5
5
|
android:layout_width="match_parent"
|
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
android:layout_gravity="start" />
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
</
|
|
23
|
+
</com.navigation.androidx.HybridDrawerLayout>
|
|
@@ -294,29 +294,7 @@
|
|
|
294
294
|
return (UINavigationController *)vc;
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
-
|
|
298
|
-
if (nav) {
|
|
299
|
-
return nav;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
HBDDrawerController *drawer = vc.drawerController;
|
|
303
|
-
if (!drawer) {
|
|
304
|
-
return nil;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
if ([drawer.contentController isKindOfClass:[UITabBarController class]]) {
|
|
308
|
-
UITabBarController *tabs = (UITabBarController *)drawer.contentController;
|
|
309
|
-
if ([tabs.selectedViewController isKindOfClass:[UINavigationController class]]) {
|
|
310
|
-
return (UINavigationController *)tabs.selectedViewController;
|
|
311
|
-
}
|
|
312
|
-
return nil;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
if ([drawer.contentController isKindOfClass:[UINavigationController class]]) {
|
|
316
|
-
return (UINavigationController *)drawer.contentController;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
return drawer.contentController.navigationController;
|
|
297
|
+
return vc.navigationController;
|
|
320
298
|
}
|
|
321
299
|
|
|
322
300
|
- (void)invalidate {
|
|
@@ -107,6 +107,11 @@
|
|
|
107
107
|
|
|
108
108
|
- (void)isStackRoot:(nonnull NSString *)sceneId callback:(nonnull RCTResponseSenderBlock)callback {
|
|
109
109
|
UIViewController *vc = [self.bridgeManager viewControllerBySceneId:sceneId];
|
|
110
|
+
if (!vc) {
|
|
111
|
+
callback(@[NSNull.null, @NO]);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
110
115
|
UINavigationController *nav = vc.navigationController;
|
|
111
116
|
if (!nav) {
|
|
112
117
|
callback(@[NSNull.null, @NO]);
|
|
@@ -120,17 +125,28 @@
|
|
|
120
125
|
}
|
|
121
126
|
|
|
122
127
|
UIViewController *root = children[0];
|
|
123
|
-
if ([
|
|
128
|
+
if ([self viewController:vc hasAncestorOrSelf:root]) {
|
|
124
129
|
callback(@[NSNull.null, @YES]);
|
|
125
130
|
return;
|
|
126
131
|
}
|
|
127
132
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
133
|
+
callback(@[NSNull.null, @NO]);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
- (BOOL)viewController:(UIViewController *)viewController hasAncestorOrSelf:(UIViewController *)ancestor {
|
|
137
|
+
if (!viewController || !ancestor) {
|
|
138
|
+
return NO;
|
|
131
139
|
}
|
|
132
140
|
|
|
133
|
-
|
|
141
|
+
NSMutableSet<UIViewController *> *visited = [NSMutableSet set];
|
|
142
|
+
for (UIViewController *current = viewController; current != nil && ![visited containsObject:current]; current = current.parentViewController) {
|
|
143
|
+
if (current == ancestor) {
|
|
144
|
+
return YES;
|
|
145
|
+
}
|
|
146
|
+
[visited addObject:current];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return NO;
|
|
134
150
|
}
|
|
135
151
|
|
|
136
152
|
- (void)dispatch:(nonnull NSString *)sceneId action:(nonnull NSString *)action params:(nonnull NSDictionary *)params callback:(nonnull RCTResponseSenderBlock)callback {
|