hybrid-navigation 4.0.7 → 4.0.8
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/src/main/java/com/navigation/androidx/AwesomeFragment.java +9 -0
- package/android/src/main/java/com/navigation/androidx/FragmentHelper.java +10 -5
- package/android/src/main/java/com/navigation/androidx/StackFragment.java +29 -23
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactFragment.java +4 -1
- package/package.json +1 -1
|
@@ -582,6 +582,15 @@ public abstract class AwesomeFragment extends InternalFragment {
|
|
|
582
582
|
|
|
583
583
|
// ------ StackFragment -----
|
|
584
584
|
|
|
585
|
+
/** The covered stack entry can resume while a redirect prepares its return state. */
|
|
586
|
+
protected final boolean isResumingForRedirect() {
|
|
587
|
+
AwesomeFragment parent = getParentAwesomeFragment();
|
|
588
|
+
if (parent instanceof StackFragment stack && stack.isRedirectPrecursor(this)) {
|
|
589
|
+
return true;
|
|
590
|
+
}
|
|
591
|
+
return parent != null && parent.isResumingForRedirect();
|
|
592
|
+
}
|
|
593
|
+
|
|
585
594
|
@NonNull
|
|
586
595
|
public StackFragment requireStackFragment() {
|
|
587
596
|
StackFragment stackFragment = getStackFragment();
|
|
@@ -30,15 +30,20 @@ public class FragmentHelper {
|
|
|
30
30
|
if (fragmentManager.isDestroyed()) {
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
+
AwesomeFragment topFragment = (AwesomeFragment) fragmentManager.findFragmentById(containerId);
|
|
34
|
+
addFragmentToBackStack(fragmentManager, containerId, fragment, animation, topFragment);
|
|
35
|
+
}
|
|
33
36
|
|
|
37
|
+
static void addFragmentToBackStack(@NonNull FragmentManager fragmentManager, int containerId,
|
|
38
|
+
@NonNull AwesomeFragment fragment, @NonNull TransitionAnimation animation,
|
|
39
|
+
@Nullable AwesomeFragment predecessor) {
|
|
34
40
|
FragmentTransaction transaction = fragmentManager.beginTransaction();
|
|
35
41
|
transaction.setReorderingAllowed(true);
|
|
36
42
|
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
transaction.
|
|
41
|
-
transaction.hide(topFragment);
|
|
43
|
+
if (predecessor != null && predecessor.isAdded()) {
|
|
44
|
+
predecessor.setAnimation(animation);
|
|
45
|
+
transaction.setMaxLifecycle(predecessor, Lifecycle.State.STARTED);
|
|
46
|
+
transaction.hide(predecessor);
|
|
42
47
|
}
|
|
43
48
|
fragment.setAnimation(animation);
|
|
44
49
|
|
|
@@ -213,6 +213,13 @@ public class StackFragment extends AwesomeFragment {
|
|
|
213
213
|
popToFragmentSync(rootFragment, completion, animation);
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
+
@Nullable
|
|
217
|
+
private AwesomeFragment mRedirectPrecursor;
|
|
218
|
+
|
|
219
|
+
boolean isRedirectPrecursor(@NonNull AwesomeFragment fragment) {
|
|
220
|
+
return mRedirectPrecursor == fragment;
|
|
221
|
+
}
|
|
222
|
+
|
|
216
223
|
public void redirectToFragment(@NonNull AwesomeFragment fragment) {
|
|
217
224
|
scheduleTaskAtStarted(() -> redirectToFragmentSync(fragment, () -> {
|
|
218
225
|
}, TransitionAnimation.Redirect, null));
|
|
@@ -241,34 +248,33 @@ public class StackFragment extends AwesomeFragment {
|
|
|
241
248
|
SystemUI.hideIme(getWindow());
|
|
242
249
|
}
|
|
243
250
|
|
|
244
|
-
topFragment
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
251
|
+
AwesomeFragment target = from != null ? from : topFragment;
|
|
252
|
+
if (target.getParentFragment() != this || FragmentHelper.getIndexAtBackStack(target) < 0) {
|
|
253
|
+
// Without an entry to pop (e.g. an embedded screen), the visual operation is a push.
|
|
254
|
+
TransitionAnimation pushAnimation = animation == TransitionAnimation.Redirect ? TransitionAnimation.Push : animation;
|
|
255
|
+
pushFragmentSync(fragment, completion, pushAnimation);
|
|
256
|
+
return;
|
|
249
257
|
}
|
|
250
258
|
|
|
259
|
+
topFragment.setAnimation(animation);
|
|
251
260
|
AwesomeFragment precursor = FragmentHelper.getFragmentBefore(target);
|
|
252
|
-
if (precursor != null && precursor.isAdded()) {
|
|
253
|
-
precursor.setAnimation(animation);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
261
|
FragmentManager fragmentManager = getChildFragmentManager();
|
|
257
|
-
fragmentManager.beginTransaction()
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
262
|
+
FragmentTransaction lifecycle = fragmentManager.beginTransaction()
|
|
263
|
+
.setMaxLifecycle(topFragment, Lifecycle.State.STARTED);
|
|
264
|
+
if (precursor != null) {
|
|
265
|
+
lifecycle.setMaxLifecycle(precursor, Lifecycle.State.RESUMED);
|
|
266
|
+
}
|
|
267
|
+
mRedirectPrecursor = precursor;
|
|
268
|
+
try {
|
|
269
|
+
// The replacement must record RESUMED as the state to restore when popped.
|
|
270
|
+
lifecycle.commitNow();
|
|
271
|
+
// Batch the visual operations so the outgoing view can slide under the incoming one.
|
|
272
|
+
fragmentManager.popBackStack(target.getSceneId(), FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
|
273
|
+
FragmentHelper.addFragmentToBackStack(fragmentManager, R.id.navigation_content, fragment, animation, precursor);
|
|
274
|
+
fragmentManager.executePendingTransactions();
|
|
275
|
+
} finally {
|
|
276
|
+
mRedirectPrecursor = null;
|
|
266
277
|
}
|
|
267
|
-
fragment.setAnimation(animation);
|
|
268
|
-
transaction.add(R.id.navigation_content, fragment, fragment.getSceneId());
|
|
269
|
-
transaction.addToBackStack(fragment.getSceneId());
|
|
270
|
-
transaction.commit();
|
|
271
|
-
fragmentManager.executePendingTransactions();
|
|
272
278
|
|
|
273
279
|
completion.run();
|
|
274
280
|
}
|
|
@@ -58,6 +58,9 @@ public class ReactFragment extends HybridFragment implements ReactManager.ReactB
|
|
|
58
58
|
@Override
|
|
59
59
|
public void onResume() {
|
|
60
60
|
super.onResume();
|
|
61
|
+
if (isResumingForRedirect()) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
61
64
|
if (isViewReady()) {
|
|
62
65
|
sendViewAppearEvent(true);
|
|
63
66
|
}
|
|
@@ -163,7 +166,7 @@ public class ReactFragment extends HybridFragment implements ReactManager.ReactB
|
|
|
163
166
|
}
|
|
164
167
|
firstRenderCompleted = true;
|
|
165
168
|
|
|
166
|
-
if (isViewReady() && isResumed()) {
|
|
169
|
+
if (isViewReady() && isResumed() && !isResumingForRedirect()) {
|
|
167
170
|
sendViewAppearEvent(true);
|
|
168
171
|
}
|
|
169
172
|
}
|
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": "4.0.
|
|
4
|
+
"version": "4.0.8",
|
|
5
5
|
"main": "./dist/index",
|
|
6
6
|
"module": "./dist/index",
|
|
7
7
|
"types": "./dist/index.d.ts",
|