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
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
package com.navigation.androidx;
|
|
2
|
-
|
|
3
|
-
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS;
|
|
4
|
-
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;
|
|
5
|
-
|
|
6
|
-
import android.view.View;
|
|
7
|
-
import android.view.Window;
|
|
8
|
-
import android.view.WindowInsets;
|
|
9
|
-
import android.view.WindowInsetsController;
|
|
10
|
-
|
|
11
|
-
import androidx.annotation.NonNull;
|
|
12
|
-
import androidx.annotation.RequiresApi;
|
|
13
|
-
|
|
14
|
-
@RequiresApi(30)
|
|
15
|
-
public class SystemUI30 {
|
|
16
|
-
|
|
17
|
-
public static void enableEdgeToEdge(@NonNull Window window) {
|
|
18
|
-
window.setDecorFitsSystemWindows(false);
|
|
19
|
-
|
|
20
|
-
View decorView = window.getDecorView();
|
|
21
|
-
WindowInsetsController controller = decorView.getWindowInsetsController();
|
|
22
|
-
assert controller != null;
|
|
23
|
-
controller.setSystemBarsBehavior(WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public static void setStatusBarStyle(@NonNull Window window, boolean dark) {
|
|
27
|
-
WindowInsetsController controller = window.getDecorView().getWindowInsetsController();
|
|
28
|
-
assert controller != null;
|
|
29
|
-
controller.setSystemBarsAppearance(dark ? APPEARANCE_LIGHT_STATUS_BARS : 0, APPEARANCE_LIGHT_STATUS_BARS);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
public static boolean isStatusBarStyleDark(@NonNull Window window) {
|
|
33
|
-
WindowInsetsController controller = window.getDecorView().getWindowInsetsController();
|
|
34
|
-
assert controller != null;
|
|
35
|
-
return (controller.getSystemBarsAppearance() & APPEARANCE_LIGHT_STATUS_BARS) != 0;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
public static void setStatusBarHidden(@NonNull Window window, boolean hidden) {
|
|
39
|
-
WindowInsetsController controller = window.getDecorView().getWindowInsetsController();
|
|
40
|
-
assert controller != null;
|
|
41
|
-
if (hidden) {
|
|
42
|
-
controller.hide(WindowInsets.Type.statusBars());
|
|
43
|
-
} else {
|
|
44
|
-
controller.show(WindowInsets.Type.statusBars());
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
public static boolean isStatusBarHidden(@NonNull Window window) {
|
|
49
|
-
View decorView = window.getDecorView();
|
|
50
|
-
WindowInsets insets = decorView.getRootWindowInsets();
|
|
51
|
-
if (insets == null) {
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
return !insets.isVisible(WindowInsets.Type.statusBars());
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
public static void setNavigationBarStyle(Window window, boolean dark) {
|
|
58
|
-
WindowInsetsController controller = window.getDecorView().getWindowInsetsController();
|
|
59
|
-
assert controller != null;
|
|
60
|
-
controller.setSystemBarsAppearance(dark ? APPEARANCE_LIGHT_NAVIGATION_BARS : 0, APPEARANCE_LIGHT_NAVIGATION_BARS);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
public static boolean isNavigationBarStyleDark(Window window) {
|
|
64
|
-
WindowInsetsController controller = window.getDecorView().getWindowInsetsController();
|
|
65
|
-
assert controller != null;
|
|
66
|
-
return (controller.getSystemBarsAppearance() & APPEARANCE_LIGHT_NAVIGATION_BARS) != 0;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
public static void setNavigationBarHidden(Window window, boolean hidden) {
|
|
70
|
-
WindowInsetsController controller = window.getDecorView().getWindowInsetsController();
|
|
71
|
-
assert controller != null;
|
|
72
|
-
if (hidden) {
|
|
73
|
-
controller.hide(WindowInsets.Type.navigationBars());
|
|
74
|
-
} else {
|
|
75
|
-
controller.show(WindowInsets.Type.navigationBars());
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
public static boolean isNavigationBarHidden(Window window) {
|
|
80
|
-
View decorView = window.getDecorView();
|
|
81
|
-
WindowInsets insets = decorView.getRootWindowInsets();
|
|
82
|
-
if (insets == null) {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
return !insets.isVisible(WindowInsets.Type.navigationBars());
|
|
86
|
-
}
|
|
87
|
-
}
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
package com.reactnative.hybridnavigation;
|
|
2
|
-
|
|
3
|
-
import static com.reactnative.hybridnavigation.Constants.ACTION_SET_TAB_ITEM;
|
|
4
|
-
import static com.reactnative.hybridnavigation.Constants.ACTION_UPDATE_TAB_BAR;
|
|
5
|
-
import static com.reactnative.hybridnavigation.Constants.ARG_ACTION;
|
|
6
|
-
import static com.reactnative.hybridnavigation.Constants.ARG_OPTIONS;
|
|
7
|
-
import static com.reactnative.hybridnavigation.Parameters.toBundle;
|
|
8
|
-
import static com.reactnative.hybridnavigation.Parameters.toList;
|
|
9
|
-
|
|
10
|
-
import android.app.Activity;
|
|
11
|
-
import android.os.Bundle;
|
|
12
|
-
|
|
13
|
-
import androidx.annotation.NonNull;
|
|
14
|
-
import androidx.annotation.Nullable;
|
|
15
|
-
import androidx.fragment.app.FragmentManager;
|
|
16
|
-
|
|
17
|
-
import com.facebook.common.logging.FLog;
|
|
18
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
19
|
-
import com.facebook.react.bridge.ReactContext;
|
|
20
|
-
import com.facebook.react.bridge.ReadableArray;
|
|
21
|
-
import com.facebook.react.bridge.ReadableMap;
|
|
22
|
-
import com.facebook.react.bridge.UiThreadUtil;
|
|
23
|
-
import com.facebook.react.module.annotations.ReactModule;
|
|
24
|
-
import com.navigation.androidx.AwesomeFragment;
|
|
25
|
-
import com.navigation.androidx.DrawerFragment;
|
|
26
|
-
import com.navigation.androidx.FragmentHelper;
|
|
27
|
-
import com.navigation.androidx.TabBarFragment;
|
|
28
|
-
|
|
29
|
-
import java.util.HashMap;
|
|
30
|
-
import java.util.Map;
|
|
31
|
-
|
|
32
|
-
@ReactModule(name = NativeGarden.NAME)
|
|
33
|
-
public class NativeGarden extends NativeGardenSpec {
|
|
34
|
-
private static final String TAG = "Navigation";
|
|
35
|
-
public static final String NAME = "HBDNativeGarden";
|
|
36
|
-
private final ReactManager reactManager;
|
|
37
|
-
|
|
38
|
-
public NativeGarden(ReactApplicationContext reactContext, ReactManager reactManager) {
|
|
39
|
-
super(reactContext);
|
|
40
|
-
this.reactManager = reactManager;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
@Override
|
|
44
|
-
@NonNull
|
|
45
|
-
public String getName() {
|
|
46
|
-
return NAME;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
@Override
|
|
50
|
-
protected Map<String, Object> getTypedExportedConstants() {
|
|
51
|
-
final Map<String, Object> constants = new HashMap<>();
|
|
52
|
-
constants.put("TOOLBAR_HEIGHT", 56);
|
|
53
|
-
return constants;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
@Override
|
|
57
|
-
public void setStyle(ReadableMap style) {
|
|
58
|
-
UiThreadUtil.runOnUiThread(() -> {
|
|
59
|
-
FLog.i(TAG, "GardenModule#setStyle");
|
|
60
|
-
Garden.createGlobalStyle(toBundle(style));
|
|
61
|
-
|
|
62
|
-
ReactAppCompatActivity activity = getActiveActivity();
|
|
63
|
-
if (activity != null) {
|
|
64
|
-
activity.inflateStyle();
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
@Override
|
|
70
|
-
public void updateOptions(String sceneId, ReadableMap options) {
|
|
71
|
-
FLog.i(TAG, "update options:" + options);
|
|
72
|
-
UiThreadUtil.runOnUiThread(() -> {
|
|
73
|
-
HybridFragment fragment = findHybridFragmentBySceneId(sceneId);
|
|
74
|
-
if (fragment != null) {
|
|
75
|
-
fragment.getGarden().updateOptions(options);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
@Override
|
|
81
|
-
public void updateTabBar(String sceneId, ReadableMap item) {
|
|
82
|
-
FLog.i(TAG, "updateTabBar:" + item);
|
|
83
|
-
UiThreadUtil.runOnUiThread(() -> {
|
|
84
|
-
TabBarFragment tabBarFragment = getTabBarFragment(sceneId);
|
|
85
|
-
if (tabBarFragment == null) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
Bundle bundle = new Bundle();
|
|
90
|
-
bundle.putString(ARG_ACTION, ACTION_UPDATE_TAB_BAR);
|
|
91
|
-
bundle.putBundle(ARG_OPTIONS, toBundle(item));
|
|
92
|
-
tabBarFragment.updateTabBar(bundle);
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
@Override
|
|
97
|
-
public void setTabItem(String sceneId, ReadableArray options) {
|
|
98
|
-
FLog.i(TAG, "setTabItem:" + options);
|
|
99
|
-
UiThreadUtil.runOnUiThread(() -> {
|
|
100
|
-
TabBarFragment tabBarFragment = getTabBarFragment(sceneId);
|
|
101
|
-
if (tabBarFragment == null) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
Bundle bundle = new Bundle();
|
|
106
|
-
bundle.putString(ARG_ACTION, ACTION_SET_TAB_ITEM);
|
|
107
|
-
bundle.putSerializable(ARG_OPTIONS, toList(options));
|
|
108
|
-
tabBarFragment.updateTabBar(bundle);
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
@Override
|
|
113
|
-
public void setMenuInteractive(String sceneId, boolean enabled) {
|
|
114
|
-
UiThreadUtil.runOnUiThread(() -> {
|
|
115
|
-
AwesomeFragment fragment = findFragmentBySceneId(sceneId);
|
|
116
|
-
if (fragment == null) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
DrawerFragment drawerFragment = fragment.getDrawerFragment();
|
|
121
|
-
if (drawerFragment == null) {
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
drawerFragment.setMenuInteractive(enabled);
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
@Nullable
|
|
130
|
-
private ReactAppCompatActivity getActiveActivity() {
|
|
131
|
-
ReactContext reactContext = getReactApplicationContext();
|
|
132
|
-
if (!reactContext.hasActiveReactInstance()) {
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
Activity activity = reactContext.getCurrentActivity();
|
|
137
|
-
if (activity instanceof ReactAppCompatActivity) {
|
|
138
|
-
return (ReactAppCompatActivity) activity;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return null;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
private HybridFragment findHybridFragmentBySceneId(String sceneId) {
|
|
145
|
-
AwesomeFragment fragment = findFragmentBySceneId(sceneId);
|
|
146
|
-
if (fragment instanceof HybridFragment) {
|
|
147
|
-
return (HybridFragment) fragment;
|
|
148
|
-
}
|
|
149
|
-
return null;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
private AwesomeFragment findFragmentBySceneId(String sceneId) {
|
|
153
|
-
if (!reactManager.isViewHierarchyReady()) {
|
|
154
|
-
FLog.w(TAG, "View hierarchy is not ready now.");
|
|
155
|
-
return null;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
ReactAppCompatActivity activity = getActiveActivity();
|
|
159
|
-
if (activity == null) {
|
|
160
|
-
return null;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
FragmentManager fragmentManager = activity.getSupportFragmentManager();
|
|
164
|
-
return FragmentHelper.findAwesomeFragment(fragmentManager, sceneId);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
@Nullable
|
|
168
|
-
private TabBarFragment getTabBarFragment(String sceneId) {
|
|
169
|
-
AwesomeFragment fragment = findFragmentBySceneId(sceneId);
|
|
170
|
-
if (fragment != null) {
|
|
171
|
-
return fragment.getTabBarFragment();
|
|
172
|
-
}
|
|
173
|
-
return null;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
package com.reactnative.hybridnavigation;
|
|
2
|
-
|
|
3
|
-
import android.content.Context;
|
|
4
|
-
import android.graphics.Color;
|
|
5
|
-
import android.graphics.drawable.ColorDrawable;
|
|
6
|
-
import android.graphics.drawable.Drawable;
|
|
7
|
-
import android.util.AttributeSet;
|
|
8
|
-
import android.view.LayoutInflater;
|
|
9
|
-
import android.view.View;
|
|
10
|
-
import android.view.ViewGroup;
|
|
11
|
-
import android.widget.FrameLayout;
|
|
12
|
-
|
|
13
|
-
import androidx.annotation.Nullable;
|
|
14
|
-
|
|
15
|
-
import com.facebook.common.logging.FLog;
|
|
16
|
-
|
|
17
|
-
public class ReactTabBar extends FrameLayout {
|
|
18
|
-
|
|
19
|
-
protected static final String TAG = "Navigation";
|
|
20
|
-
|
|
21
|
-
private Drawable shadow = new ColorDrawable(Color.parseColor("#EEEEEE"));
|
|
22
|
-
private final Drawable background = new ColorDrawable(Color.WHITE);
|
|
23
|
-
|
|
24
|
-
private FrameLayout mReactHolderView;
|
|
25
|
-
private View mDivider;
|
|
26
|
-
private boolean mSizeIndeterminate;
|
|
27
|
-
private FrameLayout mBackgroundView;
|
|
28
|
-
|
|
29
|
-
private ViewGroup mReactRootView;
|
|
30
|
-
|
|
31
|
-
public ReactTabBar(Context context) {
|
|
32
|
-
super(context);
|
|
33
|
-
init();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
public ReactTabBar(Context context, boolean sizeIndeterminate) {
|
|
37
|
-
super(context);
|
|
38
|
-
mSizeIndeterminate = sizeIndeterminate;
|
|
39
|
-
init();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
public ReactTabBar(Context context, AttributeSet attrs) {
|
|
43
|
-
this(context, attrs, 0);
|
|
44
|
-
init();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
public ReactTabBar(Context context, AttributeSet attrs, int defStyleAttr) {
|
|
48
|
-
super(context, attrs, defStyleAttr);
|
|
49
|
-
init();
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
public ReactTabBar(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
|
53
|
-
super(context, attrs, defStyleAttr, defStyleRes);
|
|
54
|
-
init();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
private void init() {
|
|
58
|
-
setLayoutParams(new ViewGroup.LayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)));
|
|
59
|
-
LayoutInflater inflater = LayoutInflater.from(getContext());
|
|
60
|
-
int layout = mSizeIndeterminate ? R.layout.nav_tab_bar_react_indeterminate : R.layout.nav_tab_bar_react;
|
|
61
|
-
View parentView = inflater.inflate(layout, this, true);
|
|
62
|
-
mBackgroundView = parentView.findViewById(R.id.bottom_navigation_bar_background);
|
|
63
|
-
mReactHolderView = parentView.findViewById(R.id.bottom_navigation_bar_react_holder);
|
|
64
|
-
mDivider = parentView.findViewById(R.id.bottom_navigation_bar_divider);
|
|
65
|
-
mDivider.setBackground(shadow);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
public void setShadow(@Nullable Drawable drawable) {
|
|
69
|
-
shadow = drawable;
|
|
70
|
-
if (mDivider != null) {
|
|
71
|
-
mDivider.setBackground(drawable);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
@Override
|
|
76
|
-
public void setPadding(int left, int top, int right, int bottom) {
|
|
77
|
-
mBackgroundView.setPadding(left, top, right, bottom);
|
|
78
|
-
if (mSizeIndeterminate) {
|
|
79
|
-
mReactHolderView.setPadding(left, top, right, bottom);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
public void setRootView(View rootView) {
|
|
84
|
-
mReactHolderView.addView(rootView);
|
|
85
|
-
mReactRootView = (ViewGroup) rootView;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
@Override
|
|
89
|
-
protected void onDetachedFromWindow() {
|
|
90
|
-
super.onDetachedFromWindow();
|
|
91
|
-
mReactHolderView.removeAllViews();
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
@Override
|
|
95
|
-
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
96
|
-
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
97
|
-
|
|
98
|
-
ViewGroup.LayoutParams params = mReactRootView.getLayoutParams();
|
|
99
|
-
if (params.height > 0) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
int height = getReactIntrinsicHeight();
|
|
104
|
-
FLog.i(TAG, "[ReactTabBar] intrinsic height:" + height);
|
|
105
|
-
if (height > 0) {
|
|
106
|
-
params.height = height;
|
|
107
|
-
post(mReactRootView::requestLayout);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
private int getReactIntrinsicHeight() {
|
|
112
|
-
int rootViewHeight = mReactRootView.getMeasuredHeight();
|
|
113
|
-
if (mReactRootView.getChildCount() > 1 || mReactHolderView.getLayoutParams().height > 0) {
|
|
114
|
-
return rootViewHeight;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
ViewGroup group = mReactRootView;
|
|
118
|
-
while (group.getMeasuredHeight() == rootViewHeight) {
|
|
119
|
-
if (group.getChildCount() == 0) {
|
|
120
|
-
return 0;
|
|
121
|
-
}
|
|
122
|
-
group = (ViewGroup) group.getChildAt(0);
|
|
123
|
-
if (group.getMeasuredHeight() < rootViewHeight) {
|
|
124
|
-
return group.getMeasuredHeight();
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return rootViewHeight;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
|
-
android:id="@+id/bottom_navigation_bar_container"
|
|
4
|
-
android:layout_width="match_parent"
|
|
5
|
-
android:layout_height="wrap_content">
|
|
6
|
-
|
|
7
|
-
<FrameLayout
|
|
8
|
-
android:id="@+id/bottom_navigation_bar_background"
|
|
9
|
-
android:layout_width="match_parent"
|
|
10
|
-
android:layout_height="wrap_content"
|
|
11
|
-
android:layout_gravity="bottom">
|
|
12
|
-
|
|
13
|
-
<View
|
|
14
|
-
android:id="@+id/bottom_navigation_bar_divider"
|
|
15
|
-
android:layout_width="match_parent"
|
|
16
|
-
android:layout_height="1dp"
|
|
17
|
-
android:layout_gravity="top" />
|
|
18
|
-
|
|
19
|
-
<View
|
|
20
|
-
android:layout_width="match_parent"
|
|
21
|
-
android:layout_height="@dimen/nav_tab_bar_height"
|
|
22
|
-
android:layout_gravity="bottom" />
|
|
23
|
-
|
|
24
|
-
</FrameLayout>
|
|
25
|
-
|
|
26
|
-
<FrameLayout
|
|
27
|
-
android:id="@+id/bottom_navigation_bar_react_holder"
|
|
28
|
-
android:layout_width="match_parent"
|
|
29
|
-
android:layout_height="@dimen/nav_tab_bar_height"
|
|
30
|
-
android:layout_gravity="top" />
|
|
31
|
-
|
|
32
|
-
</FrameLayout>
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
|
-
android:id="@+id/bottom_navigation_bar_container"
|
|
4
|
-
android:layout_width="match_parent"
|
|
5
|
-
android:layout_height="wrap_content">
|
|
6
|
-
|
|
7
|
-
<FrameLayout
|
|
8
|
-
android:id="@+id/bottom_navigation_bar_background"
|
|
9
|
-
android:layout_width="match_parent"
|
|
10
|
-
android:layout_height="wrap_content"
|
|
11
|
-
android:layout_gravity="bottom">
|
|
12
|
-
|
|
13
|
-
<View
|
|
14
|
-
android:id="@+id/bottom_navigation_bar_divider"
|
|
15
|
-
android:layout_width="match_parent"
|
|
16
|
-
android:layout_height="1dp"
|
|
17
|
-
android:layout_gravity="top" />
|
|
18
|
-
|
|
19
|
-
<View
|
|
20
|
-
android:layout_width="match_parent"
|
|
21
|
-
android:layout_height="@dimen/nav_tab_bar_height"
|
|
22
|
-
android:layout_gravity="bottom" />
|
|
23
|
-
|
|
24
|
-
</FrameLayout>
|
|
25
|
-
|
|
26
|
-
<FrameLayout
|
|
27
|
-
android:id="@+id/bottom_navigation_bar_react_holder"
|
|
28
|
-
android:layout_width="match_parent"
|
|
29
|
-
android:layout_height="wrap_content"
|
|
30
|
-
android:layout_gravity="top" />
|
|
31
|
-
|
|
32
|
-
</FrameLayout>
|
package/dist/NativeGarden.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { CodegenTypes, TurboModule } from 'react-native';
|
|
2
|
-
export interface Spec extends TurboModule {
|
|
3
|
-
getConstants: () => {
|
|
4
|
-
TOOLBAR_HEIGHT: number;
|
|
5
|
-
};
|
|
6
|
-
setStyle: (style: CodegenTypes.UnsafeObject) => void;
|
|
7
|
-
updateOptions: (sceneId: string, options: CodegenTypes.UnsafeObject) => void;
|
|
8
|
-
updateTabBar: (sceneId: string, item: CodegenTypes.UnsafeObject) => void;
|
|
9
|
-
setTabItem: (sceneId: string, item: Array<CodegenTypes.UnsafeObject>) => void;
|
|
10
|
-
setMenuInteractive: (sceneId: string, enabled: boolean) => void;
|
|
11
|
-
}
|
|
12
|
-
declare const _default: Spec;
|
|
13
|
-
export default _default;
|
package/dist/NativeGarden.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Visibility } from '../Route';
|
|
2
|
-
export type VisibilityEventListener = (visibility: Visibility) => void;
|
|
3
|
-
export type GlobalVisibilityEventListener = (sceneId: string, visibility: Visibility) => void;
|
|
4
|
-
export default class VisibilityEventHandler {
|
|
5
|
-
private listeners;
|
|
6
|
-
private globalListeners;
|
|
7
|
-
constructor();
|
|
8
|
-
handleComponentVisibility(): void;
|
|
9
|
-
addGlobalVisibilityEventListener(listener: GlobalVisibilityEventListener): void;
|
|
10
|
-
removeGlobalVisibilityEventListener(listener: GlobalVisibilityEventListener): void;
|
|
11
|
-
addVisibilityEventListener(sceneId: string, listener: VisibilityEventListener): void;
|
|
12
|
-
removeVisibilityEventListener(sceneId: string, listener: VisibilityEventListener): void;
|
|
13
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import NativeEvent from '../NativeEvent';
|
|
2
|
-
export default class VisibilityEventHandler {
|
|
3
|
-
listeners = {};
|
|
4
|
-
globalListeners = [];
|
|
5
|
-
constructor() { }
|
|
6
|
-
handleComponentVisibility() {
|
|
7
|
-
NativeEvent.onComponentAppear(({ sceneId }) => {
|
|
8
|
-
const listeners = this.listeners[sceneId];
|
|
9
|
-
if (listeners) {
|
|
10
|
-
listeners.forEach(listener => listener('visible'));
|
|
11
|
-
}
|
|
12
|
-
this.globalListeners.forEach(listener => listener(sceneId, 'visible'));
|
|
13
|
-
});
|
|
14
|
-
NativeEvent.onComponentDisappear(({ sceneId }) => {
|
|
15
|
-
const listeners = this.listeners[sceneId];
|
|
16
|
-
if (listeners) {
|
|
17
|
-
listeners.forEach(listener => listener('invisible'));
|
|
18
|
-
}
|
|
19
|
-
this.globalListeners.forEach(listener => listener(sceneId, 'invisible'));
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
addGlobalVisibilityEventListener(listener) {
|
|
23
|
-
this.globalListeners.push(listener);
|
|
24
|
-
}
|
|
25
|
-
removeGlobalVisibilityEventListener(listener) {
|
|
26
|
-
this.globalListeners = this.globalListeners.filter(l => l !== listener);
|
|
27
|
-
}
|
|
28
|
-
addVisibilityEventListener(sceneId, listener) {
|
|
29
|
-
if (!this.listeners[sceneId]) {
|
|
30
|
-
this.listeners[sceneId] = [];
|
|
31
|
-
}
|
|
32
|
-
this.listeners[sceneId].push(listener);
|
|
33
|
-
}
|
|
34
|
-
removeVisibilityEventListener(sceneId, listener) {
|
|
35
|
-
if (this.listeners[sceneId]) {
|
|
36
|
-
this.listeners[sceneId] = this.listeners[sceneId].filter(l => l !== listener);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
package/ios/GlobalStyle.h
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
#import <UIKit/UIKit.h>
|
|
2
|
-
|
|
3
|
-
@interface GlobalStyle : NSObject
|
|
4
|
-
|
|
5
|
-
+ (void)createWithOptions:(NSDictionary *)options;
|
|
6
|
-
|
|
7
|
-
+ (GlobalStyle *)globalStyle;
|
|
8
|
-
|
|
9
|
-
@property(nonatomic, strong, readonly) UIColor *screenBackgroundColor;
|
|
10
|
-
@property(nonatomic, assign, readonly) UIBarStyle statusBarStyle;
|
|
11
|
-
@property(nonatomic, assign) UIInterfaceOrientationMask interfaceOrientation;
|
|
12
|
-
|
|
13
|
-
- (instancetype)initWithOptions:(NSDictionary *)options;
|
|
14
|
-
|
|
15
|
-
@end
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
#import "HBDNativeGarden.h"
|
|
2
|
-
|
|
3
|
-
#import "HBDReactBridgeManager.h"
|
|
4
|
-
#import "HBDTabBarController.h"
|
|
5
|
-
#import "GlobalStyle.h"
|
|
6
|
-
#import "HBDUtils.h"
|
|
7
|
-
|
|
8
|
-
#import <React/RCTLog.h>
|
|
9
|
-
|
|
10
|
-
@interface HBDNativeGarden ()
|
|
11
|
-
|
|
12
|
-
@property(nonatomic, strong, readonly) HBDReactBridgeManager *bridgeManager;
|
|
13
|
-
|
|
14
|
-
@end
|
|
15
|
-
|
|
16
|
-
@implementation HBDNativeGarden
|
|
17
|
-
|
|
18
|
-
+ (NSString *)moduleName {
|
|
19
|
-
return @"HBDNativeGarden";
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
+ (BOOL)requiresMainQueueSetup {
|
|
23
|
-
return YES;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
- (dispatch_queue_t)methodQueue {
|
|
27
|
-
return dispatch_get_main_queue();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
- (instancetype)init {
|
|
31
|
-
if (self = [super init]) {
|
|
32
|
-
_bridgeManager = [HBDReactBridgeManager get];
|
|
33
|
-
}
|
|
34
|
-
return self;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const facebook::react::ObjCTurboModule::InitParams &)params {
|
|
38
|
-
return std::make_shared<facebook::react::NativeGardenSpecJSI>(params);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
- (nonnull facebook::react::ModuleConstants<JS::NativeGarden::Constants::Builder>)constantsToExport {
|
|
42
|
-
JS::NativeGarden::Constants::Builder::Input input = {
|
|
43
|
-
44
|
|
44
|
-
};
|
|
45
|
-
return facebook::react::typedConstants<JS::NativeGarden::Constants::Builder>(std::move(input));
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
- (nonnull facebook::react::ModuleConstants<JS::NativeGarden::Constants::Builder>)getConstants {
|
|
49
|
-
return [self constantsToExport];
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
- (void)setMenuInteractive:(nonnull NSString *)sceneId enabled:(BOOL)enabled {
|
|
53
|
-
UIViewController *vc = [self.bridgeManager viewControllerBySceneId:sceneId];
|
|
54
|
-
HBDDrawerController *drawer = [vc drawerController];
|
|
55
|
-
if (drawer) {
|
|
56
|
-
drawer.menuInteractive = enabled;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
- (void)setStyle:(nonnull NSDictionary *)style {
|
|
62
|
-
[GlobalStyle createWithOptions:style];
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
- (void)setTabItem:(nonnull NSString *)sceneId item:(nonnull NSArray *)item {
|
|
67
|
-
RCTLogInfo(@"[Navigation] setTabItem: %@", item);
|
|
68
|
-
UIViewController *vc = [self.bridgeManager viewControllerBySceneId:sceneId];
|
|
69
|
-
UITabBarController *tabBarController = [self tabBarControllerWithViewController:vc];
|
|
70
|
-
if ([tabBarController isKindOfClass:[HBDTabBarController class]]) {
|
|
71
|
-
HBDTabBarController *tabBarVC = (HBDTabBarController *)tabBarController;
|
|
72
|
-
[tabBarVC setTabItem:item];
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
- (void)updateOptions:(nonnull NSString *)sceneId options:(nonnull NSDictionary *)options {
|
|
78
|
-
RCTLogInfo(@"[Navigation] updateNavigationBarOptions: %@", options);
|
|
79
|
-
HBDViewController *vc = [self viewControllerWithSceneId:sceneId];
|
|
80
|
-
if (vc) {
|
|
81
|
-
[vc updateNavigationBarOptions:options];
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
- (void)updateTabBar:(nonnull NSString *)sceneId item:(nonnull NSDictionary *)item {
|
|
87
|
-
RCTLogInfo(@"[Navigation] updateTabBar: %@", item);
|
|
88
|
-
UIViewController *vc = [self.bridgeManager viewControllerBySceneId:sceneId];
|
|
89
|
-
UITabBarController *tabBarVC = [self tabBarControllerWithViewController:vc];
|
|
90
|
-
if (tabBarVC && [tabBarVC isKindOfClass:[HBDTabBarController class]]) {
|
|
91
|
-
[((HBDTabBarController *)tabBarVC) updateTabBar:item];
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
- (HBDViewController *)viewControllerWithSceneId:(NSString *)sceneId {
|
|
96
|
-
UIViewController *vc = [self.bridgeManager viewControllerBySceneId:sceneId];
|
|
97
|
-
if ([vc isKindOfClass:[HBDViewController class]]) {
|
|
98
|
-
return (HBDViewController *)vc;
|
|
99
|
-
}
|
|
100
|
-
return nil;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
- (UITabBarController *)tabBarControllerWithViewController:(UIViewController *)vc {
|
|
104
|
-
if ([vc isKindOfClass:[UITabBarController class]]) {
|
|
105
|
-
return (UITabBarController *)vc;
|
|
106
|
-
} else {
|
|
107
|
-
return vc.tabBarController;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
@end
|
package/src/NativeGarden.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { TurboModuleRegistry } from 'react-native';
|
|
2
|
-
import type { CodegenTypes, TurboModule } from 'react-native';
|
|
3
|
-
|
|
4
|
-
export interface Spec extends TurboModule {
|
|
5
|
-
getConstants: () => {
|
|
6
|
-
TOOLBAR_HEIGHT: number;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
setStyle: (style: CodegenTypes.UnsafeObject) => void;
|
|
10
|
-
updateOptions: (sceneId: string, options: CodegenTypes.UnsafeObject) => void;
|
|
11
|
-
updateTabBar: (sceneId: string, item: CodegenTypes.UnsafeObject) => void;
|
|
12
|
-
setTabItem: (sceneId: string, item: Array<CodegenTypes.UnsafeObject>) => void;
|
|
13
|
-
setMenuInteractive: (sceneId: string, enabled: boolean) => void;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export default TurboModuleRegistry.getEnforcing<Spec>('HBDNativeGarden');
|