hybrid-navigation 4.0.8 → 5.0.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/HybridNavigation.podspec +9 -1
- package/README.md +12 -4
- package/android/build.gradle +5 -4
- package/android/proguard-rules.pro +3 -0
- package/android/src/main/java/com/navigation/androidx/AwesomeActivity.java +114 -23
- package/android/src/main/java/com/navigation/androidx/AwesomeFragment.java +116 -13
- package/android/src/main/java/com/navigation/androidx/DrawableUtils.java +83 -18
- package/android/src/main/java/com/navigation/androidx/DrawerFragment.java +192 -28
- package/android/src/main/java/com/navigation/androidx/FragmentHelper.java +11 -0
- package/android/src/main/java/com/navigation/androidx/HybridDrawerLayout.java +563 -143
- package/android/src/main/java/com/navigation/androidx/LifecycleDelegate.java +47 -15
- package/android/src/main/java/com/navigation/androidx/PresentableActivity.java +3 -0
- package/android/src/main/java/com/navigation/androidx/PresentationDelegate.java +8 -3
- package/android/src/main/java/com/navigation/androidx/StackDelegate.java +29 -9
- package/android/src/main/java/com/navigation/androidx/StackFragment.java +28 -3
- package/android/src/main/java/com/navigation/androidx/SystemUI.java +59 -90
- package/android/src/main/java/com/navigation/androidx/TabBar.java +21 -2
- package/android/src/main/java/com/navigation/androidx/TabBarFragment.java +24 -7
- package/android/src/main/java/com/navigation/androidx/TabView.java +11 -2
- package/android/src/main/java/com/reactnative/hybridnavigation/DispatchResult.java +59 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/Garden.java +18 -10
- package/android/src/main/java/com/reactnative/hybridnavigation/GlobalStyle.java +15 -2
- package/android/src/main/java/com/reactnative/hybridnavigation/HBDRootView.java +3 -8
- package/android/src/main/java/com/reactnative/hybridnavigation/HybridFragment.java +113 -6
- package/android/src/main/java/com/reactnative/hybridnavigation/HybridNavigationPackage.java +13 -24
- package/android/src/main/java/com/reactnative/hybridnavigation/NativeEvent.java +5 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/NativeNavigation.java +196 -194
- package/android/src/main/java/com/reactnative/hybridnavigation/NavigationCommandQueue.java +499 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/Navigator.java +4 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/OrientationCoordinator.java +162 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivity.java +103 -66
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactFragment.java +50 -87
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactManager.java +156 -77
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactStackFragment.java +6 -6
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactSurfaceCleanup.java +3 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarProvider.java +8 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/SceneLifecycleState.java +21 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/SceneLifecycleStateMachine.java +116 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/ScreenOrientation.java +42 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/Utils.java +17 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/DrawerNavigator.java +14 -6
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/ScreenNavigator.java +62 -22
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/StackNavigator.java +35 -16
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/TabNavigator.java +16 -13
- package/dist/DeepLink.d.ts +3 -2
- package/dist/DeepLink.js +37 -14
- package/dist/NativeEvent.d.ts +4 -12
- package/dist/NativeNavigation.d.ts +17 -19
- package/dist/Navigation.d.ts +21 -19
- package/dist/Navigation.js +83 -89
- package/dist/NavigationComponentWrap.d.ts +4 -3
- package/dist/NavigationComponentWrap.js +3 -6
- package/dist/Navigator.d.ts +31 -42
- package/dist/Navigator.js +97 -90
- package/dist/Options.d.ts +3 -1
- package/dist/Route.d.ts +85 -18
- package/dist/handler/DispatchCommandHandler.d.ts +10 -6
- package/dist/handler/DispatchCommandHandler.js +41 -17
- package/dist/handler/LayoutCommandHandler.d.ts +7 -7
- package/dist/handler/LayoutCommandHandler.js +21 -15
- package/dist/handler/LifecycleEventHandler.d.ts +26 -0
- package/dist/handler/LifecycleEventHandler.js +136 -0
- package/dist/handler/ResultEventHandler.d.ts +14 -9
- package/dist/handler/ResultEventHandler.js +88 -13
- package/dist/hooks.d.ts +5 -2
- package/dist/hooks.js +26 -4
- package/dist/index.d.ts +13 -0
- package/dist/index.js +0 -2
- package/dist/routeConfigRegistry.d.ts +6 -0
- package/dist/routeConfigRegistry.js +19 -0
- package/dist/router/drawer.d.ts +2 -2
- package/dist/router/drawer.js +6 -3
- package/dist/router/index.d.ts +8 -5
- package/dist/router/index.js +127 -43
- package/dist/router/screen.d.ts +2 -2
- package/dist/router/screen.js +1 -1
- package/dist/router/stack.d.ts +2 -2
- package/dist/router/stack.js +59 -30
- package/dist/router/tabs.d.ts +2 -2
- package/dist/router/tabs.js +4 -1
- package/dist/store.d.ts +2 -2
- package/ios/HBDGlobalStyle.h +26 -0
- package/ios/{GlobalStyle.mm → HBDGlobalStyle.mm} +30 -27
- package/ios/HybridNavigation.h +4 -1
- package/ios/Navigator/HBDDrawerNavigator.mm +24 -8
- package/ios/Navigator/HBDNavigatorRegistry.mm +1 -0
- package/ios/Navigator/HBDScreenNavigator.mm +106 -52
- package/ios/Navigator/HBDStackNavigator.mm +109 -61
- package/ios/Navigator/HBDTabNavigator.mm +32 -14
- package/ios/React/HBDNativeNavigation.mm +109 -131
- package/ios/React/HBDNavigator.h +29 -5
- package/ios/React/HBDOrientationCoordinator.h +27 -0
- package/ios/React/HBDOrientationCoordinator.mm +282 -0
- package/ios/React/HBDReactBridgeManager.h +37 -19
- package/ios/React/HBDReactBridgeManager.mm +490 -96
- package/ios/React/HBDSceneLifecycleStateMachine.h +38 -0
- package/ios/React/HBDSceneLifecycleStateMachine.mm +180 -0
- package/ios/View/HBDRootView.h +2 -0
- package/ios/View/HBDRootView.mm +148 -0
- package/ios/View/UIImage+WithBadge.h +3 -3
- package/ios/View/UIImage+WithBadge.mm +10 -15
- package/ios/ViewController/HBDDrawerController.mm +127 -6
- package/ios/ViewController/HBDNavigationController.mm +17 -4
- package/ios/ViewController/HBDReactViewController.mm +59 -121
- package/ios/ViewController/HBDTabBarController.h +4 -0
- package/ios/ViewController/HBDTabBarController.mm +59 -44
- package/ios/ViewController/HBDViewController.h +10 -3
- package/ios/ViewController/HBDViewController.mm +161 -147
- package/ios/ViewController/UINavigationController+HBD.h +2 -2
- package/ios/ViewController/UINavigationController+HBD.mm +3 -3
- package/ios/ViewController/UIViewController+HBD.h +17 -10
- package/ios/ViewController/UIViewController+HBD.mm +85 -69
- package/package.json +1 -1
- package/src/DeepLink.ts +41 -14
- package/src/NativeEvent.ts +4 -14
- package/src/NativeNavigation.ts +22 -33
- package/src/Navigation.ts +162 -121
- package/src/NavigationComponentWrap.tsx +9 -9
- package/src/Navigator.ts +191 -153
- package/src/Options.ts +3 -1
- package/src/Route.ts +134 -19
- package/src/handler/DispatchCommandHandler.ts +55 -21
- package/src/handler/LayoutCommandHandler.ts +36 -17
- package/src/handler/LifecycleEventHandler.ts +172 -0
- package/src/handler/ResultEventHandler.ts +112 -19
- package/src/hooks.ts +39 -7
- package/src/index.ts +26 -2
- package/src/routeConfigRegistry.ts +26 -0
- package/src/router/drawer.ts +8 -5
- package/src/router/index.ts +161 -50
- package/src/router/screen.ts +3 -3
- package/src/router/stack.ts +80 -29
- package/src/router/tabs.ts +15 -7
- package/src/store.ts +1 -1
- package/android/src/main/java/androidx/fragment/app/InternalFragment.java +0 -22
- package/android/src/main/java/com/navigation/androidx/SystemUI30.java +0 -87
- package/android/src/main/java/com/reactnative/hybridnavigation/NativeGarden.java +0 -176
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBar.java +0 -130
- package/android/src/main/res/layout/nav_tab_bar_react.xml +0 -32
- package/android/src/main/res/layout/nav_tab_bar_react_indeterminate.xml +0 -32
- package/dist/NativeGarden.d.ts +0 -13
- package/dist/NativeGarden.js +0 -2
- package/dist/handler/VisibilityEventHandler.d.ts +0 -13
- package/dist/handler/VisibilityEventHandler.js +0 -39
- package/ios/GlobalStyle.h +0 -15
- package/ios/React/HBDNativeGarden.h +0 -10
- package/ios/React/HBDNativeGarden.mm +0 -111
- package/src/NativeGarden.ts +0 -16
- package/src/handler/VisibilityEventHandler.ts +0 -52
|
@@ -29,6 +29,7 @@ import androidx.core.graphics.drawable.DrawableCompat;
|
|
|
29
29
|
public class TabView extends FrameLayout {
|
|
30
30
|
|
|
31
31
|
protected int position;
|
|
32
|
+
private int iconLoadGeneration;
|
|
32
33
|
protected int selectedColor;
|
|
33
34
|
protected int unselectedColor;
|
|
34
35
|
protected int badgeColor;
|
|
@@ -82,8 +83,16 @@ public class TabView extends FrameLayout {
|
|
|
82
83
|
setLayoutParams(params);
|
|
83
84
|
}
|
|
84
85
|
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
int nextIconLoadGeneration() {
|
|
87
|
+
return ++iconLoadGeneration;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
int getIconLoadGeneration() {
|
|
91
|
+
return iconLoadGeneration;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
public void setIcon(@Nullable Drawable icon) {
|
|
95
|
+
this.icon = icon != null ? DrawableCompat.wrap(icon) : null;
|
|
87
96
|
}
|
|
88
97
|
|
|
89
98
|
public void setUnselectedIcon(@Nullable Drawable icon) {
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
package com.reactnative.hybridnavigation;
|
|
2
|
+
|
|
3
|
+
import android.text.TextUtils;
|
|
4
|
+
|
|
5
|
+
import androidx.annotation.NonNull;
|
|
6
|
+
import androidx.annotation.Nullable;
|
|
7
|
+
|
|
8
|
+
import com.facebook.react.bridge.Arguments;
|
|
9
|
+
import com.facebook.react.bridge.WritableMap;
|
|
10
|
+
|
|
11
|
+
public final class DispatchResult {
|
|
12
|
+
|
|
13
|
+
public static final String CODE_OK = "ok";
|
|
14
|
+
public static final String CODE_INTERCEPTED = "intercepted";
|
|
15
|
+
public static final String CODE_SCENE_NOT_FOUND = "scene_not_found";
|
|
16
|
+
public static final String CODE_ALREADY_PRESENTING = "already_presenting";
|
|
17
|
+
public static final String CODE_NOT_READY = "not_ready";
|
|
18
|
+
public static final String CODE_SUPERSEDED = "superseded";
|
|
19
|
+
public static final String CODE_INVALID_ACTION = "invalid_action";
|
|
20
|
+
public static final String CODE_HOST_UNAVAILABLE = "host_unavailable";
|
|
21
|
+
|
|
22
|
+
public final boolean ok;
|
|
23
|
+
@NonNull
|
|
24
|
+
public final String code;
|
|
25
|
+
@Nullable
|
|
26
|
+
public final String message;
|
|
27
|
+
|
|
28
|
+
private DispatchResult(boolean ok, @NonNull String code, @Nullable String message) {
|
|
29
|
+
this.ok = ok;
|
|
30
|
+
this.code = code;
|
|
31
|
+
this.message = message;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@NonNull
|
|
35
|
+
public static DispatchResult ok() {
|
|
36
|
+
return new DispatchResult(true, CODE_OK, null);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@NonNull
|
|
40
|
+
public static DispatchResult fail(@NonNull String code) {
|
|
41
|
+
return new DispatchResult(false, code, null);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@NonNull
|
|
45
|
+
public static DispatchResult fail(@NonNull String code, @Nullable String message) {
|
|
46
|
+
return new DispatchResult(false, code, message);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@NonNull
|
|
50
|
+
public WritableMap toWritableMap() {
|
|
51
|
+
WritableMap map = Arguments.createMap();
|
|
52
|
+
map.putBoolean("ok", ok);
|
|
53
|
+
map.putString("code", code);
|
|
54
|
+
if (!TextUtils.isEmpty(message)) {
|
|
55
|
+
map.putString("message", message);
|
|
56
|
+
}
|
|
57
|
+
return map;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -17,18 +17,13 @@ import com.navigation.androidx.Style;
|
|
|
17
17
|
|
|
18
18
|
public class Garden {
|
|
19
19
|
|
|
20
|
-
private static GlobalStyle globalStyle;
|
|
21
|
-
|
|
22
20
|
static void createGlobalStyle(Bundle options) {
|
|
23
|
-
|
|
21
|
+
ReactManager.get().setGlobalStyle(new GlobalStyle(options != null ? options : new Bundle()));
|
|
24
22
|
}
|
|
25
23
|
|
|
26
24
|
@NonNull
|
|
27
25
|
static GlobalStyle getGlobalStyle() {
|
|
28
|
-
|
|
29
|
-
globalStyle = new GlobalStyle(new Bundle());
|
|
30
|
-
}
|
|
31
|
-
return globalStyle;
|
|
26
|
+
return ReactManager.get().getGlobalStyle();
|
|
32
27
|
}
|
|
33
28
|
|
|
34
29
|
private final HybridFragment fragment;
|
|
@@ -89,9 +84,14 @@ public class Garden {
|
|
|
89
84
|
|
|
90
85
|
if (readableMap.hasKey("screenBackgroundColor")) {
|
|
91
86
|
String color = readableMap.getString("screenBackgroundColor");
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
87
|
+
if (!TextUtils.isEmpty(color)) {
|
|
88
|
+
int parsedColor = Color.parseColor(color);
|
|
89
|
+
style.setScreenBackgroundColor(parsedColor);
|
|
90
|
+
View root = fragment.getView();
|
|
91
|
+
if (root != null) {
|
|
92
|
+
root.setBackground(new ColorDrawable(parsedColor));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
if (shouldUpdateStatusBar(readableMap)) {
|
|
@@ -102,8 +102,16 @@ public class Garden {
|
|
|
102
102
|
fragment.setNeedsNavigationBarAppearanceUpdate();
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
if (readableMap.hasKey("backInteractive")) {
|
|
106
|
+
fragment.setNeedsBackPressedCallbackUpdate();
|
|
107
|
+
}
|
|
108
|
+
|
|
105
109
|
Bundle options = mergeOptions(fragment.getOptions(), patches);
|
|
106
110
|
fragment.setOptions(options);
|
|
111
|
+
|
|
112
|
+
if (readableMap.hasKey("orientation")) {
|
|
113
|
+
fragment.notifyOrientationOptionsUpdated();
|
|
114
|
+
}
|
|
107
115
|
}
|
|
108
116
|
|
|
109
117
|
private boolean shouldUpdateStatusBar(@NonNull ReadableMap readableMap) {
|
|
@@ -23,9 +23,22 @@ public class GlobalStyle {
|
|
|
23
23
|
private static final String TAG = "Navigation";
|
|
24
24
|
|
|
25
25
|
private final Bundle options;
|
|
26
|
+
private final ScreenOrientation defaultOrientation;
|
|
26
27
|
|
|
27
|
-
public GlobalStyle(Bundle options) {
|
|
28
|
-
this.options = options;
|
|
28
|
+
public GlobalStyle(@Nullable Bundle options) {
|
|
29
|
+
this.options = options != null ? new Bundle(options) : new Bundle();
|
|
30
|
+
ScreenOrientation parsed = ScreenOrientation.fromString(this.options.getString("orientation"));
|
|
31
|
+
this.defaultOrientation = parsed != null ? parsed : ScreenOrientation.PORTRAIT;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@NonNull
|
|
35
|
+
public Bundle getOptions() {
|
|
36
|
+
return new Bundle(options);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@NonNull
|
|
40
|
+
public ScreenOrientation getDefaultOrientation() {
|
|
41
|
+
return defaultOrientation;
|
|
29
42
|
}
|
|
30
43
|
|
|
31
44
|
public void inflateStyle(Context context, Style style) {
|
|
@@ -14,11 +14,9 @@ import androidx.annotation.Nullable;
|
|
|
14
14
|
|
|
15
15
|
import com.facebook.react.interfaces.TaskInterface;
|
|
16
16
|
import com.facebook.react.interfaces.fabric.ReactSurface;
|
|
17
|
+
import com.facebook.react.runtime.ReactSurfaceImpl;
|
|
17
18
|
import com.facebook.react.runtime.ReactSurfaceView;
|
|
18
19
|
|
|
19
|
-
import java.lang.reflect.InvocationTargetException;
|
|
20
|
-
import java.lang.reflect.Method;
|
|
21
|
-
|
|
22
20
|
@SuppressLint("ClickableViewAccessibility")
|
|
23
21
|
public class HBDRootView extends FrameLayout {
|
|
24
22
|
|
|
@@ -142,11 +140,8 @@ public class HBDRootView extends FrameLayout {
|
|
|
142
140
|
return;
|
|
143
141
|
}
|
|
144
142
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
updateInitProps.invoke(surface, new Bundle(appProperties));
|
|
148
|
-
} catch (NoSuchMethodException | IllegalAccessException |
|
|
149
|
-
InvocationTargetException ignored) {
|
|
143
|
+
if (surface instanceof ReactSurfaceImpl surfaceImpl) {
|
|
144
|
+
surfaceImpl.updateInitProps(new Bundle(appProperties));
|
|
150
145
|
}
|
|
151
146
|
}
|
|
152
147
|
|
|
@@ -13,7 +13,10 @@ import androidx.annotation.CallSuper;
|
|
|
13
13
|
import androidx.annotation.NonNull;
|
|
14
14
|
import androidx.annotation.Nullable;
|
|
15
15
|
|
|
16
|
+
import com.facebook.react.bridge.Arguments;
|
|
16
17
|
import com.facebook.react.bridge.ReactContext;
|
|
18
|
+
import com.facebook.react.bridge.WritableMap;
|
|
19
|
+
import com.facebook.react.common.LifecycleState;
|
|
17
20
|
import com.navigation.androidx.AwesomeFragment;
|
|
18
21
|
import com.navigation.androidx.BarStyle;
|
|
19
22
|
import com.navigation.androidx.FragmentHelper;
|
|
@@ -32,6 +35,90 @@ public class HybridFragment extends AwesomeFragment {
|
|
|
32
35
|
private final ReactManager reactManager = ReactManager.get();
|
|
33
36
|
|
|
34
37
|
private Garden garden;
|
|
38
|
+
private final SceneLifecycleStateMachine lifecycleStateMachine = new SceneLifecycleStateMachine(this::onSceneLifecycleStateChanged);
|
|
39
|
+
|
|
40
|
+
@NonNull
|
|
41
|
+
public SceneLifecycleStateMachine getLifecycleStateMachine() {
|
|
42
|
+
return lifecycleStateMachine;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
protected void onSceneLifecycleStateChanged(@NonNull SceneLifecycleState prevState, @NonNull SceneLifecycleState newState) {
|
|
46
|
+
if (newState == SceneLifecycleState.VISIBLE) {
|
|
47
|
+
applySceneOrientation();
|
|
48
|
+
}
|
|
49
|
+
if (!isReactModuleRegisterCompleted() && newState != SceneLifecycleState.DESTROYED) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
emitSceneStateChange(prevState, newState);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
private void emitSceneStateChange(@NonNull SceneLifecycleState prevState, @NonNull SceneLifecycleState newState) {
|
|
56
|
+
NativeEvent nativeEvent = NativeEvent.getInstance();
|
|
57
|
+
if (nativeEvent == null) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
WritableMap payload = Arguments.createMap();
|
|
61
|
+
payload.putString("sceneId", getSceneId());
|
|
62
|
+
payload.putString("state", newState.getWireValue());
|
|
63
|
+
payload.putString("prevState", prevState.getWireValue());
|
|
64
|
+
nativeEvent.emitOnSceneStateChange(payload);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
protected boolean isNativeManagedLifecycle() {
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
protected boolean isReactContextResumed() {
|
|
72
|
+
ReactContext reactContext = getCurrentReactContext();
|
|
73
|
+
return reactContext != null && reactContext.getLifecycleState() == LifecycleState.RESUMED;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@Override
|
|
77
|
+
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
|
78
|
+
super.onViewCreated(view, savedInstanceState);
|
|
79
|
+
if (isNativeManagedLifecycle()) {
|
|
80
|
+
lifecycleStateMachine.onMount();
|
|
81
|
+
lifecycleStateMachine.onFirstRenderComplete(isResumed() && !isResumingForRedirect() && isReactContextResumed());
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@Override
|
|
86
|
+
public void onResume() {
|
|
87
|
+
super.onResume();
|
|
88
|
+
if (isResumingForRedirect()) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
applySceneOrientation();
|
|
92
|
+
if (isNativeManagedLifecycle()) {
|
|
93
|
+
lifecycleStateMachine.onHostResume(isReactContextResumed());
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@Override
|
|
98
|
+
public void onPause() {
|
|
99
|
+
super.onPause();
|
|
100
|
+
if (isNativeManagedLifecycle()) {
|
|
101
|
+
// 应用进入后台时不触发 invisible,与 ReactFragment 及 iOS 保持一致
|
|
102
|
+
lifecycleStateMachine.onHostPause(isReactContextResumed());
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
@Override
|
|
107
|
+
public void onDestroyView() {
|
|
108
|
+
super.onDestroyView();
|
|
109
|
+
if (isNativeManagedLifecycle()) {
|
|
110
|
+
lifecycleStateMachine.onUnmount();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@Nullable
|
|
115
|
+
public OrientationCoordinator getOrientationCoordinator() {
|
|
116
|
+
if (getActivity() instanceof ReactAppCompatActivity reactActivity) {
|
|
117
|
+
return reactActivity.getOrientationCoordinator();
|
|
118
|
+
}
|
|
119
|
+
ReactAppCompatActivity active = reactManager.getActiveActivity();
|
|
120
|
+
return active != null ? active.getOrientationCoordinator() : null;
|
|
121
|
+
}
|
|
35
122
|
|
|
36
123
|
@NonNull
|
|
37
124
|
public ReactManager getReactManager() {
|
|
@@ -58,6 +145,7 @@ public class HybridFragment extends AwesomeFragment {
|
|
|
58
145
|
@Override
|
|
59
146
|
public void onDestroy() {
|
|
60
147
|
super.onDestroy();
|
|
148
|
+
lifecycleStateMachine.onDestroy();
|
|
61
149
|
reactManager.watchMemory(this);
|
|
62
150
|
}
|
|
63
151
|
|
|
@@ -122,20 +210,39 @@ public class HybridFragment extends AwesomeFragment {
|
|
|
122
210
|
|
|
123
211
|
@Override
|
|
124
212
|
protected boolean isBackInteractive() {
|
|
125
|
-
|
|
213
|
+
if (garden != null) {
|
|
214
|
+
return garden.backInteractive;
|
|
215
|
+
}
|
|
216
|
+
return getOptions().getBoolean("backInteractive", true);
|
|
126
217
|
}
|
|
127
218
|
|
|
128
219
|
protected boolean shouldAnimatedTransition() {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
220
|
+
OrientationCoordinator coordinator = getOrientationCoordinator();
|
|
221
|
+
if (coordinator != null && coordinator.requiresOrientationChange(this)) {
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
132
224
|
Bundle options = getOptions();
|
|
133
225
|
return options.getBoolean("animatedTransition", true);
|
|
134
226
|
}
|
|
135
227
|
|
|
136
|
-
|
|
228
|
+
@Nullable
|
|
229
|
+
public ScreenOrientation getExplicitOrientation() {
|
|
137
230
|
Bundle options = getOptions();
|
|
138
|
-
return options.
|
|
231
|
+
return ScreenOrientation.fromString(options.getString("orientation"));
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
public void applySceneOrientation() {
|
|
235
|
+
OrientationCoordinator coordinator = getOrientationCoordinator();
|
|
236
|
+
if (coordinator != null) {
|
|
237
|
+
coordinator.applyForScene(this);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
public void notifyOrientationOptionsUpdated() {
|
|
242
|
+
OrientationCoordinator coordinator = getOrientationCoordinator();
|
|
243
|
+
if (coordinator != null) {
|
|
244
|
+
coordinator.onSceneOptionsUpdated(this);
|
|
245
|
+
}
|
|
139
246
|
}
|
|
140
247
|
|
|
141
248
|
private Bundle options;
|
|
@@ -19,10 +19,7 @@ public class HybridNavigationPackage extends BaseReactPackage {
|
|
|
19
19
|
public NativeModule getModule(@NonNull String name, @NonNull ReactApplicationContext context) {
|
|
20
20
|
return switch (name) {
|
|
21
21
|
case NativeEvent.NAME -> new NativeEvent(context);
|
|
22
|
-
case NativeNavigation.NAME ->
|
|
23
|
-
new NativeNavigation(context, ReactManager.get());
|
|
24
|
-
case NativeGarden.NAME ->
|
|
25
|
-
new NativeGarden(context, ReactManager.get());
|
|
22
|
+
case NativeNavigation.NAME -> new NativeNavigation(context, ReactManager.get());
|
|
26
23
|
default -> null;
|
|
27
24
|
};
|
|
28
25
|
}
|
|
@@ -36,28 +33,20 @@ public class HybridNavigationPackage extends BaseReactPackage {
|
|
|
36
33
|
public Map<String, ReactModuleInfo> getReactModuleInfos() {
|
|
37
34
|
Map<String, ReactModuleInfo> map = new HashMap<>();
|
|
38
35
|
map.put(NativeNavigation.NAME, new ReactModuleInfo(
|
|
39
|
-
NativeNavigation.NAME,
|
|
40
|
-
NativeNavigation.NAME,
|
|
41
|
-
false,
|
|
42
|
-
false,
|
|
43
|
-
false,
|
|
44
|
-
true
|
|
45
|
-
));
|
|
46
|
-
map.put(NativeGarden.NAME, new ReactModuleInfo(
|
|
47
|
-
NativeGarden.NAME, // name
|
|
48
|
-
NativeGarden.NAME, // className
|
|
49
|
-
false, // canOverrideExistingModule
|
|
50
|
-
false, // needsEagerInit
|
|
51
|
-
false, // isCXXModule
|
|
52
|
-
true // isTurboModule
|
|
36
|
+
NativeNavigation.NAME,
|
|
37
|
+
NativeNavigation.NAME,
|
|
38
|
+
false,
|
|
39
|
+
false,
|
|
40
|
+
false,
|
|
41
|
+
true
|
|
53
42
|
));
|
|
54
43
|
map.put(NativeEvent.NAME, new ReactModuleInfo(
|
|
55
|
-
NativeEvent.NAME,
|
|
56
|
-
NativeEvent.NAME,
|
|
57
|
-
false,
|
|
58
|
-
false,
|
|
59
|
-
false,
|
|
60
|
-
true
|
|
44
|
+
NativeEvent.NAME,
|
|
45
|
+
NativeEvent.NAME,
|
|
46
|
+
false,
|
|
47
|
+
false,
|
|
48
|
+
false,
|
|
49
|
+
true
|
|
61
50
|
));
|
|
62
51
|
return map;
|
|
63
52
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package com.reactnative.hybridnavigation;
|
|
2
2
|
|
|
3
3
|
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
4
5
|
|
|
5
6
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
6
7
|
import com.facebook.react.bridge.ReactContext;
|
|
@@ -21,10 +22,13 @@ public class NativeEvent extends NativeEventSpec {
|
|
|
21
22
|
return NAME;
|
|
22
23
|
}
|
|
23
24
|
|
|
25
|
+
@Nullable
|
|
24
26
|
public static NativeEvent getInstance() {
|
|
25
27
|
ReactManager reactManager = ReactManager.get();
|
|
26
28
|
ReactContext reactContext = reactManager.getCurrentReactContext();
|
|
27
|
-
|
|
29
|
+
if (reactContext == null) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
28
32
|
return reactContext.getNativeModule(NativeEvent.class);
|
|
29
33
|
}
|
|
30
34
|
|