|
@@ -1,14 +1,12 @@
|
1
|
|
-package com.reactnativenavigation.viewcontrollers;
|
|
1
|
+package com.reactnativenavigation.viewcontrollers.navigator;
|
2
|
2
|
|
3
|
|
-import android.animation.Animator;
|
4
|
|
-import android.animation.AnimatorListenerAdapter;
|
5
|
3
|
import android.app.Activity;
|
6
|
4
|
import android.support.annotation.NonNull;
|
7
|
5
|
import android.support.annotation.Nullable;
|
|
6
|
+import android.support.annotation.RestrictTo;
|
8
|
7
|
import android.view.ViewGroup;
|
9
|
8
|
import android.widget.FrameLayout;
|
10
|
9
|
|
11
|
|
-import com.reactnativenavigation.anim.NavigationAnimator;
|
12
|
10
|
import com.reactnativenavigation.parse.Options;
|
13
|
11
|
import com.reactnativenavigation.presentation.OptionsPresenter;
|
14
|
12
|
import com.reactnativenavigation.presentation.OverlayManager;
|
|
@@ -16,9 +14,11 @@ import com.reactnativenavigation.react.EventEmitter;
|
16
|
14
|
import com.reactnativenavigation.utils.CommandListener;
|
17
|
15
|
import com.reactnativenavigation.utils.CompatUtils;
|
18
|
16
|
import com.reactnativenavigation.utils.Task;
|
|
17
|
+import com.reactnativenavigation.viewcontrollers.ChildControllersRegistry;
|
|
18
|
+import com.reactnativenavigation.viewcontrollers.ParentController;
|
|
19
|
+import com.reactnativenavigation.viewcontrollers.ViewController;
|
19
|
20
|
import com.reactnativenavigation.viewcontrollers.modal.ModalStack;
|
20
|
21
|
import com.reactnativenavigation.viewcontrollers.stack.StackController;
|
21
|
|
-import com.reactnativenavigation.views.element.ElementTransitionManager;
|
22
|
22
|
|
23
|
23
|
import java.util.Collection;
|
24
|
24
|
import java.util.Collections;
|
|
@@ -27,6 +27,7 @@ public class Navigator extends ParentController {
|
27
|
27
|
|
28
|
28
|
private final ModalStack modalStack;
|
29
|
29
|
private final OverlayManager overlayManager;
|
|
30
|
+ private final RootPresenter rootPresenter;
|
30
|
31
|
private ViewController root;
|
31
|
32
|
private final FrameLayout rootLayout;
|
32
|
33
|
private final FrameLayout modalsLayout;
|
|
@@ -60,14 +61,19 @@ public class Navigator extends ParentController {
|
60
|
61
|
contentLayout.addView(overlaysLayout);
|
61
|
62
|
}
|
62
|
63
|
|
63
|
|
- public Navigator(final Activity activity, ChildControllersRegistry childRegistry, ModalStack modalStack, OverlayManager overlayManager) {
|
|
64
|
+ public Navigator(final Activity activity, ChildControllersRegistry childRegistry, ModalStack modalStack, OverlayManager overlayManager, RootPresenter rootPresenter) {
|
64
|
65
|
super(activity, childRegistry,"navigator" + CompatUtils.generateViewId(), new OptionsPresenter(activity, new Options()), new Options());
|
65
|
66
|
this.modalStack = modalStack;
|
66
|
67
|
this.overlayManager = overlayManager;
|
|
68
|
+ this.rootPresenter = rootPresenter;
|
67
|
69
|
rootLayout = new FrameLayout(getActivity());
|
68
|
70
|
modalsLayout = new FrameLayout(getActivity());
|
69
|
71
|
overlaysLayout = new FrameLayout(getActivity());
|
|
72
|
+ }
|
|
73
|
+
|
|
74
|
+ public void bindViews() {
|
70
|
75
|
modalStack.setModalsContainer(modalsLayout);
|
|
76
|
+ rootPresenter.setRootContainer(rootLayout);
|
71
|
77
|
}
|
72
|
78
|
|
73
|
79
|
@NonNull
|
|
@@ -123,19 +129,7 @@ public class Navigator extends ParentController {
|
123
|
129
|
getView();
|
124
|
130
|
}
|
125
|
131
|
root = viewController;
|
126
|
|
- rootLayout.addView(viewController.getView());
|
127
|
|
- Options options = viewController.resolveCurrentOptions().withDefaultOptions(defaultOptions);
|
128
|
|
- if (options.animations.setRoot.hasAnimation()) {
|
129
|
|
- new NavigationAnimator(viewController.getActivity(), new ElementTransitionManager())
|
130
|
|
- .animateStartApp(viewController.getView(), options.animations.setRoot, new AnimatorListenerAdapter() {
|
131
|
|
- @Override
|
132
|
|
- public void onAnimationEnd(Animator animation) {
|
133
|
|
- commandListener.onSuccess(viewController.getId());
|
134
|
|
- }
|
135
|
|
- });
|
136
|
|
- } else {
|
137
|
|
- commandListener.onSuccess(viewController.getId());
|
138
|
|
- }
|
|
132
|
+ rootPresenter.setRoot(root, defaultOptions, commandListener);
|
139
|
133
|
}
|
140
|
134
|
|
141
|
135
|
private void removePreviousContentView() {
|
|
@@ -221,4 +215,9 @@ public class Navigator extends ParentController {
|
221
|
215
|
private boolean isRootNotCreated() {
|
222
|
216
|
return view == null;
|
223
|
217
|
}
|
|
218
|
+
|
|
219
|
+ @RestrictTo(RestrictTo.Scope.TESTS)
|
|
220
|
+ public FrameLayout getModalsLayout() {
|
|
221
|
+ return modalsLayout;
|
|
222
|
+ }
|
224
|
223
|
}
|