瀏覽代碼

Rename startApp animation to setRoot

This commit also resolves the setRoot animations correctly with default options and current child options
Guy Carmeli 6 年之前
父節點
當前提交
b732226d7b

+ 4
- 4
lib/android/app/src/main/java/com/reactnativenavigation/parse/AnimationsOptions.java 查看文件

@@ -11,7 +11,7 @@ public class AnimationsOptions {
11 11
 
12 12
         options.push = NestedAnimationsOptions.parse(json.optJSONObject("push"));
13 13
         options.pop = NestedAnimationsOptions.parse(json.optJSONObject("pop"));
14
-        options.startApp = AnimationOptions.parse(json.optJSONObject("startApp"));
14
+        options.setRoot = AnimationOptions.parse(json.optJSONObject("setRoot"));
15 15
         options.showModal = AnimationOptions.parse(json.optJSONObject("showModal"));
16 16
         options.dismissModal = AnimationOptions.parse(json.optJSONObject("dismissModal"));
17 17
 
@@ -20,14 +20,14 @@ public class AnimationsOptions {
20 20
 
21 21
     public NestedAnimationsOptions push = new NestedAnimationsOptions();
22 22
     public NestedAnimationsOptions pop = new NestedAnimationsOptions();
23
-    public AnimationOptions startApp = new AnimationOptions();
23
+    public AnimationOptions setRoot = new AnimationOptions();
24 24
     public AnimationOptions showModal = new AnimationOptions();
25 25
     public AnimationOptions dismissModal = new AnimationOptions();
26 26
 
27 27
     public void mergeWith(AnimationsOptions other) {
28 28
         push.mergeWith(other.push);
29 29
         pop.mergeWith(other.pop);
30
-        startApp.mergeWith(other.startApp);
30
+        setRoot.mergeWith(other.setRoot);
31 31
         showModal.mergeWith(other.showModal);
32 32
         dismissModal.mergeWith(other.dismissModal);
33 33
     }
@@ -35,7 +35,7 @@ public class AnimationsOptions {
35 35
     void mergeWithDefault(AnimationsOptions defaultOptions) {
36 36
         push.mergeWithDefault(defaultOptions.push);
37 37
         pop.mergeWithDefault(defaultOptions.pop);
38
-        startApp.mergeWithDefault(defaultOptions.startApp);
38
+        setRoot.mergeWithDefault(defaultOptions.setRoot);
39 39
         showModal.mergeWithDefault(defaultOptions.showModal);
40 40
         dismissModal.mergeWithDefault(defaultOptions.dismissModal);
41 41
     }

+ 3
- 2
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/Navigator.java 查看文件

@@ -124,9 +124,10 @@ public class Navigator extends ParentController {
124 124
         }
125 125
         root = viewController;
126 126
         rootLayout.addView(viewController.getView());
127
-        if (viewController.options.animations.startApp.hasAnimation()) {
127
+        Options options = viewController.resolveCurrentOptions().withDefaultOptions(defaultOptions);
128
+        if (options.animations.setRoot.hasAnimation()) {
128 129
             new NavigationAnimator(viewController.getActivity(), new ElementTransitionManager())
129
-                    .animateStartApp(viewController.getView(), viewController.options.animations.startApp, new AnimatorListenerAdapter() {
130
+                    .animateStartApp(viewController.getView(), options.animations.setRoot, new AnimatorListenerAdapter() {
130 131
                         @Override
131 132
                         public void onAnimationEnd(Animator animation) {
132 133
                             commandListener.onSuccess(viewController.getId());

+ 1
- 1
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/NavigatorTest.java 查看文件

@@ -555,7 +555,7 @@ public class NavigatorTest extends BaseTest {
555 555
         disablePushAnimation(child1);
556 556
 
557 557
         StackController spy = spy(parentController);
558
-        spy.options.animations.startApp.enable = new Bool(false);
558
+        spy.options.animations.setRoot.enable = new Bool(false);
559 559
         uut.setRoot(spy, new CommandListenerAdapter());
560 560
         spy.push(child1, new CommandListenerAdapter());
561 561
         activityController.destroy();