hybrid-navigation 2.11.2 → 2.12.1
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/android/build.gradle +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/GardenModule.java +0 -3
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivity.java +0 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactDefaultTabBarProvider.java +146 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactStackFragment.java +9 -10
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarFragment.java +14 -144
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarProvider.java +4 -2
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/ScreenNavigator.java +6 -6
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/StackNavigator.java +13 -12
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/TabNavigator.java +3 -4
- package/ios/HybridNavigation/Navigator/HBDScreenNavigator.m +6 -4
- package/package.json +1 -12
package/android/build.gradle
CHANGED
|
@@ -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:12.5.
|
|
36
|
+
api 'io.github.listenzz:AndroidNavigation:12.5.5'
|
|
37
37
|
}
|
|
@@ -45,7 +45,6 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
|
|
|
45
45
|
super.onCreate(savedInstanceState);
|
|
46
46
|
activityDelegate.onCreate(savedInstanceState);
|
|
47
47
|
getReactBridgeManager().addReactModuleRegisterListener(this);
|
|
48
|
-
|
|
49
48
|
ensureViewHierarchy(savedInstanceState);
|
|
50
49
|
}
|
|
51
50
|
|
package/android/src/main/java/com/reactnative/hybridnavigation/ReactDefaultTabBarProvider.java
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
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.mergeOptions;
|
|
8
|
+
|
|
9
|
+
import android.os.Bundle;
|
|
10
|
+
import android.view.View;
|
|
11
|
+
|
|
12
|
+
import androidx.annotation.NonNull;
|
|
13
|
+
import androidx.annotation.Nullable;
|
|
14
|
+
|
|
15
|
+
import com.navigation.androidx.DefaultTabBarProvider;
|
|
16
|
+
import com.navigation.androidx.Style;
|
|
17
|
+
import com.navigation.androidx.TabBar;
|
|
18
|
+
import com.navigation.androidx.TabBarFragment;
|
|
19
|
+
import com.navigation.androidx.TabBarItem;
|
|
20
|
+
|
|
21
|
+
import java.util.ArrayList;
|
|
22
|
+
import java.util.List;
|
|
23
|
+
|
|
24
|
+
public class ReactDefaultTabBarProvider extends DefaultTabBarProvider {
|
|
25
|
+
|
|
26
|
+
private ReactTabBarFragment tabBarFragment;
|
|
27
|
+
|
|
28
|
+
@Override
|
|
29
|
+
public View onCreateTabBar(@NonNull List<TabBarItem> tabBarItems, @NonNull TabBarFragment tabBarFragment, @Nullable Bundle savedInstanceState) {
|
|
30
|
+
this.tabBarFragment = (ReactTabBarFragment) tabBarFragment;
|
|
31
|
+
return super.onCreateTabBar(tabBarItems, tabBarFragment, savedInstanceState);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@Override
|
|
35
|
+
public void updateTabBar(@NonNull Bundle options) {
|
|
36
|
+
String action = options.getString(ARG_ACTION);
|
|
37
|
+
if (action == null) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
switch (action) {
|
|
42
|
+
case ACTION_SET_TAB_ITEM:
|
|
43
|
+
setTabItem(options.getParcelableArrayList(ARG_OPTIONS));
|
|
44
|
+
break;
|
|
45
|
+
case ACTION_UPDATE_TAB_BAR:
|
|
46
|
+
updateTabBarStyle(options.getBundle(ARG_OPTIONS));
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
private void setTabItem(@Nullable ArrayList<Bundle> options) {
|
|
52
|
+
if (options == null) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
TabBar tabBar = tabBarFragment.getTabBar();
|
|
57
|
+
|
|
58
|
+
for (Bundle option : options) {
|
|
59
|
+
int index = (int) option.getDouble("index");
|
|
60
|
+
TabBarItem tabBarItem = tabBar.getTabBarItem(index);
|
|
61
|
+
if (tabBarItem == null) {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
setTabItemTitle(option, tabBarItem);
|
|
66
|
+
setTabItemIcon(option, tabBarItem);
|
|
67
|
+
setTabItemBadge(option, tabBarItem);
|
|
68
|
+
tabBar.renderTabView(index);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private void setTabItemBadge(Bundle option, TabBarItem tabBarItem) {
|
|
73
|
+
Bundle badge = option.getBundle("badge");
|
|
74
|
+
if (badge == null) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
boolean hidden = badge.getBoolean("hidden", true);
|
|
79
|
+
String text = !hidden ? badge.getString("text", "") : "";
|
|
80
|
+
boolean dot = !hidden && badge.getBoolean("dot", false);
|
|
81
|
+
|
|
82
|
+
tabBarItem.badgeText = text;
|
|
83
|
+
tabBarItem.showDotBadge = dot;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
private void setTabItemIcon(Bundle option, TabBarItem tabBarItem) {
|
|
87
|
+
Bundle icon = option.getBundle("icon");
|
|
88
|
+
if (icon == null) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
Bundle selected = icon.getBundle("selected");
|
|
93
|
+
tabBarItem.iconUri = selected.getString("uri");
|
|
94
|
+
|
|
95
|
+
Bundle unselected = icon.getBundle("unselected");
|
|
96
|
+
if (unselected == null) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
tabBarItem.unselectedIconUri = unselected.getString("uri");
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
private void setTabItemTitle(Bundle option, TabBarItem tabBarItem) {
|
|
103
|
+
String title = option.getString("title");
|
|
104
|
+
if (title == null) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
tabBarItem.title = title;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
private void updateTabBarStyle(@Nullable Bundle options) {
|
|
111
|
+
if (options == null) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
tabBarFragment.setOptions(mergeOptions(tabBarFragment.getOptions(), options));
|
|
116
|
+
TabBar tabBar = tabBarFragment.getTabBar();
|
|
117
|
+
|
|
118
|
+
String tabBarColor = options.getString("tabBarColor");
|
|
119
|
+
Bundle shadowImage = options.getBundle("tabBarShadowImage");
|
|
120
|
+
String tabBarItemColor = options.getString("tabBarItemColor");
|
|
121
|
+
String tabBarUnselectedItemColor = options.getString("tabBarUnselectedItemColor");
|
|
122
|
+
|
|
123
|
+
if (tabBarColor != null) {
|
|
124
|
+
tabBar.setBarBackgroundColor(tabBarColor);
|
|
125
|
+
|
|
126
|
+
Style style = tabBarFragment.getStyle();
|
|
127
|
+
style.setTabBarBackgroundColor(tabBarColor);
|
|
128
|
+
tabBarFragment.setNeedsNavigationBarAppearanceUpdate();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (shadowImage != null) {
|
|
132
|
+
tabBar.setShadowDrawable(Utils.createTabBarShadow(tabBarFragment.requireContext(), shadowImage));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (tabBarItemColor != null) {
|
|
136
|
+
tabBar.setSelectedItemColor(tabBarItemColor);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (tabBarUnselectedItemColor != null) {
|
|
140
|
+
tabBar.setUnselectedItemColor(tabBarUnselectedItemColor);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
tabBar.initialise(tabBar.getCurrentSelectedPosition());
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
}
|
|
@@ -43,40 +43,39 @@ public class ReactStackFragment extends StackFragment {
|
|
|
43
43
|
private final static TransitionAnimation BetterRedirect = new TransitionAnimation(R.anim.nav_push_translucent_enter, R.anim.nav_gone, R.anim.nav_none, R.anim.nav_push_translucent_exit);
|
|
44
44
|
|
|
45
45
|
@Override
|
|
46
|
-
protected void pushFragmentSync(
|
|
46
|
+
protected void pushFragmentSync(AwesomeFragment fragment, @NonNull Runnable completion, @NonNull TransitionAnimation animation) {
|
|
47
47
|
if (fragment instanceof ReactFragment) {
|
|
48
48
|
ReactFragment reactFragment = (ReactFragment) fragment;
|
|
49
49
|
if (reactFragment.shouldPassThroughTouches()) {
|
|
50
|
-
super.pushFragmentSync(fragment,
|
|
50
|
+
super.pushFragmentSync(fragment, completion, BetterPush);
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
super.pushFragmentSync(fragment,
|
|
54
|
+
super.pushFragmentSync(fragment, completion, animation);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
@Override
|
|
58
|
-
protected void popToFragmentSync(
|
|
58
|
+
protected void popToFragmentSync(AwesomeFragment fragment, @NonNull Runnable completion, @NonNull TransitionAnimation animation) {
|
|
59
59
|
AwesomeFragment topFragment = getTopFragment();
|
|
60
60
|
if (topFragment instanceof ReactFragment) {
|
|
61
61
|
ReactFragment reactFragment = (ReactFragment) topFragment;
|
|
62
62
|
if (reactFragment.shouldPassThroughTouches()) {
|
|
63
|
-
super.popToFragmentSync(fragment,
|
|
63
|
+
super.popToFragmentSync(fragment, completion, BetterPush);
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
super.popToFragmentSync(fragment,
|
|
67
|
+
super.popToFragmentSync(fragment, completion, animation);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
@Override
|
|
71
|
-
protected void redirectToFragmentSync(@NonNull AwesomeFragment fragment, @NonNull
|
|
71
|
+
protected void redirectToFragmentSync(@NonNull AwesomeFragment fragment, @NonNull Runnable completion, @NonNull TransitionAnimation animation, @Nullable AwesomeFragment from) {
|
|
72
72
|
if (fragment instanceof ReactFragment) {
|
|
73
73
|
ReactFragment reactFragment = (ReactFragment) fragment;
|
|
74
74
|
if (reactFragment.shouldPassThroughTouches()) {
|
|
75
|
-
super.redirectToFragmentSync(fragment,
|
|
75
|
+
super.redirectToFragmentSync(fragment, completion, BetterRedirect, from);
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
|
|
80
|
-
super.redirectToFragmentSync(fragment, animation, completion, from);
|
|
79
|
+
super.redirectToFragmentSync(fragment, completion, animation, from);
|
|
81
80
|
}
|
|
82
81
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
package com.reactnative.hybridnavigation;
|
|
2
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
3
|
import static com.reactnative.hybridnavigation.Constants.ARG_OPTIONS;
|
|
7
4
|
import static com.reactnative.hybridnavigation.HBDEventEmitter.EVENT_NAVIGATION;
|
|
8
5
|
import static com.reactnative.hybridnavigation.HBDEventEmitter.KEY_INDEX;
|
|
@@ -12,7 +9,6 @@ import static com.reactnative.hybridnavigation.HBDEventEmitter.KEY_RESULT_CODE;
|
|
|
12
9
|
import static com.reactnative.hybridnavigation.HBDEventEmitter.KEY_RESULT_DATA;
|
|
13
10
|
import static com.reactnative.hybridnavigation.HBDEventEmitter.KEY_SCENE_ID;
|
|
14
11
|
import static com.reactnative.hybridnavigation.HBDEventEmitter.ON_COMPONENT_RESULT;
|
|
15
|
-
import static com.reactnative.hybridnavigation.Parameters.mergeOptions;
|
|
16
12
|
|
|
17
13
|
import android.os.Bundle;
|
|
18
14
|
|
|
@@ -21,16 +17,12 @@ import androidx.annotation.Nullable;
|
|
|
21
17
|
|
|
22
18
|
import com.facebook.react.bridge.Arguments;
|
|
23
19
|
import com.navigation.androidx.AwesomeFragment;
|
|
24
|
-
import com.navigation.androidx.DefaultTabBarProvider;
|
|
25
20
|
import com.navigation.androidx.FragmentHelper;
|
|
26
21
|
import com.navigation.androidx.Style;
|
|
27
|
-
import com.navigation.androidx.TabBar;
|
|
28
22
|
import com.navigation.androidx.TabBarFragment;
|
|
29
|
-
import com.navigation.androidx.TabBarItem;
|
|
30
23
|
import com.navigation.androidx.TabBarProvider;
|
|
31
24
|
import com.navigation.androidx.TransitionAnimation;
|
|
32
25
|
|
|
33
|
-
import java.util.ArrayList;
|
|
34
26
|
import java.util.List;
|
|
35
27
|
|
|
36
28
|
|
|
@@ -124,6 +116,15 @@ public class ReactTabBarFragment extends TabBarFragment {
|
|
|
124
116
|
}
|
|
125
117
|
}
|
|
126
118
|
|
|
119
|
+
@Override
|
|
120
|
+
protected TabBarProvider createDefaultTabBarProvider() {
|
|
121
|
+
Bundle options = getOptions();
|
|
122
|
+
if (options.getString("tabBarModuleName") != null) {
|
|
123
|
+
return new ReactTabBarProvider();
|
|
124
|
+
}
|
|
125
|
+
return new ReactDefaultTabBarProvider();
|
|
126
|
+
}
|
|
127
|
+
|
|
127
128
|
private Bundle options;
|
|
128
129
|
|
|
129
130
|
@NonNull
|
|
@@ -149,10 +150,11 @@ public class ReactTabBarFragment extends TabBarFragment {
|
|
|
149
150
|
private boolean intercepted = true;
|
|
150
151
|
|
|
151
152
|
@Override
|
|
152
|
-
public void setSelectedIndex(int index, @
|
|
153
|
+
public void setSelectedIndex(int index, @NonNull Runnable completion) {
|
|
153
154
|
if (shouldIntercept()) {
|
|
154
155
|
sendSwitchTabEvent(index);
|
|
155
|
-
|
|
156
|
+
// restore tab bar selected index
|
|
157
|
+
setTabBarSelectedIndex(getSelectedIndex());
|
|
156
158
|
return;
|
|
157
159
|
}
|
|
158
160
|
|
|
@@ -163,15 +165,7 @@ public class ReactTabBarFragment extends TabBarFragment {
|
|
|
163
165
|
private boolean shouldIntercept() {
|
|
164
166
|
return isAdded() && bridgeManager.hasRootLayout() && this.intercepted;
|
|
165
167
|
}
|
|
166
|
-
|
|
167
|
-
private void restoreTabBarState() {
|
|
168
|
-
TabBarProvider tabBarProvider = getTabBarProvider();
|
|
169
|
-
if (tabBarProvider == null) {
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
tabBarProvider.setSelectedIndex(getSelectedIndex());
|
|
173
|
-
}
|
|
174
|
-
|
|
168
|
+
|
|
175
169
|
private void sendSwitchTabEvent(int index) {
|
|
176
170
|
Bundle data = new Bundle();
|
|
177
171
|
data.putString(KEY_SCENE_ID, getSceneId());
|
|
@@ -203,129 +197,5 @@ public class ReactTabBarFragment extends TabBarFragment {
|
|
|
203
197
|
public Style getStyle() {
|
|
204
198
|
return mStyle;
|
|
205
199
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
@Override
|
|
209
|
-
public void updateTabBar(Bundle options) {
|
|
210
|
-
super.updateTabBar(options);
|
|
211
|
-
if (getTabBarProvider() instanceof DefaultTabBarProvider) {
|
|
212
|
-
updateDefaultTabBar(options);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
private void updateDefaultTabBar(Bundle options) {
|
|
217
|
-
String action = options.getString(ARG_ACTION);
|
|
218
|
-
if (action == null) {
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
switch (action) {
|
|
223
|
-
case ACTION_SET_TAB_ITEM:
|
|
224
|
-
setTabItem(options.getParcelableArrayList(ARG_OPTIONS));
|
|
225
|
-
break;
|
|
226
|
-
case ACTION_UPDATE_TAB_BAR:
|
|
227
|
-
updateTabBarStyle(options.getBundle(ARG_OPTIONS));
|
|
228
|
-
break;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
private void setTabItem(@Nullable ArrayList<Bundle> options) {
|
|
233
|
-
if (options == null) {
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
TabBar tabBar = getTabBar();
|
|
238
|
-
if (tabBar == null) {
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
for (Bundle option : options) {
|
|
243
|
-
int index = (int) option.getDouble("index");
|
|
244
|
-
TabBarItem tabBarItem = tabBar.getTabBarItem(index);
|
|
245
|
-
if (tabBarItem == null) {
|
|
246
|
-
continue;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
setTabItemTitle(option, tabBarItem);
|
|
250
|
-
setTabItemIcon(option, tabBarItem);
|
|
251
|
-
setTabItemBadge(option, tabBarItem);
|
|
252
|
-
tabBar.renderTabView(index);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
private void setTabItemBadge(Bundle option, TabBarItem tabBarItem) {
|
|
257
|
-
Bundle badge = option.getBundle("badge");
|
|
258
|
-
if (badge == null) {
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
boolean hidden = badge.getBoolean("hidden", true);
|
|
263
|
-
String text = !hidden ? badge.getString("text", "") : "";
|
|
264
|
-
boolean dot = !hidden && badge.getBoolean("dot", false);
|
|
265
|
-
|
|
266
|
-
tabBarItem.badgeText = text;
|
|
267
|
-
tabBarItem.showDotBadge = dot;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
private void setTabItemIcon(Bundle option, TabBarItem tabBarItem) {
|
|
271
|
-
Bundle icon = option.getBundle("icon");
|
|
272
|
-
if (icon == null) {
|
|
273
|
-
return;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
Bundle selected = icon.getBundle("selected");
|
|
277
|
-
tabBarItem.iconUri = selected.getString("uri");
|
|
278
|
-
|
|
279
|
-
Bundle unselected = icon.getBundle("unselected");
|
|
280
|
-
if (unselected == null) {
|
|
281
|
-
return;
|
|
282
|
-
}
|
|
283
|
-
tabBarItem.unselectedIconUri = unselected.getString("uri");
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
private void setTabItemTitle(Bundle option, TabBarItem tabBarItem) {
|
|
287
|
-
String title = option.getString("title");
|
|
288
|
-
if (title == null) {
|
|
289
|
-
return;
|
|
290
|
-
}
|
|
291
|
-
tabBarItem.title = title;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
private void updateTabBarStyle(@Nullable Bundle options) {
|
|
295
|
-
if (options == null) {
|
|
296
|
-
return;
|
|
297
|
-
}
|
|
298
|
-
setOptions(mergeOptions(getOptions(), options));
|
|
299
|
-
|
|
300
|
-
TabBar tabBar = getTabBar();
|
|
301
|
-
if (tabBar == null) {
|
|
302
|
-
return;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
String tabBarColor = options.getString("tabBarColor");
|
|
306
|
-
Bundle shadowImage = options.getBundle("tabBarShadowImage");
|
|
307
|
-
String tabBarItemColor = options.getString("tabBarItemColor");
|
|
308
|
-
String tabBarUnselectedItemColor = options.getString("tabBarUnselectedItemColor");
|
|
309
|
-
|
|
310
|
-
if (tabBarColor != null) {
|
|
311
|
-
mStyle.setTabBarBackgroundColor(tabBarColor);
|
|
312
|
-
tabBar.setBarBackgroundColor(tabBarColor);
|
|
313
|
-
setNeedsNavigationBarAppearanceUpdate();
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
if (shadowImage != null) {
|
|
317
|
-
tabBar.setShadowDrawable(Utils.createTabBarShadow(requireContext(), shadowImage));
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
if (tabBarItemColor != null) {
|
|
321
|
-
tabBar.setSelectedItemColor(tabBarItemColor);
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
if (tabBarUnselectedItemColor != null) {
|
|
325
|
-
tabBar.setUnselectedItemColor(tabBarUnselectedItemColor);
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
tabBar.initialise(tabBar.getCurrentSelectedPosition());
|
|
329
|
-
}
|
|
330
|
-
|
|
200
|
+
|
|
331
201
|
}
|
|
@@ -281,15 +281,17 @@ public class ReactTabBarProvider implements TabBarProvider, ReactBridgeManager.R
|
|
|
281
281
|
return;
|
|
282
282
|
}
|
|
283
283
|
|
|
284
|
-
|
|
284
|
+
|
|
285
285
|
Bundle options = tabBarFragment.getOptions();
|
|
286
286
|
ReactTabBar tabBar = this.tabBar;
|
|
287
287
|
|
|
288
288
|
String tabBarColor = bundle.getString("tabBarColor");
|
|
289
289
|
if (tabBarColor != null) {
|
|
290
290
|
options.putString("tabBarColor", tabBarColor);
|
|
291
|
-
style.setTabBarBackgroundColor(tabBarColor);
|
|
292
291
|
tabBar.setTabBarBackground(new ColorDrawable(Color.parseColor(tabBarColor)));
|
|
292
|
+
|
|
293
|
+
Style style = tabBarFragment.getStyle();
|
|
294
|
+
style.setTabBarBackgroundColor(tabBarColor);
|
|
293
295
|
tabBarFragment.setNeedsNavigationBarAppearanceUpdate();
|
|
294
296
|
}
|
|
295
297
|
|
package/android/src/main/java/com/reactnative/hybridnavigation/navigator/ScreenNavigator.java
CHANGED
|
@@ -128,7 +128,7 @@ public class ScreenNavigator implements Navigator {
|
|
|
128
128
|
}
|
|
129
129
|
presented.setPresentationStyle(PresentationStyle.OverFullScreen);
|
|
130
130
|
int requestCode = extras.getInt("requestCode");
|
|
131
|
-
presenting.presentFragment(presented, requestCode,
|
|
131
|
+
presenting.presentFragment(presented, requestCode, () -> promise.resolve(true), TransitionAnimation.Fade);
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
private void handlePresentLayout(@NonNull AwesomeFragment presenting, @NonNull ReadableMap extras, @NonNull Promise promise) {
|
|
@@ -150,16 +150,16 @@ public class ScreenNavigator implements Navigator {
|
|
|
150
150
|
}
|
|
151
151
|
presented.setPresentationStyle(PresentationStyle.OverFullScreen);
|
|
152
152
|
int requestCode = extras.getInt("requestCode");
|
|
153
|
-
presenting.presentFragment(presented, requestCode,
|
|
153
|
+
presenting.presentFragment(presented, requestCode, () -> promise.resolve(true), TransitionAnimation.Fade);
|
|
154
154
|
}
|
|
155
|
-
|
|
155
|
+
|
|
156
156
|
private void handleHideModal(@NonNull AwesomeFragment target, @NonNull Promise promise) {
|
|
157
157
|
AwesomeFragment presenting = target.getPresentingFragment();
|
|
158
158
|
if (presenting == null) {
|
|
159
|
-
target.dismissFragment(
|
|
159
|
+
target.dismissFragment(() -> promise.resolve(true), TransitionAnimation.Fade);
|
|
160
160
|
return;
|
|
161
161
|
}
|
|
162
|
-
presenting.dismissFragment(
|
|
162
|
+
presenting.dismissFragment(() -> promise.resolve(true), TransitionAnimation.Fade);
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
private void handleDismiss(@NonNull AwesomeFragment target, @NonNull Promise promise) {
|
|
@@ -182,7 +182,7 @@ public class ScreenNavigator implements Navigator {
|
|
|
182
182
|
stackFragment.setRootFragment(fragment);
|
|
183
183
|
target.presentFragment(stackFragment, requestCode, () -> promise.resolve(true));
|
|
184
184
|
}
|
|
185
|
-
|
|
185
|
+
|
|
186
186
|
private AwesomeFragment createFragmentWithExtras(@NonNull ReadableMap extras) {
|
|
187
187
|
if (!extras.hasKey("moduleName")) {
|
|
188
188
|
return null;
|
package/android/src/main/java/com/reactnative/hybridnavigation/navigator/StackNavigator.java
CHANGED
|
@@ -16,6 +16,7 @@ import com.navigation.androidx.AwesomeFragment;
|
|
|
16
16
|
import com.navigation.androidx.DrawerFragment;
|
|
17
17
|
import com.navigation.androidx.StackFragment;
|
|
18
18
|
import com.navigation.androidx.TabBarFragment;
|
|
19
|
+
import com.navigation.androidx.TransitionAnimation;
|
|
19
20
|
import com.reactnative.hybridnavigation.HybridFragment;
|
|
20
21
|
import com.reactnative.hybridnavigation.ReactBridgeManager;
|
|
21
22
|
import com.reactnative.hybridnavigation.ReactStackFragment;
|
|
@@ -74,11 +75,11 @@ public class StackNavigator implements Navigator {
|
|
|
74
75
|
if (!(fragment instanceof StackFragment)) {
|
|
75
76
|
return null;
|
|
76
77
|
}
|
|
77
|
-
|
|
78
|
+
|
|
78
79
|
if (!fragment.isAdded()) {
|
|
79
80
|
return null;
|
|
80
81
|
}
|
|
81
|
-
|
|
82
|
+
|
|
82
83
|
StackFragment stack = (StackFragment) fragment;
|
|
83
84
|
ArrayList<Bundle> children = buildChildrenGraph(stack);
|
|
84
85
|
Bundle graph = new Bundle();
|
|
@@ -102,7 +103,7 @@ public class StackNavigator implements Navigator {
|
|
|
102
103
|
}
|
|
103
104
|
return children;
|
|
104
105
|
}
|
|
105
|
-
|
|
106
|
+
|
|
106
107
|
@Override
|
|
107
108
|
public HybridFragment primaryFragment(@NonNull AwesomeFragment fragment) {
|
|
108
109
|
if (!(fragment instanceof StackFragment)) {
|
|
@@ -128,13 +129,13 @@ public class StackNavigator implements Navigator {
|
|
|
128
129
|
handlePush(extras, promise, stackFragment);
|
|
129
130
|
break;
|
|
130
131
|
case "pop":
|
|
131
|
-
stackFragment.popFragment(
|
|
132
|
+
stackFragment.popFragment(() -> promise.resolve(true));
|
|
132
133
|
break;
|
|
133
134
|
case "popTo":
|
|
134
135
|
handlePopTo(extras, promise, stackFragment);
|
|
135
136
|
break;
|
|
136
137
|
case "popToRoot":
|
|
137
|
-
stackFragment.popToRootFragment(
|
|
138
|
+
stackFragment.popToRootFragment(() -> promise.resolve(true));
|
|
138
139
|
break;
|
|
139
140
|
case "redirectTo":
|
|
140
141
|
handleRedirectTo(target, extras, promise, stackFragment);
|
|
@@ -152,7 +153,7 @@ public class StackNavigator implements Navigator {
|
|
|
152
153
|
promise.resolve(false);
|
|
153
154
|
return;
|
|
154
155
|
}
|
|
155
|
-
stackFragment.pushFragment(fragment,
|
|
156
|
+
stackFragment.pushFragment(fragment, () -> promise.resolve(true));
|
|
156
157
|
}
|
|
157
158
|
|
|
158
159
|
private void handleRedirectTo(@NonNull AwesomeFragment target, @NonNull ReadableMap extras, @NonNull Promise promise, StackFragment stackFragment) {
|
|
@@ -161,7 +162,7 @@ public class StackNavigator implements Navigator {
|
|
|
161
162
|
promise.resolve(false);
|
|
162
163
|
return;
|
|
163
164
|
}
|
|
164
|
-
stackFragment.redirectToFragment(fragment,
|
|
165
|
+
stackFragment.redirectToFragment(fragment, () -> promise.resolve(true), TransitionAnimation.Redirect, target);
|
|
165
166
|
}
|
|
166
167
|
|
|
167
168
|
private void handlePopTo(@NonNull ReadableMap extras, @NonNull Promise promise, StackFragment stackFragment) {
|
|
@@ -179,7 +180,7 @@ public class StackNavigator implements Navigator {
|
|
|
179
180
|
return;
|
|
180
181
|
}
|
|
181
182
|
|
|
182
|
-
stackFragment.popToFragment(fragment,
|
|
183
|
+
stackFragment.popToFragment(fragment, () -> promise.resolve(true));
|
|
183
184
|
}
|
|
184
185
|
|
|
185
186
|
@Nullable
|
|
@@ -218,7 +219,7 @@ public class StackNavigator implements Navigator {
|
|
|
218
219
|
promise.resolve(false);
|
|
219
220
|
return;
|
|
220
221
|
}
|
|
221
|
-
stackFragment.pushFragment(fragment,
|
|
222
|
+
stackFragment.pushFragment(fragment, () -> promise.resolve(true));
|
|
222
223
|
}
|
|
223
224
|
|
|
224
225
|
private AwesomeFragment createFragmentWithExtras(@NonNull ReadableMap extras) {
|
|
@@ -272,12 +273,12 @@ public class StackNavigator implements Navigator {
|
|
|
272
273
|
return null;
|
|
273
274
|
}
|
|
274
275
|
|
|
275
|
-
TabBarFragment tabBarFragment = drawerFragment.
|
|
276
|
+
TabBarFragment tabBarFragment = drawerFragment.requireContentFragment().getTabBarFragment();
|
|
276
277
|
if (tabBarFragment != null) {
|
|
277
|
-
return tabBarFragment.
|
|
278
|
+
return tabBarFragment.requireSelectedFragment().getStackFragment();
|
|
278
279
|
}
|
|
279
280
|
|
|
280
|
-
return drawerFragment.
|
|
281
|
+
return drawerFragment.requireContentFragment().getStackFragment();
|
|
281
282
|
}
|
|
282
283
|
|
|
283
284
|
private ReactBridgeManager getReactBridgeManager() {
|
|
@@ -11,10 +11,10 @@ import com.facebook.react.bridge.ReadableMap;
|
|
|
11
11
|
import com.navigation.androidx.AwesomeFragment;
|
|
12
12
|
import com.navigation.androidx.StackFragment;
|
|
13
13
|
import com.navigation.androidx.TabBarFragment;
|
|
14
|
+
import com.navigation.androidx.TransitionAnimation;
|
|
14
15
|
import com.reactnative.hybridnavigation.HybridFragment;
|
|
15
16
|
import com.reactnative.hybridnavigation.ReactBridgeManager;
|
|
16
17
|
import com.reactnative.hybridnavigation.ReactTabBarFragment;
|
|
17
|
-
import com.reactnative.hybridnavigation.ReactTabBarProvider;
|
|
18
18
|
|
|
19
19
|
import java.util.ArrayList;
|
|
20
20
|
import java.util.Collections;
|
|
@@ -85,7 +85,6 @@ public class TabNavigator implements Navigator {
|
|
|
85
85
|
if (options.hasKey("tabBarModuleName")) {
|
|
86
86
|
String tabBarModuleName = options.getString("tabBarModuleName");
|
|
87
87
|
bundle.putString("tabBarModuleName", tabBarModuleName);
|
|
88
|
-
tabBarFragment.setTabBarProvider(new ReactTabBarProvider());
|
|
89
88
|
}
|
|
90
89
|
|
|
91
90
|
if (options.hasKey("sizeIndeterminate")) {
|
|
@@ -204,9 +203,9 @@ public class TabNavigator implements Navigator {
|
|
|
204
203
|
return;
|
|
205
204
|
}
|
|
206
205
|
|
|
207
|
-
StackFragment stackFragment = tabBarFragment.
|
|
206
|
+
StackFragment stackFragment = tabBarFragment.requireSelectedFragment().getStackFragment();
|
|
208
207
|
if (stackFragment != null && stackFragment.getChildAwesomeFragments().size() > 1) {
|
|
209
|
-
stackFragment.popToRootFragment(
|
|
208
|
+
stackFragment.popToRootFragment(()-> {}, TransitionAnimation.None);
|
|
210
209
|
}
|
|
211
210
|
}
|
|
212
211
|
|
|
@@ -87,18 +87,19 @@
|
|
|
87
87
|
viewController = [self createViewControllerWithExtras:extras];
|
|
88
88
|
NSInteger requestCode = [extras[@"requestCode"] integerValue];
|
|
89
89
|
viewController.modalPresentationStyle = UIModalPresentationOverFullScreen;
|
|
90
|
+
viewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
|
|
90
91
|
[viewController setRequestCode:requestCode];
|
|
91
|
-
[target presentViewController:viewController animated:
|
|
92
|
+
[target presentViewController:viewController animated:YES completion:^{
|
|
92
93
|
resolve(@(YES));
|
|
93
94
|
}];
|
|
94
95
|
} else if ([action isEqualToString:@"hideModal"]) {
|
|
95
96
|
UIViewController *presenting = target.presentingViewController;
|
|
96
97
|
if (presenting) {
|
|
97
|
-
[presenting dismissViewControllerAnimated:
|
|
98
|
+
[presenting dismissViewControllerAnimated:YES completion:^{
|
|
98
99
|
resolve(@(YES));
|
|
99
100
|
}];
|
|
100
101
|
} else {
|
|
101
|
-
[target dismissViewControllerAnimated:
|
|
102
|
+
[target dismissViewControllerAnimated:YES completion:^{
|
|
102
103
|
resolve(@(YES));
|
|
103
104
|
}];
|
|
104
105
|
}
|
|
@@ -116,8 +117,9 @@
|
|
|
116
117
|
NSDictionary *layout = extras[@"layout"];
|
|
117
118
|
viewController = [[HBDReactBridgeManager get] controllerWithLayout:layout];
|
|
118
119
|
viewController.modalPresentationStyle = UIModalPresentationOverFullScreen;
|
|
120
|
+
viewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
|
|
119
121
|
[viewController setRequestCode:requestCode];
|
|
120
|
-
[target presentViewController:viewController animated:
|
|
122
|
+
[target presentViewController:viewController animated:YES completion:^{
|
|
121
123
|
resolve(@(YES));
|
|
122
124
|
}];
|
|
123
125
|
}
|
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.
|
|
4
|
+
"version": "2.12.1",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"typings": "./lib/index.d.ts",
|
|
7
7
|
"react-native": "src/index",
|
|
@@ -73,16 +73,5 @@
|
|
|
73
73
|
"typescript": "^4.6.4",
|
|
74
74
|
"vuepress": "^2.0.0-beta.26",
|
|
75
75
|
"zustand": "^3.7.1"
|
|
76
|
-
},
|
|
77
|
-
"jest": {
|
|
78
|
-
"preset": "react-native",
|
|
79
|
-
"moduleFileExtensions": [
|
|
80
|
-
"ts",
|
|
81
|
-
"tsx",
|
|
82
|
-
"js",
|
|
83
|
-
"jsx",
|
|
84
|
-
"json",
|
|
85
|
-
"node"
|
|
86
|
-
]
|
|
87
76
|
}
|
|
88
77
|
}
|