hybrid-navigation 4.1.0 → 5.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/HybridNavigation.podspec +9 -1
- package/README.md +12 -4
- package/android/build.gradle +4 -4
- package/android/proguard-rules.pro +0 -14
- package/android/src/main/java/com/navigation/androidx/AwesomeActivity.java +116 -27
- package/android/src/main/java/com/navigation/androidx/AwesomeFragment.java +162 -13
- package/android/src/main/java/com/navigation/androidx/DefaultTabBarProvider.java +2 -2
- package/android/src/main/java/com/navigation/androidx/DrawableUtils.java +83 -18
- package/android/src/main/java/com/navigation/androidx/DrawerFragment.java +185 -25
- package/android/src/main/java/com/navigation/androidx/FragmentHelper.java +18 -0
- package/android/src/main/java/com/navigation/androidx/HybridDrawerLayout.java +563 -143
- package/android/src/main/java/com/navigation/androidx/LifecycleDelegate.java +39 -12
- package/android/src/main/java/com/navigation/androidx/PresentableActivity.java +3 -0
- package/android/src/main/java/com/navigation/androidx/PresentationDelegate.java +10 -7
- package/android/src/main/java/com/navigation/androidx/StackDelegate.java +29 -9
- package/android/src/main/java/com/navigation/androidx/StackFragment.java +31 -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 +74 -7
- package/android/src/main/java/com/navigation/androidx/TabBarItem.java +4 -0
- package/android/src/main/java/com/navigation/androidx/TabView.java +11 -2
- package/android/src/main/java/com/reactnative/hybridnavigation/DispatchResult.java +71 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/Garden.java +18 -10
- package/android/src/main/java/com/reactnative/hybridnavigation/GlobalStyle.java +34 -2
- package/android/src/main/java/com/reactnative/hybridnavigation/HBDRootView.java +20 -10
- package/android/src/main/java/com/reactnative/hybridnavigation/HybridFragment.java +179 -13
- 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 +283 -183
- package/android/src/main/java/com/reactnative/hybridnavigation/NavigationCommandQueue.java +507 -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 +421 -92
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactManager.java +227 -78
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactStackFragment.java +6 -6
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarFragment.java +26 -0
- 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 +188 -26
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/StackNavigator.java +67 -16
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/TabNavigator.java +42 -14
- package/dist/DeepLink.d.ts +3 -2
- package/dist/DeepLink.js +37 -14
- package/dist/NativeEvent.d.ts +17 -10
- package/dist/NativeNavigation.d.ts +24 -18
- package/dist/Navigation.d.ts +34 -19
- package/dist/Navigation.js +225 -90
- package/dist/NavigationComponentWrap.d.ts +5 -3
- package/dist/NavigationComponentWrap.js +3 -6
- package/dist/Navigator.d.ts +32 -42
- package/dist/Navigator.js +117 -91
- package/dist/Options.d.ts +15 -3
- package/dist/Route.d.ts +149 -17
- package/dist/defineRoutes.d.ts +19 -0
- package/dist/defineRoutes.js +6 -0
- package/dist/handler/DispatchCommandHandler.d.ts +25 -6
- package/dist/handler/DispatchCommandHandler.js +99 -17
- package/dist/handler/LayoutCommandHandler.d.ts +8 -7
- package/dist/handler/LayoutCommandHandler.js +24 -15
- package/dist/handler/LeaveGuardHandler.d.ts +17 -0
- package/dist/handler/LeaveGuardHandler.js +350 -0
- package/dist/handler/LifecycleEventHandler.d.ts +30 -0
- package/dist/handler/LifecycleEventHandler.js +169 -0
- package/dist/handler/PresentationCoordinator.d.ts +24 -0
- package/dist/handler/PresentationCoordinator.js +449 -0
- package/dist/handler/ResultEventHandler.d.ts +21 -9
- package/dist/handler/ResultEventHandler.js +96 -13
- package/dist/handler/TabEventHandler.d.ts +8 -0
- package/dist/handler/TabEventHandler.js +25 -0
- package/dist/hooks.d.ts +7 -2
- package/dist/hooks.js +46 -4
- package/dist/index.d.ts +24 -0
- package/dist/index.js +3 -2
- package/dist/reveal.d.ts +46 -0
- package/dist/reveal.js +431 -0
- package/dist/routeConfigRegistry.d.ts +6 -0
- package/dist/routeConfigRegistry.js +19 -0
- package/dist/routeGraph.d.ts +12 -0
- package/dist/routeGraph.js +68 -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 +106 -58
- 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 +3 -2
- package/dist/router/tabs.js +4 -1
- package/dist/store.d.ts +4 -2
- package/dist/store.js +4 -0
- package/dist/testing.d.ts +79 -0
- package/dist/testing.js +251 -0
- package/ios/HBDGlobalStyle.h +29 -0
- package/ios/{GlobalStyle.mm → HBDGlobalStyle.mm} +43 -29
- package/ios/HybridNavigation.h +5 -1
- package/ios/Navigator/HBDDrawerNavigator.mm +24 -8
- package/ios/Navigator/HBDNavigatorRegistry.mm +1 -0
- package/ios/Navigator/HBDScreenNavigator.mm +278 -58
- package/ios/Navigator/HBDStackNavigator.mm +152 -61
- package/ios/Navigator/HBDTabNavigator.mm +60 -14
- package/ios/React/HBDNativeNavigation.mm +162 -123
- package/ios/React/HBDNavigator.h +37 -5
- package/ios/React/HBDOrientationCoordinator.h +29 -0
- package/ios/React/HBDOrientationCoordinator.mm +309 -0
- package/ios/React/HBDReactBridgeManager.h +46 -20
- package/ios/React/HBDReactBridgeManager.mm +496 -108
- 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 +126 -5
- package/ios/ViewController/HBDNavigationController.mm +31 -4
- package/ios/ViewController/HBDReactViewController.h +6 -0
- package/ios/ViewController/HBDReactViewController.mm +220 -106
- package/ios/ViewController/HBDTabBarController.h +15 -0
- package/ios/ViewController/HBDTabBarController.mm +227 -45
- package/ios/ViewController/HBDTabBarRenderer.h +28 -0
- package/ios/ViewController/HBDViewController.h +11 -3
- package/ios/ViewController/HBDViewController.mm +209 -159
- package/ios/ViewController/UINavigationController+HBD.h +2 -2
- package/ios/ViewController/UINavigationController+HBD.mm +3 -3
- package/ios/ViewController/UIViewController+HBD.h +18 -10
- package/ios/ViewController/UIViewController+HBD.mm +90 -65
- package/package.json +3 -1
- package/src/DeepLink.ts +41 -14
- package/src/NativeEvent.ts +18 -11
- package/src/NativeNavigation.ts +29 -31
- package/src/Navigation.ts +377 -120
- package/src/NavigationComponentWrap.tsx +18 -9
- package/src/Navigator.ts +219 -152
- package/src/Options.ts +12 -3
- package/src/Route.ts +228 -17
- package/src/defineRoutes.ts +46 -0
- package/src/handler/DispatchCommandHandler.ts +154 -21
- package/src/handler/LayoutCommandHandler.ts +40 -17
- package/src/handler/LeaveGuardHandler.ts +436 -0
- package/src/handler/LifecycleEventHandler.ts +219 -0
- package/src/handler/PresentationCoordinator.ts +560 -0
- package/src/handler/ResultEventHandler.ts +126 -19
- package/src/handler/TabEventHandler.ts +31 -0
- package/src/hooks.ts +75 -7
- package/src/index.ts +37 -2
- package/src/reveal.ts +565 -0
- package/src/routeConfigRegistry.ts +26 -0
- package/src/routeGraph.ts +87 -0
- package/src/router/drawer.ts +8 -5
- package/src/router/index.ts +139 -63
- package/src/router/screen.ts +3 -3
- package/src/router/stack.ts +80 -29
- package/src/router/tabs.ts +16 -7
- package/src/store.ts +6 -1
- package/src/testing.ts +395 -0
- package/testing.d.ts +1 -0
- package/testing.js +3 -0
- 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,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
|
-
this.globalListeners.forEach(listener => listener(sceneId, 'visible'));
|
|
9
|
-
const listeners = this.listeners[sceneId];
|
|
10
|
-
if (listeners) {
|
|
11
|
-
listeners.forEach(listener => listener('visible'));
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
NativeEvent.onComponentDisappear(({ sceneId }) => {
|
|
15
|
-
this.globalListeners.forEach(listener => listener(sceneId, 'invisible'));
|
|
16
|
-
const listeners = this.listeners[sceneId];
|
|
17
|
-
if (listeners) {
|
|
18
|
-
listeners.forEach(listener => listener('invisible'));
|
|
19
|
-
}
|
|
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');
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { Visibility } from '../Route';
|
|
2
|
-
import NativeEvent from '../NativeEvent';
|
|
3
|
-
|
|
4
|
-
export type VisibilityEventListener = (visibility: Visibility) => void;
|
|
5
|
-
export type GlobalVisibilityEventListener = (sceneId: string, visibility: Visibility) => void;
|
|
6
|
-
|
|
7
|
-
export default class VisibilityEventHandler {
|
|
8
|
-
private listeners: Record<string, VisibilityEventListener[]> = {};
|
|
9
|
-
private globalListeners: GlobalVisibilityEventListener[] = [];
|
|
10
|
-
|
|
11
|
-
constructor() {}
|
|
12
|
-
|
|
13
|
-
handleComponentVisibility() {
|
|
14
|
-
NativeEvent.onComponentAppear(({ sceneId }) => {
|
|
15
|
-
this.globalListeners.forEach(listener => listener(sceneId, 'visible'));
|
|
16
|
-
|
|
17
|
-
const listeners = this.listeners[sceneId];
|
|
18
|
-
if (listeners) {
|
|
19
|
-
listeners.forEach(listener => listener('visible'));
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
NativeEvent.onComponentDisappear(({ sceneId }) => {
|
|
23
|
-
this.globalListeners.forEach(listener => listener(sceneId, 'invisible'));
|
|
24
|
-
|
|
25
|
-
const listeners = this.listeners[sceneId];
|
|
26
|
-
if (listeners) {
|
|
27
|
-
listeners.forEach(listener => listener('invisible'));
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
addGlobalVisibilityEventListener(listener: GlobalVisibilityEventListener) {
|
|
33
|
-
this.globalListeners.push(listener);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
removeGlobalVisibilityEventListener(listener: GlobalVisibilityEventListener) {
|
|
37
|
-
this.globalListeners = this.globalListeners.filter(l => l !== listener);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
addVisibilityEventListener(sceneId: string, listener: VisibilityEventListener) {
|
|
41
|
-
if (!this.listeners[sceneId]) {
|
|
42
|
-
this.listeners[sceneId] = [];
|
|
43
|
-
}
|
|
44
|
-
this.listeners[sceneId].push(listener);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
removeVisibilityEventListener(sceneId: string, listener: VisibilityEventListener) {
|
|
48
|
-
if (this.listeners[sceneId]) {
|
|
49
|
-
this.listeners[sceneId] = this.listeners[sceneId].filter(l => l !== listener);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|