hybrid-navigation 2.14.5 → 2.15.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.
@@ -33,5 +33,5 @@ dependencies {
33
33
  implementation fileTree(dir: 'libs', include: ['*.jar'])
34
34
  implementation 'com.facebook.react:react-native:+'
35
35
  // api project(':navigation')
36
- api 'io.github.listenzz:AndroidNavigation:13.4.2'
36
+ api 'io.github.listenzz:AndroidNavigation:13.5.0'
37
37
  }
@@ -64,6 +64,8 @@ public class Garden {
64
64
  boolean extendedLayoutIncludesTopBar;
65
65
 
66
66
  boolean forceTransparentDialogWindow;
67
+
68
+ boolean fitsOpaqueNavigationBar;
67
69
 
68
70
  Garden(@NonNull HybridFragment fragment, Style style) {
69
71
  // 构造 garden 实例时,Toolbar 还没有被创建
@@ -79,6 +81,7 @@ public class Garden {
79
81
  Bundle tabItem = options.getBundle("tabItem");
80
82
  this.hidesBottomBarWhenPushed = tabItem == null || tabItem.getBoolean("hideTabBarWhenPush", true);
81
83
  this.extendedLayoutIncludesTopBar = options.getBoolean("extendedLayoutIncludesTopBar", false);
84
+ this.fitsOpaqueNavigationBar = options.getBoolean("fitsOpaqueNavigationBarAndroid", true);
82
85
 
83
86
  String screenColor = options.getString("screenBackgroundColor");
84
87
  if (!TextUtils.isEmpty(screenColor)) {
@@ -72,11 +72,21 @@ public class HBDReactRootView extends ReactRootView {
72
72
  super.runApplication();
73
73
  }
74
74
  }
75
+
76
+ private boolean hbd_isAttachedToReactInstance;
77
+
78
+ @Override
79
+ public void onAttachedToReactInstance() {
80
+ super.onAttachedToReactInstance();
81
+ hbd_isAttachedToReactInstance = true;
82
+ }
75
83
 
76
84
  @Override
77
85
  public void setAppProperties(@Nullable Bundle appProperties) {
78
- shouldRunApplication = true;
79
- super.setAppProperties(appProperties);
86
+ if (hbd_isAttachedToReactInstance) {
87
+ shouldRunApplication = true;
88
+ super.setAppProperties(appProperties);
89
+ }
80
90
  }
81
91
 
82
92
  @Override
@@ -152,6 +152,11 @@ public class HybridFragment extends AwesomeFragment {
152
152
  return garden.hidesBottomBarWhenPushed;
153
153
  }
154
154
 
155
+ @Override
156
+ protected boolean shouldFitsOpaqueNavigationBar() {
157
+ return garden.fitsOpaqueNavigationBar;
158
+ }
159
+
155
160
  protected boolean shouldPassThroughTouches() {
156
161
  Bundle options = getOptions();
157
162
  return options.getBoolean("passThroughTouches");
@@ -12,15 +12,21 @@ import android.widget.FrameLayout;
12
12
 
13
13
  import androidx.annotation.Nullable;
14
14
 
15
+ import com.facebook.common.logging.FLog;
16
+
15
17
  public class ReactTabBar extends FrameLayout {
16
18
 
19
+ protected static final String TAG = "Navigation";
20
+
17
21
  private Drawable shadow = new ColorDrawable(Color.parseColor("#EEEEEE"));
18
22
  private Drawable background = new ColorDrawable(Color.WHITE);
19
23
 
20
- private FrameLayout mReactHolder;
24
+ private FrameLayout mReactHolderView;
21
25
  private View mDivider;
22
26
  private boolean mSizeIndeterminate;
23
27
  private FrameLayout mBackgroundView;
28
+
29
+ private ViewGroup mReactRootView;
24
30
 
25
31
  public ReactTabBar(Context context) {
26
32
  super(context);
@@ -55,7 +61,7 @@ public class ReactTabBar extends FrameLayout {
55
61
  View parentView = inflater.inflate(layout, this, true);
56
62
  mBackgroundView = parentView.findViewById(R.id.bottom_navigation_bar_background);
57
63
  mBackgroundView.setBackground(background);
58
- mReactHolder = parentView.findViewById(R.id.bottom_navigation_bar_react_holder);
64
+ mReactHolderView = parentView.findViewById(R.id.bottom_navigation_bar_react_holder);
59
65
  mDivider = parentView.findViewById(R.id.bottom_navigation_bar_divider);
60
66
  mDivider.setBackground(shadow);
61
67
  }
@@ -71,18 +77,19 @@ public class ReactTabBar extends FrameLayout {
71
77
  public void setPadding(int left, int top, int right, int bottom) {
72
78
  mBackgroundView.setPadding(left, top, right, bottom);
73
79
  if (mSizeIndeterminate) {
74
- mReactHolder.setPadding(left, top, right, bottom);
80
+ mReactHolderView.setPadding(left, top, right, bottom);
75
81
  }
76
82
  }
77
83
 
78
84
  public void setRootView(View rootView) {
79
- mReactHolder.addView(rootView);
85
+ mReactHolderView.addView(rootView);
86
+ mReactRootView = (ViewGroup) rootView;
80
87
  }
81
88
 
82
89
  @Override
83
90
  protected void onDetachedFromWindow() {
84
91
  super.onDetachedFromWindow();
85
- mReactHolder.removeAllViews();
92
+ mReactHolderView.removeAllViews();
86
93
  }
87
94
 
88
95
  public void setTabBarBackground(Drawable drawable) {
@@ -91,4 +98,41 @@ public class ReactTabBar extends FrameLayout {
91
98
  mBackgroundView.setBackground(drawable);
92
99
  }
93
100
  }
101
+
102
+ @Override
103
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
104
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
105
+
106
+ ViewGroup.LayoutParams params = mReactRootView.getLayoutParams();
107
+ if (params.height > 0) {
108
+ return;
109
+ }
110
+
111
+ int height = getReactIntrinsicHeight();
112
+ FLog.i(TAG, "[ReactTabBar] intrinsic height:" + height);
113
+ if (height > 0) {
114
+ params.height = height;
115
+ post(mReactRootView::requestLayout);
116
+ }
117
+ }
118
+
119
+ private int getReactIntrinsicHeight() {
120
+ int rootViewHeight = mReactRootView.getMeasuredHeight();
121
+ if (mReactRootView.getChildCount() > 1 || mReactHolderView.getLayoutParams().height > 0) {
122
+ return rootViewHeight;
123
+ }
124
+
125
+ ViewGroup group = mReactRootView;
126
+ while (group.getMeasuredHeight() == rootViewHeight) {
127
+ if (group.getChildCount() == 0) {
128
+ return 0;
129
+ }
130
+ group = (ViewGroup) group.getChildAt(0);
131
+ if (group.getMeasuredHeight() < rootViewHeight) {
132
+ return group.getMeasuredHeight();
133
+ }
134
+ }
135
+ return rootViewHeight;
136
+ }
137
+
94
138
  }
@@ -9,6 +9,7 @@
9
9
  android:layout_width="match_parent"
10
10
  android:layout_height="wrap_content"
11
11
  android:layout_gravity="bottom">
12
+
12
13
  <View
13
14
  android:id="@+id/bottom_navigation_bar_divider"
14
15
  android:layout_width="match_parent"
@@ -20,6 +20,7 @@
20
20
  android:layout_width="match_parent"
21
21
  android:layout_height="@dimen/nav_tab_bar_height"
22
22
  android:layout_gravity="bottom" />
23
+
23
24
  </FrameLayout>
24
25
 
25
26
  <FrameLayout
package/lib/Options.d.ts CHANGED
@@ -35,6 +35,7 @@ export interface NavigationOption {
35
35
  titleTextSize?: number;
36
36
  navigationBarColorAndroid?: Color;
37
37
  navigationBarHiddenAndroid?: boolean;
38
+ fitsOpaqueNavigationBarAndroid?: boolean;
38
39
  displayCutoutWhenLandscapeAndroid?: boolean;
39
40
  homeIndicatorAutoHiddenIOS?: boolean;
40
41
  backButtonHidden?: boolean;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hybrid-navigation",
3
3
  "description": "React Native Navigation that supports seamless navigation between Native and React.",
4
- "version": "2.14.5",
4
+ "version": "2.15.0",
5
5
  "main": "./lib/index.js",
6
6
  "typings": "./lib/index.d.ts",
7
7
  "react-native": "src/index",
@@ -51,22 +51,23 @@
51
51
  "path-to-regexp": "^6.1.0"
52
52
  },
53
53
  "devDependencies": {
54
- "@babel/core": "^7.16.0",
55
- "@babel/preset-env": "^7.16.0",
56
- "@babel/runtime": "^7.16.0",
54
+ "@babel/core": "^7.20.0",
55
+ "@babel/preset-env": "^7.20.0",
56
+ "@babel/runtime": "^7.20.0",
57
57
  "@gfez/eslint-config-react-native": "^1.0.0",
58
58
  "@react-native-community/hooks": "^2.8.0",
59
+ "@react-native-community/slider": "^4.4.2",
59
60
  "@types/jest": "^29.2.1",
60
61
  "@types/react": "^18.0.24",
61
62
  "@types/react-redux": "^7.1.9",
62
63
  "@types/react-test-renderer": "^18.0.0",
63
64
  "babel-jest": "^29.2.1",
64
65
  "jest": "^29.2.1",
65
- "metro-react-native-babel-preset": "0.73.5",
66
+ "metro-react-native-babel-preset": "0.73.7",
66
67
  "react": "18.2.0",
67
- "react-native": "^0.71.0",
68
+ "react-native": "^0.71.3",
68
69
  "react-native-fast-image": "^8.5.11",
69
- "react-native-keyboard-insets": "^1.1.0",
70
+ "react-native-keyboard-insets": "^1.3.3",
70
71
  "react-native-safe-area-context": "^4.5.0",
71
72
  "react-native-toast-hybrid": "^2.5.0",
72
73
  "react-redux": "^7.2.5",
package/src/Options.ts CHANGED
@@ -34,6 +34,7 @@ export interface NavigationOption {
34
34
  titleTextSize?: number // TopBar 标题字体大小
35
35
  navigationBarColorAndroid?: Color // Android 底部虚拟按钮背景颜色
36
36
  navigationBarHiddenAndroid?: boolean // 是否隐藏 Android 底部的虚拟导航栏
37
+ fitsOpaqueNavigationBarAndroid?: boolean // 是否将页面内容延伸至不透明的虚拟导航栏下方,默认为不延伸(true)
37
38
  displayCutoutWhenLandscapeAndroid?: boolean // 横屏时,是否将界面延伸至刘海区域,默认 true
38
39
  homeIndicatorAutoHiddenIOS?: boolean // 是否隐藏 Home 指示器,默认 false
39
40