hybrid-navigation 2.14.4 → 2.14.6

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.1'
36
+ api 'io.github.listenzz:AndroidNavigation:13.4.2'
37
37
  }
@@ -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
@@ -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/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.4",
4
+ "version": "2.14.6",
5
5
  "main": "./lib/index.js",
6
6
  "typings": "./lib/index.d.ts",
7
7
  "react-native": "src/index",