Browse Source

Rename enabled to enable in animation options

Guy Carmeli 6 years ago
parent
commit
85e321ad18

+ 5
- 3
lib/android/app/src/main/java/com/reactnativenavigation/parse/NestedAnimationsOptions.java View File

3
 
3
 
4
 import com.reactnativenavigation.parse.params.Bool;
4
 import com.reactnativenavigation.parse.params.Bool;
5
 import com.reactnativenavigation.parse.params.NullBool;
5
 import com.reactnativenavigation.parse.params.NullBool;
6
+import com.reactnativenavigation.parse.parsers.BoolParser;
6
 
7
 
7
 import org.json.JSONObject;
8
 import org.json.JSONObject;
8
 
9
 
14
         options.content = AnimationOptions.parse(json.optJSONObject("content"));
15
         options.content = AnimationOptions.parse(json.optJSONObject("content"));
15
         options.bottomTabs = AnimationOptions.parse(json.optJSONObject("bottomTabs"));
16
         options.bottomTabs = AnimationOptions.parse(json.optJSONObject("bottomTabs"));
16
         options.topBar = AnimationOptions.parse(json.optJSONObject("topBar"));
17
         options.topBar = AnimationOptions.parse(json.optJSONObject("topBar"));
18
+        options.enable = BoolParser.parse(json, "enable");
17
 
19
 
18
         return options;
20
         return options;
19
     }
21
     }
20
 
22
 
21
-    public Bool enabled = new NullBool();
23
+    public Bool enable = new NullBool();
22
     public AnimationOptions content = new AnimationOptions();
24
     public AnimationOptions content = new AnimationOptions();
23
     public AnimationOptions bottomTabs = new AnimationOptions();
25
     public AnimationOptions bottomTabs = new AnimationOptions();
24
     public AnimationOptions topBar = new AnimationOptions();
26
     public AnimationOptions topBar = new AnimationOptions();
27
         topBar.mergeWith(other.topBar);
29
         topBar.mergeWith(other.topBar);
28
         content.mergeWith(other.content);
30
         content.mergeWith(other.content);
29
         bottomTabs.mergeWith(other.bottomTabs);
31
         bottomTabs.mergeWith(other.bottomTabs);
30
-        if (other.enabled.hasValue()) enabled = other.enabled;
32
+        if (other.enable.hasValue()) enable = other.enable;
31
     }
33
     }
32
 
34
 
33
     void mergeWithDefault(NestedAnimationsOptions defaultOptions) {
35
     void mergeWithDefault(NestedAnimationsOptions defaultOptions) {
34
         content.mergeWithDefault(defaultOptions.content);
36
         content.mergeWithDefault(defaultOptions.content);
35
         bottomTabs.mergeWithDefault(defaultOptions.bottomTabs);
37
         bottomTabs.mergeWithDefault(defaultOptions.bottomTabs);
36
         topBar.mergeWithDefault(defaultOptions.topBar);
38
         topBar.mergeWithDefault(defaultOptions.topBar);
37
-        if (!enabled.hasValue()) enabled = defaultOptions.enabled;
39
+        if (!enable.hasValue()) enable = defaultOptions.enable;
38
     }
40
     }
39
 
41
 
40
     public boolean hasValue() {
42
     public boolean hasValue() {

+ 3
- 3
lib/android/app/src/main/java/com/reactnativenavigation/presentation/OptionsPresenter.java View File

62
         if (options.testId.hasValue()) topBar.setTestId(options.testId.get());
62
         if (options.testId.hasValue()) topBar.setTestId(options.testId.get());
63
 
63
 
64
         if (options.visible.isFalse()) {
64
         if (options.visible.isFalse()) {
65
-            if (options.animate.isTrueOrUndefined() && componentOptions.animations.push.enabled.isTrueOrUndefined()) {
65
+            if (options.animate.isTrueOrUndefined() && componentOptions.animations.push.enable.isTrueOrUndefined()) {
66
                 topBar.hideAnimate(animationOptions.pop.topBar);
66
                 topBar.hideAnimate(animationOptions.pop.topBar);
67
             } else {
67
             } else {
68
                 topBar.hide();
68
                 topBar.hide();
69
             }
69
             }
70
         }
70
         }
71
         if (options.visible.isTrueOrUndefined()) {
71
         if (options.visible.isTrueOrUndefined()) {
72
-            if (options.animate.isTrueOrUndefined() && componentOptions.animations.push.enabled.isTrueOrUndefined()) {
72
+            if (options.animate.isTrueOrUndefined() && componentOptions.animations.push.enable.isTrueOrUndefined()) {
73
                 topBar.showAnimate(animationOptions.push.topBar);
73
                 topBar.showAnimate(animationOptions.push.topBar);
74
             } else {
74
             } else {
75
                 topBar.show();
75
                 topBar.show();
106
 
106
 
107
     public void onChildWillPop(Options disappearing, Options appearing) {
107
     public void onChildWillPop(Options disappearing, Options appearing) {
108
         if (disappearing.topBar.visible.isTrueOrUndefined() && appearing.topBar.visible.isFalse()) {
108
         if (disappearing.topBar.visible.isTrueOrUndefined() && appearing.topBar.visible.isFalse()) {
109
-            if (disappearing.topBar.animate.isTrueOrUndefined() && disappearing.animations.pop.enabled.isTrueOrUndefined()) {
109
+            if (disappearing.topBar.animate.isTrueOrUndefined() && disappearing.animations.pop.enable.isTrueOrUndefined()) {
110
                 topBar.hideAnimate(disappearing.animations.pop.topBar);
110
                 topBar.hideAnimate(disappearing.animations.pop.topBar);
111
             } else {
111
             } else {
112
                 topBar.hide();
112
                 topBar.hide();

+ 2
- 2
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/StackController.java View File

96
         getView().addView(child.getView(), MATCH_PARENT, MATCH_PARENT);
96
         getView().addView(child.getView(), MATCH_PARENT, MATCH_PARENT);
97
 
97
 
98
         if (toRemove != null) {
98
         if (toRemove != null) {
99
-            if (child.options.animations.push.enabled.isTrueOrUndefined()) {
99
+            if (child.options.animations.push.enable.isTrueOrUndefined()) {
100
                 animator.push(child.getView(), () -> {
100
                 animator.push(child.getView(), () -> {
101
                     getView().removeView(toRemove.getView());
101
                     getView().removeView(toRemove.getView());
102
                     listener.onSuccess(child.getId());
102
                     listener.onSuccess(child.getId());
143
         getView().addView(appearing.getView(), 0);
143
         getView().addView(appearing.getView(), 0);
144
         getView().onChildWillPop(disappearing.options, appearing.options);
144
         getView().onChildWillPop(disappearing.options, appearing.options);
145
 
145
 
146
-        if (disappearing.options.animations.pop.enabled.isTrueOrUndefined()) {
146
+        if (disappearing.options.animations.pop.enable.isTrueOrUndefined()) {
147
             animator.pop(disappearing.getView(), () -> finishPopping(disappearing, listener));
147
             animator.pop(disappearing.getView(), () -> finishPopping(disappearing, listener));
148
         } else {
148
         } else {
149
             finishPopping(disappearing, listener);
149
             finishPopping(disappearing, listener);

+ 1
- 1
lib/android/app/src/test/java/com/reactnativenavigation/BaseTest.java View File

47
 
47
 
48
     protected void disablePushAnimation(ViewController... controllers) {
48
     protected void disablePushAnimation(ViewController... controllers) {
49
         for (ViewController controller : controllers) {
49
         for (ViewController controller : controllers) {
50
-            controller.options.animations.push.enabled = new Bool(false);
50
+            controller.options.animations.push.enable = new Bool(false);
51
         }
51
         }
52
     }
52
     }
53
 }
53
 }

+ 2
- 2
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/NavigatorTest.java View File

346
 
346
 
347
     @Test
347
     @Test
348
     public void pushedStackCanBePopped() {
348
     public void pushedStackCanBePopped() {
349
-        child1.options.animations.push.enabled = new Bool(false);
350
-        child2.options.animations.push.enabled = new Bool(false);
349
+        child1.options.animations.push.enable = new Bool(false);
350
+        child2.options.animations.push.enable = new Bool(false);
351
         StackController parent = newStack();
351
         StackController parent = newStack();
352
         parent.ensureViewIsCreated();
352
         parent.ensureViewIsCreated();
353
         uut.setRoot(parent, new MockPromise());
353
         uut.setRoot(parent, new MockPromise());

+ 13
- 13
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/StackControllerTest.java View File

279
 
279
 
280
         child1.options.topBar.visible = new Bool(false);
280
         child1.options.topBar.visible = new Bool(false);
281
         child1.options.topBar.animate = new Bool(false);
281
         child1.options.topBar.animate = new Bool(false);
282
-        child1.options.animations.push.enabled = new Bool(false);
282
+        child1.options.animations.push.enable = new Bool(false);
283
 
283
 
284
         uut.push(child1, new CommandListenerAdapter());
284
         uut.push(child1, new CommandListenerAdapter());
285
         uut.push(child2, new CommandListenerAdapter() {
285
         uut.push(child2, new CommandListenerAdapter() {
384
 
384
 
385
     @Test
385
     @Test
386
     public void popToRoot_PopsEverythingAboveFirstController() {
386
     public void popToRoot_PopsEverythingAboveFirstController() {
387
-        child1.options.animations.push.enabled = new Bool(false);
388
-        child2.options.animations.push.enabled = new Bool(false);
387
+        child1.options.animations.push.enable = new Bool(false);
388
+        child2.options.animations.push.enable = new Bool(false);
389
 
389
 
390
         uut.push(child1, new CommandListenerAdapter());
390
         uut.push(child1, new CommandListenerAdapter());
391
         uut.push(child2, new CommandListenerAdapter());
391
         uut.push(child2, new CommandListenerAdapter());
408
 
408
 
409
     @Test
409
     @Test
410
     public void popToRoot_onlyTopChildIsAnimated() {
410
     public void popToRoot_onlyTopChildIsAnimated() {
411
-        child1.options.animations.push.enabled = new Bool(false);
412
-        child2.options.animations.push.enabled = new Bool(false);
411
+        child1.options.animations.push.enable = new Bool(false);
412
+        child2.options.animations.push.enable = new Bool(false);
413
 
413
 
414
         uut.push(child1, new CommandListenerAdapter());
414
         uut.push(child1, new CommandListenerAdapter());
415
         uut.push(child2, new CommandListenerAdapter());
415
         uut.push(child2, new CommandListenerAdapter());
428
 
428
 
429
     @Test
429
     @Test
430
     public void popToRoot_topChildrenAreDestroyed() {
430
     public void popToRoot_topChildrenAreDestroyed() {
431
-        child1.options.animations.push.enabled = new Bool(false);
432
-        child2.options.animations.push.enabled = new Bool(false);
433
-        child3.options.animations.push.enabled = new Bool(false);
431
+        child1.options.animations.push.enable = new Bool(false);
432
+        child2.options.animations.push.enable = new Bool(false);
433
+        child3.options.animations.push.enable = new Bool(false);
434
 
434
 
435
         uut.push(child1, new CommandListenerAdapter());
435
         uut.push(child1, new CommandListenerAdapter());
436
         uut.push(child2, new CommandListenerAdapter());
436
         uut.push(child2, new CommandListenerAdapter());
490
 
490
 
491
     @Test
491
     @Test
492
     public void pop_callWillAppearWillDisappear() {
492
     public void pop_callWillAppearWillDisappear() {
493
-        child1.options.animations.push.enabled = new Bool(false);
494
-        child2.options.animations.push.enabled = new Bool(false);
493
+        child1.options.animations.push.enable = new Bool(false);
494
+        child2.options.animations.push.enable = new Bool(false);
495
         child1 = spy(child1);
495
         child1 = spy(child1);
496
         child2 = spy(child2);
496
         child2 = spy(child2);
497
         uut.push(child1, new CommandListenerAdapter());
497
         uut.push(child1, new CommandListenerAdapter());
506
         uut.ensureViewIsCreated();
506
         uut.ensureViewIsCreated();
507
 
507
 
508
         child1.options.topBar.visible = new Bool(false);
508
         child1.options.topBar.visible = new Bool(false);
509
-        child1.options.animations.push.enabled = new Bool(false);
510
-        child2.options.animations.push.enabled = new Bool(true);
509
+        child1.options.animations.push.enable = new Bool(false);
510
+        child2.options.animations.push.enable = new Bool(true);
511
         uut.push(child1, new CommandListenerAdapter() {
511
         uut.push(child1, new CommandListenerAdapter() {
512
             @Override
512
             @Override
513
             public void onSuccess(String childId) {
513
             public void onSuccess(String childId) {
534
 
534
 
535
         child1.options.topBar.visible = new Bool(false);
535
         child1.options.topBar.visible = new Bool(false);
536
         child1.options.topBar.animate = new Bool(false);
536
         child1.options.topBar.animate = new Bool(false);
537
-        child2.options.animations.push.enabled = new Bool(false);
537
+        child2.options.animations.push.enable = new Bool(false);
538
         child2.options.topBar.animate = new Bool(false);
538
         child2.options.topBar.animate = new Bool(false);
539
 
539
 
540
         child1.ensureViewIsCreated();
540
         child1.ensureViewIsCreated();

+ 2
- 2
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/TopTabsViewControllerTest.java View File

231
                 new TestComponentViewCreator(),
231
                 new TestComponentViewCreator(),
232
                 new Options()
232
                 new Options()
233
         );
233
         );
234
-        first.options.animations.push.enabled = new Bool(false);
235
-        uut.options.animations.push.enabled = new Bool(false);
234
+        first.options.animations.push.enable = new Bool(false);
235
+        uut.options.animations.push.enable = new Bool(false);
236
         stackController.push(first, new CommandListenerAdapter());
236
         stackController.push(first, new CommandListenerAdapter());
237
         stackController.push(uut, new CommandListenerAdapter());
237
         stackController.push(uut, new CommandListenerAdapter());
238
 
238