Quellcode durchsuchen

V2 anim (#2772)

* options

* proof of concept

* pop

* test fix

* default options

* scale

* rotation

* null check

* refactor

* refactor

* refactoring

* fix tests
Roman Kozlov vor 6 Jahren
Ursprung
Commit
ca93326f28
61 geänderte Dateien mit 547 neuen und 124 gelöschten Zeilen
  1. 6
    0
      lib/android/app/src/main/java/com/reactnativenavigation/anim/AnimationListener.java
  2. 1
    0
      lib/android/app/src/main/java/com/reactnativenavigation/anim/FabAnimator.java
  3. 46
    17
      lib/android/app/src/main/java/com/reactnativenavigation/anim/NavigationAnimator.java
  4. 49
    49
      lib/android/app/src/main/java/com/reactnativenavigation/anim/ViewAnimationSetBuilder.java
  5. 84
    0
      lib/android/app/src/main/java/com/reactnativenavigation/parse/AnimationOptions.java
  6. 43
    0
      lib/android/app/src/main/java/com/reactnativenavigation/parse/AnimationsOptions.java
  7. 4
    0
      lib/android/app/src/main/java/com/reactnativenavigation/parse/BottomTabOptions.java
  8. 9
    0
      lib/android/app/src/main/java/com/reactnativenavigation/parse/BottomTabsOptions.java
  9. 6
    0
      lib/android/app/src/main/java/com/reactnativenavigation/parse/FabOptions.java
  10. 1
    1
      lib/android/app/src/main/java/com/reactnativenavigation/parse/LayoutNode.java
  11. 5
    0
      lib/android/app/src/main/java/com/reactnativenavigation/parse/Options.java
  12. 10
    0
      lib/android/app/src/main/java/com/reactnativenavigation/parse/TopBarOptions.java
  13. 3
    0
      lib/android/app/src/main/java/com/reactnativenavigation/parse/TopTabOptions.java
  14. 6
    0
      lib/android/app/src/main/java/com/reactnativenavigation/parse/TopTabsOptions.java
  15. 69
    0
      lib/android/app/src/main/java/com/reactnativenavigation/parse/ValueAnimationOptions.java
  16. 0
    2
      lib/android/app/src/main/java/com/reactnativenavigation/parse/params/Bool.java
  17. 3
    4
      lib/android/app/src/main/java/com/reactnativenavigation/parse/params/Button.java
  18. 1
    1
      lib/android/app/src/main/java/com/reactnativenavigation/parse/params/Color.java
  19. 9
    0
      lib/android/app/src/main/java/com/reactnativenavigation/parse/params/FloatParam.java
  20. 1
    1
      lib/android/app/src/main/java/com/reactnativenavigation/parse/params/Fraction.java
  21. 26
    0
      lib/android/app/src/main/java/com/reactnativenavigation/parse/params/Interpolation.java
  22. 2
    2
      lib/android/app/src/main/java/com/reactnativenavigation/parse/params/NullColor.java
  23. 14
    0
      lib/android/app/src/main/java/com/reactnativenavigation/parse/params/NullFloatParam.java
  24. 2
    2
      lib/android/app/src/main/java/com/reactnativenavigation/parse/params/NullFraction.java
  25. 2
    2
      lib/android/app/src/main/java/com/reactnativenavigation/parse/params/NullNumber.java
  26. 1
    1
      lib/android/app/src/main/java/com/reactnativenavigation/parse/params/NullText.java
  27. 1
    1
      lib/android/app/src/main/java/com/reactnativenavigation/parse/params/Number.java
  28. 1
    1
      lib/android/app/src/main/java/com/reactnativenavigation/parse/params/Param.java
  29. 1
    1
      lib/android/app/src/main/java/com/reactnativenavigation/parse/params/Text.java
  30. 4
    1
      lib/android/app/src/main/java/com/reactnativenavigation/parse/parsers/ColorParser.java
  31. 14
    0
      lib/android/app/src/main/java/com/reactnativenavigation/parse/parsers/FloatParser.java
  32. 4
    1
      lib/android/app/src/main/java/com/reactnativenavigation/parse/parsers/FractionParser.java
  33. 23
    0
      lib/android/app/src/main/java/com/reactnativenavigation/parse/parsers/InterpolationParser.java
  34. 1
    1
      lib/android/app/src/main/java/com/reactnativenavigation/parse/parsers/JSONParser.java
  35. 3
    1
      lib/android/app/src/main/java/com/reactnativenavigation/parse/parsers/LayoutNodeParser.java
  36. 4
    1
      lib/android/app/src/main/java/com/reactnativenavigation/parse/parsers/NumberParser.java
  37. 4
    1
      lib/android/app/src/main/java/com/reactnativenavigation/parse/parsers/TextParser.java
  38. 1
    1
      lib/android/app/src/main/java/com/reactnativenavigation/presentation/OptionsPresenter.java
  39. 2
    2
      lib/android/app/src/main/java/com/reactnativenavigation/react/NavigationModule.java
  40. 1
    1
      lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/BottomTabsController.java
  41. 1
    0
      lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/StackController.java
  42. 1
    1
      lib/android/app/src/main/java/com/reactnativenavigation/views/BottomTabs.java
  43. 2
    2
      lib/android/app/src/main/java/com/reactnativenavigation/views/TitleBarButton.java
  44. 4
    4
      lib/android/app/src/main/java/com/reactnativenavigation/views/TopBar.java
  45. 2
    2
      lib/android/app/src/main/java/com/reactnativenavigation/views/TopTabs.java
  46. 2
    2
      lib/android/app/src/main/java/com/reactnativenavigation/views/TopTabsStyleHelper.java
  47. 2
    2
      lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestNavigationAnimator.java
  48. 1
    0
      lib/android/app/src/test/java/com/reactnativenavigation/parse/JSONParserTest.java
  49. 1
    0
      lib/android/app/src/test/java/com/reactnativenavigation/parse/LayoutNodeParserTest.java
  50. 3
    2
      lib/android/app/src/test/java/com/reactnativenavigation/parse/OptionsTest.java
  51. 1
    1
      lib/android/app/src/test/java/com/reactnativenavigation/utils/OptionHelper.java
  52. 1
    1
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/BottomTabsControllerTest.java
  53. 1
    1
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/FloatingActionButtonTest.java
  54. 1
    1
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/NavigatorTest.java
  55. 4
    4
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/OptionsApplyingTest.java
  56. 1
    1
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/ParentControllerTest.java
  57. 1
    1
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/StackControllerTest.java
  58. 1
    1
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/TopTabsViewControllerTest.java
  59. 2
    2
      lib/android/app/src/test/java/com/reactnativenavigation/views/TopBarTest.java
  60. 46
    0
      playground/src/app.js
  61. 2
    1
      playground/src/screens/OptionsScreen.js

+ 6
- 0
lib/android/app/src/main/java/com/reactnativenavigation/anim/AnimationListener.java Datei anzeigen

@@ -0,0 +1,6 @@
1
+package com.reactnativenavigation.anim;
2
+
3
+
4
+public interface AnimationListener {
5
+    void onAnimationEnd();
6
+}

+ 1
- 0
lib/android/app/src/main/java/com/reactnativenavigation/anim/FabAnimator.java Datei anzeigen

@@ -3,5 +3,6 @@ package com.reactnativenavigation.anim;
3 3
 
4 4
 public interface FabAnimator {
5 5
     void show();
6
+
6 7
     void hide();
7 8
 }

+ 46
- 17
lib/android/app/src/main/java/com/reactnativenavigation/anim/NavigationAnimator.java Datei anzeigen

@@ -5,19 +5,19 @@ import android.animation.AnimatorListenerAdapter;
5 5
 import android.animation.AnimatorSet;
6 6
 import android.animation.ObjectAnimator;
7 7
 import android.content.Context;
8
+import android.support.annotation.NonNull;
8 9
 import android.support.annotation.Nullable;
9 10
 import android.view.View;
10 11
 import android.view.animation.AccelerateInterpolator;
11 12
 import android.view.animation.DecelerateInterpolator;
12 13
 
14
+import com.reactnativenavigation.parse.AnimationsOptions;
13 15
 import com.reactnativenavigation.utils.UiUtils;
14 16
 
15 17
 @SuppressWarnings("ResourceType")
16 18
 public class NavigationAnimator {
17 19
 
18
-    public interface NavigationAnimationListener {
19
-        void onAnimationEnd();
20
-    }
20
+    private AnimationsOptions options = new AnimationsOptions();
21 21
 
22 22
     private static final int DURATION = 300;
23 23
     private static final DecelerateInterpolator DECELERATE_INTERPOLATOR = new DecelerateInterpolator();
@@ -28,12 +28,14 @@ public class NavigationAnimator {
28 28
         translationY = UiUtils.getWindowHeight(context);
29 29
     }
30 30
 
31
-    public void animatePush(final View view, @Nullable final NavigationAnimationListener animationListener) {
31
+    public void animatePush(final View view, @Nullable final AnimationListener animationListener) {
32 32
         view.setVisibility(View.INVISIBLE);
33
-        ObjectAnimator alpha = ObjectAnimator.ofFloat(view, View.ALPHA, 0, 1);
34
-        alpha.setInterpolator(DECELERATE_INTERPOLATOR);
35
-
36
-        AnimatorSet set = new AnimatorSet();
33
+        AnimatorSet set;
34
+        if (options.push.hasValue()) {
35
+            set = options.push.getAnimation(view);
36
+        } else {
37
+            set = getDefaultPushAnimation(view);
38
+        }
37 39
         set.addListener(new AnimatorListenerAdapter() {
38 40
             @Override
39 41
             public void onAnimationStart(Animator animation) {
@@ -47,19 +49,30 @@ public class NavigationAnimator {
47 49
                 }
48 50
             }
49 51
         });
52
+        set.start();
53
+    }
54
+
55
+    @NonNull
56
+    private AnimatorSet getDefaultPushAnimation(View view) {
57
+        ObjectAnimator alpha = ObjectAnimator.ofFloat(view, View.ALPHA, 0, 1);
58
+        alpha.setInterpolator(DECELERATE_INTERPOLATOR);
59
+
60
+        AnimatorSet set = new AnimatorSet();
50 61
         ObjectAnimator translationY = ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, this.translationY, 0);
51 62
         translationY.setInterpolator(DECELERATE_INTERPOLATOR);
52 63
         translationY.setDuration(DURATION);
53 64
         alpha.setDuration(DURATION);
54 65
         set.playTogether(translationY, alpha);
55
-        set.start();
66
+        return set;
56 67
     }
57 68
 
58
-    public void animatePop(View view, @Nullable final NavigationAnimationListener animationListener) {
59
-        ObjectAnimator alpha = ObjectAnimator.ofFloat(view, View.ALPHA, 1, 0);
60
-        ObjectAnimator translationY = ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, 0, this.translationY);
61
-
62
-        AnimatorSet set = new AnimatorSet();
69
+    public void animatePop(View view, @Nullable final AnimationListener animationListener) {
70
+        AnimatorSet set;
71
+        if (options.pop.hasValue()) {
72
+            set = options.pop.getAnimation(view);
73
+        } else {
74
+            set = getDefaultPopAnimation(view);
75
+        }
63 76
         set.addListener(new AnimatorListenerAdapter() {
64 77
             @Override
65 78
             public void onAnimationEnd(Animator animation) {
@@ -68,9 +81,25 @@ public class NavigationAnimator {
68 81
                 }
69 82
             }
70 83
         });
71
-        set.playTogether(translationY, alpha);
72
-        set.setDuration(DURATION);
73
-        set.setInterpolator(ACCELERATE_INTERPOLATOR);
74 84
         set.start();
75 85
     }
86
+
87
+    @NonNull
88
+    private AnimatorSet getDefaultPopAnimation(View view) {
89
+        AnimatorSet set = new AnimatorSet();
90
+
91
+        ObjectAnimator alpha = ObjectAnimator.ofFloat(view, View.ALPHA, 1, 0);
92
+        alpha.setInterpolator(ACCELERATE_INTERPOLATOR);
93
+
94
+        ObjectAnimator translationY = ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, 0, this.translationY);
95
+        translationY.setInterpolator(ACCELERATE_INTERPOLATOR);
96
+        translationY.setDuration(DURATION);
97
+        alpha.setDuration(DURATION);
98
+        set.playTogether(translationY, alpha);
99
+        return set;
100
+    }
101
+
102
+    public void setOptions(AnimationsOptions options) {
103
+        this.options = options;
104
+    }
76 105
 }

+ 49
- 49
lib/android/app/src/main/java/com/reactnativenavigation/anim/ViewAnimationSetBuilder.java Datei anzeigen

@@ -8,53 +8,53 @@ import java.util.List;
8 8
 
9 9
 public class ViewAnimationSetBuilder implements Animation.AnimationListener {
10 10
 
11
-	private Runnable onComplete;
12
-	private List<View> views = new ArrayList<>();
13
-	private List<Animation> pendingAnimations = new ArrayList<>();
14
-	private boolean started = false;
15
-
16
-	public ViewAnimationSetBuilder withEndListener(Runnable onComplete) {
17
-		this.onComplete = onComplete;
18
-		return this;
19
-	}
20
-
21
-	public ViewAnimationSetBuilder add(View view, Animation animation) {
22
-		views.add(view);
23
-		pendingAnimations.add(animation);
24
-		animation.setAnimationListener(this);
25
-		view.setAnimation(animation);
26
-		return this;
27
-	}
28
-
29
-	public void start() {
30
-		for (Animation animation : pendingAnimations) {
31
-			animation.start();
32
-		}
33
-		started = true;
34
-		if (pendingAnimations.isEmpty()) finish();
35
-	}
36
-
37
-	@Override
38
-	public void onAnimationStart(final Animation animation) {
39
-		// nothing
40
-	}
41
-
42
-	@Override
43
-	public void onAnimationEnd(final Animation animation) {
44
-		pendingAnimations.remove(animation);
45
-		if (started && pendingAnimations.isEmpty()) finish();
46
-	}
47
-
48
-	@Override
49
-	public void onAnimationRepeat(final Animation animation) {
50
-		// nothing
51
-	}
52
-
53
-	private void finish() {
54
-		for (View view : views) {
55
-			view.clearAnimation();
56
-		}
57
-		views.clear();
58
-		if (onComplete != null) onComplete.run();
59
-	}
11
+    private Runnable onComplete;
12
+    private List<View> views = new ArrayList<>();
13
+    private List<Animation> pendingAnimations = new ArrayList<>();
14
+    private boolean started = false;
15
+
16
+    public ViewAnimationSetBuilder withEndListener(Runnable onComplete) {
17
+        this.onComplete = onComplete;
18
+        return this;
19
+    }
20
+
21
+    public ViewAnimationSetBuilder add(View view, Animation animation) {
22
+        views.add(view);
23
+        pendingAnimations.add(animation);
24
+        animation.setAnimationListener(this);
25
+        view.setAnimation(animation);
26
+        return this;
27
+    }
28
+
29
+    public void start() {
30
+        for (Animation animation : pendingAnimations) {
31
+            animation.start();
32
+        }
33
+        started = true;
34
+        if (pendingAnimations.isEmpty()) finish();
35
+    }
36
+
37
+    @Override
38
+    public void onAnimationStart(final Animation animation) {
39
+        // nothing
40
+    }
41
+
42
+    @Override
43
+    public void onAnimationEnd(final Animation animation) {
44
+        pendingAnimations.remove(animation);
45
+        if (started && pendingAnimations.isEmpty()) finish();
46
+    }
47
+
48
+    @Override
49
+    public void onAnimationRepeat(final Animation animation) {
50
+        // nothing
51
+    }
52
+
53
+    private void finish() {
54
+        for (View view : views) {
55
+            view.clearAnimation();
56
+        }
57
+        views.clear();
58
+        if (onComplete != null) onComplete.run();
59
+    }
60 60
 }

+ 84
- 0
lib/android/app/src/main/java/com/reactnativenavigation/parse/AnimationOptions.java Datei anzeigen

@@ -0,0 +1,84 @@
1
+package com.reactnativenavigation.parse;
2
+
3
+
4
+import android.animation.Animator;
5
+import android.animation.AnimatorSet;
6
+import android.util.Property;
7
+import android.view.View;
8
+
9
+import org.json.JSONObject;
10
+
11
+import java.util.ArrayList;
12
+import java.util.HashSet;
13
+import java.util.Iterator;
14
+import java.util.List;
15
+
16
+public class AnimationOptions {
17
+
18
+    public static AnimationOptions parse(JSONObject json) {
19
+        AnimationOptions options = new AnimationOptions();
20
+        if (json == null) return options;
21
+
22
+        options.hasValue = true;
23
+        for (Iterator<String> it = json.keys(); it.hasNext(); ) {
24
+            String key = it.next();
25
+            options.valueOptions.add(ValueAnimationOptions.parse(json.optJSONObject(key), getAnimProp(key)));
26
+        }
27
+
28
+        return options;
29
+    }
30
+
31
+    private boolean hasValue = false;
32
+
33
+    private HashSet<ValueAnimationOptions> valueOptions = new HashSet<>();
34
+
35
+    void mergeWith(AnimationOptions other) {
36
+        if (other.hasValue()) {
37
+            hasValue = true;
38
+            valueOptions = other.valueOptions;
39
+        }
40
+    }
41
+
42
+    void mergeWithDefault(AnimationOptions defaultOptions) {
43
+        if (defaultOptions.hasValue()) {
44
+            hasValue = true;
45
+            valueOptions = defaultOptions.valueOptions;
46
+        }
47
+    }
48
+
49
+    public boolean hasValue() {
50
+        return hasValue;
51
+    }
52
+
53
+    public AnimatorSet getAnimation(View view) {
54
+        AnimatorSet animationSet = new AnimatorSet();
55
+        List<Animator> animators = new ArrayList<>();
56
+        for (ValueAnimationOptions options: valueOptions) {
57
+            animators.add(options.getAnimation(view));
58
+        }
59
+        animationSet.playTogether(animators);
60
+        return animationSet;
61
+    }
62
+
63
+    private static Property<View, Float> getAnimProp(String key) {
64
+        switch (key) {
65
+            case "y":
66
+                return View.TRANSLATION_Y;
67
+            case "x":
68
+                return View.TRANSLATION_X;
69
+            case "alpha":
70
+                return View.ALPHA;
71
+            case "scaleY":
72
+                return View.SCALE_Y;
73
+            case "scaleX":
74
+                return View.SCALE_X;
75
+            case "rotationX":
76
+                return View.ROTATION_X;
77
+            case "rotationY":
78
+                return View.ROTATION_Y;
79
+            case "rotation":
80
+                return View.ROTATION;
81
+        }
82
+        throw new IllegalArgumentException("This animation is not supported: " + key);
83
+    }
84
+}

+ 43
- 0
lib/android/app/src/main/java/com/reactnativenavigation/parse/AnimationsOptions.java Datei anzeigen

@@ -0,0 +1,43 @@
1
+package com.reactnativenavigation.parse;
2
+
3
+
4
+import org.json.JSONObject;
5
+
6
+public class AnimationsOptions {
7
+
8
+    public static AnimationsOptions parse(JSONObject json) {
9
+        AnimationsOptions options = new AnimationsOptions();
10
+        if (json == null) return options;
11
+
12
+        options.push = AnimationOptions.parse(json.optJSONObject("push"));
13
+        options.pop = AnimationOptions.parse(json.optJSONObject("pop"));
14
+        options.startApp = AnimationOptions.parse(json.optJSONObject("startApp"));
15
+        options.showModal = AnimationOptions.parse(json.optJSONObject("showModal"));
16
+        options.dismissModal = AnimationOptions.parse(json.optJSONObject("dismissModal"));
17
+
18
+        return options;
19
+    }
20
+
21
+    public AnimationOptions push = new AnimationOptions();
22
+    public AnimationOptions pop = new AnimationOptions();
23
+    public AnimationOptions startApp = new AnimationOptions();
24
+    public AnimationOptions showModal = new AnimationOptions();
25
+    public AnimationOptions dismissModal = new AnimationOptions();
26
+
27
+    void mergeWith(AnimationsOptions other) {
28
+        push.mergeWith(other.push);
29
+        pop.mergeWith(other.pop);
30
+        startApp.mergeWith(other.startApp);
31
+        showModal.mergeWith(other.showModal);
32
+        dismissModal.mergeWith(other.dismissModal);
33
+
34
+    }
35
+
36
+    void mergeWithDefault(AnimationsOptions defaultOptions) {
37
+        push.mergeWithDefault(defaultOptions.push);
38
+        pop.mergeWithDefault(defaultOptions.pop);
39
+        startApp.mergeWithDefault(defaultOptions.startApp);
40
+        showModal.mergeWithDefault(defaultOptions.showModal);
41
+        dismissModal.mergeWithDefault(defaultOptions.dismissModal);
42
+    }
43
+}

+ 4
- 0
lib/android/app/src/main/java/com/reactnativenavigation/parse/BottomTabOptions.java Datei anzeigen

@@ -1,5 +1,9 @@
1 1
 package com.reactnativenavigation.parse;
2 2
 
3
+import com.reactnativenavigation.parse.params.NullText;
4
+import com.reactnativenavigation.parse.params.Text;
5
+import com.reactnativenavigation.parse.parsers.TextParser;
6
+
3 7
 import org.json.JSONObject;
4 8
 
5 9
 public class BottomTabOptions implements DEFAULT_VALUES {

+ 9
- 0
lib/android/app/src/main/java/com/reactnativenavigation/parse/BottomTabsOptions.java Datei anzeigen

@@ -1,8 +1,17 @@
1 1
 package com.reactnativenavigation.parse;
2 2
 
3 3
 import com.reactnativenavigation.parse.params.Bool;
4
+import com.reactnativenavigation.parse.params.Color;
4 5
 import com.reactnativenavigation.parse.params.NullBool;
6
+import com.reactnativenavigation.parse.params.NullColor;
7
+import com.reactnativenavigation.parse.params.NullNumber;
8
+import com.reactnativenavigation.parse.params.NullText;
9
+import com.reactnativenavigation.parse.params.Number;
10
+import com.reactnativenavigation.parse.params.Text;
5 11
 import com.reactnativenavigation.parse.parsers.BoolParser;
12
+import com.reactnativenavigation.parse.parsers.ColorParser;
13
+import com.reactnativenavigation.parse.parsers.NumberParser;
14
+import com.reactnativenavigation.parse.parsers.TextParser;
6 15
 
7 16
 import org.json.JSONObject;
8 17
 

+ 6
- 0
lib/android/app/src/main/java/com/reactnativenavigation/parse/FabOptions.java Datei anzeigen

@@ -2,8 +2,14 @@ package com.reactnativenavigation.parse;
2 2
 
3 3
 
4 4
 import com.reactnativenavigation.parse.params.Bool;
5
+import com.reactnativenavigation.parse.params.Color;
5 6
 import com.reactnativenavigation.parse.params.NullBool;
7
+import com.reactnativenavigation.parse.params.NullColor;
8
+import com.reactnativenavigation.parse.params.NullText;
9
+import com.reactnativenavigation.parse.params.Text;
6 10
 import com.reactnativenavigation.parse.parsers.BoolParser;
11
+import com.reactnativenavigation.parse.parsers.ColorParser;
12
+import com.reactnativenavigation.parse.parsers.TextParser;
7 13
 
8 14
 import org.json.JSONArray;
9 15
 import org.json.JSONObject;

+ 1
- 1
lib/android/app/src/main/java/com/reactnativenavigation/parse/LayoutNode.java Datei anzeigen

@@ -27,7 +27,7 @@ public class LayoutNode {
27 27
 		this(id, type, new JSONObject(), new ArrayList<>());
28 28
 	}
29 29
 
30
-	LayoutNode(String id, Type type, JSONObject data, List<LayoutNode> children) {
30
+	public LayoutNode(String id, Type type, JSONObject data, List<LayoutNode> children) {
31 31
 		this.id = id;
32 32
 		this.type = type;
33 33
 		this.data = data;

+ 5
- 0
lib/android/app/src/main/java/com/reactnativenavigation/parse/Options.java Datei anzeigen

@@ -26,6 +26,7 @@ public class Options implements DEFAULT_VALUES {
26 26
         result.bottomTabsOptions = BottomTabsOptions.parse(json.optJSONObject("bottomTabs"));
27 27
         result.overlayOptions = OverlayOptions.parse(json.optJSONObject("overlay"));
28 28
         result.fabOptions = FabOptions.parse(json.optJSONObject("fab"));
29
+        result.animationsOptions = AnimationsOptions.parse(json.optJSONObject("animations"));
29 30
 
30 31
         return result.withDefaultOptions(defaultOptions);
31 32
     }
@@ -37,6 +38,7 @@ public class Options implements DEFAULT_VALUES {
37 38
     @NonNull public BottomTabsOptions bottomTabsOptions = new BottomTabsOptions();
38 39
     @NonNull public OverlayOptions overlayOptions = new OverlayOptions();
39 40
     @NonNull public FabOptions fabOptions = new FabOptions();
41
+    @NonNull public AnimationsOptions animationsOptions = new AnimationsOptions();
40 42
 
41 43
     void setTopTabIndex(int i) {
42 44
         topTabOptions.tabIndex = i;
@@ -52,6 +54,7 @@ public class Options implements DEFAULT_VALUES {
52 54
         result.bottomTabsOptions.mergeWith(bottomTabsOptions);
53 55
         result.overlayOptions = overlayOptions;
54 56
         result.fabOptions.mergeWith(fabOptions);
57
+        result.animationsOptions.mergeWith(animationsOptions);
55 58
         return result;
56 59
     }
57 60
 
@@ -64,6 +67,7 @@ public class Options implements DEFAULT_VALUES {
64 67
         result.bottomTabOptions.mergeWith(other.bottomTabOptions);
65 68
         result.bottomTabsOptions.mergeWith(other.bottomTabsOptions);
66 69
         result.fabOptions.mergeWith(other.fabOptions);
70
+        result.animationsOptions.mergeWith(other.animationsOptions);
67 71
         return result;
68 72
     }
69 73
 
@@ -74,6 +78,7 @@ public class Options implements DEFAULT_VALUES {
74 78
         bottomTabOptions.mergeWithDefault(other.bottomTabOptions);
75 79
         bottomTabsOptions.mergeWithDefault(other.bottomTabsOptions);
76 80
         fabOptions.mergeWithDefault(other.fabOptions);
81
+        animationsOptions.mergeWithDefault(other.animationsOptions);
77 82
         return this;
78 83
     }
79 84
 

+ 10
- 0
lib/android/app/src/main/java/com/reactnativenavigation/parse/TopBarOptions.java Datei anzeigen

@@ -5,8 +5,18 @@ import android.graphics.Typeface;
5 5
 import android.support.annotation.Nullable;
6 6
 
7 7
 import com.reactnativenavigation.parse.params.Bool;
8
+import com.reactnativenavigation.parse.params.Button;
9
+import com.reactnativenavigation.parse.params.Color;
10
+import com.reactnativenavigation.parse.params.Fraction;
8 11
 import com.reactnativenavigation.parse.params.NullBool;
12
+import com.reactnativenavigation.parse.params.NullColor;
13
+import com.reactnativenavigation.parse.params.NullFraction;
14
+import com.reactnativenavigation.parse.params.NullText;
15
+import com.reactnativenavigation.parse.params.Text;
9 16
 import com.reactnativenavigation.parse.parsers.BoolParser;
17
+import com.reactnativenavigation.parse.parsers.ColorParser;
18
+import com.reactnativenavigation.parse.parsers.FractionParser;
19
+import com.reactnativenavigation.parse.parsers.TextParser;
10 20
 import com.reactnativenavigation.utils.TypefaceLoader;
11 21
 
12 22
 import org.json.JSONObject;

+ 3
- 0
lib/android/app/src/main/java/com/reactnativenavigation/parse/TopTabOptions.java Datei anzeigen

@@ -3,6 +3,9 @@ package com.reactnativenavigation.parse;
3 3
 import android.graphics.Typeface;
4 4
 import android.support.annotation.Nullable;
5 5
 
6
+import com.reactnativenavigation.parse.params.NullText;
7
+import com.reactnativenavigation.parse.params.Text;
8
+import com.reactnativenavigation.parse.parsers.TextParser;
6 9
 import com.reactnativenavigation.utils.TypefaceLoader;
7 10
 
8 11
 import org.json.JSONObject;

+ 6
- 0
lib/android/app/src/main/java/com/reactnativenavigation/parse/TopTabsOptions.java Datei anzeigen

@@ -4,8 +4,14 @@ import android.support.annotation.NonNull;
4 4
 import android.support.annotation.Nullable;
5 5
 
6 6
 import com.reactnativenavigation.parse.params.Bool;
7
+import com.reactnativenavigation.parse.params.Color;
7 8
 import com.reactnativenavigation.parse.params.NullBool;
9
+import com.reactnativenavigation.parse.params.NullColor;
10
+import com.reactnativenavigation.parse.params.NullNumber;
11
+import com.reactnativenavigation.parse.params.Number;
8 12
 import com.reactnativenavigation.parse.parsers.BoolParser;
13
+import com.reactnativenavigation.parse.parsers.ColorParser;
14
+import com.reactnativenavigation.parse.parsers.NumberParser;
9 15
 
10 16
 import org.json.JSONObject;
11 17
 

+ 69
- 0
lib/android/app/src/main/java/com/reactnativenavigation/parse/ValueAnimationOptions.java Datei anzeigen

@@ -0,0 +1,69 @@
1
+package com.reactnativenavigation.parse;
2
+
3
+
4
+import android.animation.Animator;
5
+import android.animation.ObjectAnimator;
6
+import android.util.Property;
7
+import android.view.View;
8
+
9
+import com.reactnativenavigation.parse.params.FloatParam;
10
+import com.reactnativenavigation.parse.params.Interpolation;
11
+import com.reactnativenavigation.parse.params.NullFloatParam;
12
+import com.reactnativenavigation.parse.params.NullNumber;
13
+import com.reactnativenavigation.parse.params.Number;
14
+import com.reactnativenavigation.parse.parsers.FloatParser;
15
+import com.reactnativenavigation.parse.parsers.InterpolationParser;
16
+import com.reactnativenavigation.parse.parsers.NumberParser;
17
+
18
+import org.json.JSONObject;
19
+
20
+public class ValueAnimationOptions implements DEFAULT_VALUES {
21
+
22
+    public static ValueAnimationOptions parse(JSONObject json, Property<View, Float> property) {
23
+        ValueAnimationOptions options = new ValueAnimationOptions();
24
+
25
+        options.animProp = property;
26
+        options.from = FloatParser.parse(json, "from");
27
+        options.to = FloatParser.parse(json, "to");
28
+        options.duration = NumberParser.parse(json, "duration");
29
+        options.startDelay = NumberParser.parse(json, "startDelay");
30
+        options.interpolation = InterpolationParser.parse(json, "interpolation");
31
+
32
+        return options;
33
+    }
34
+
35
+    private Property<View, Float> animProp;
36
+
37
+    private FloatParam from = new NullFloatParam();
38
+    private FloatParam to = new NullFloatParam();
39
+    private Number duration = new NullNumber();
40
+    private Number startDelay = new NullNumber();
41
+    private Interpolation interpolation = Interpolation.NO_VALUE;
42
+
43
+    Animator getAnimation(View view) {
44
+        if (!this.from.hasValue() || !this.to.hasValue())
45
+            throw new IllegalArgumentException("Params 'from' and 'to' are mandatory");
46
+        ObjectAnimator animator = ObjectAnimator.ofFloat(view, animProp, this.from.get(), this.to.get());
47
+        animator.setInterpolator(this.interpolation.getInterpolator());
48
+        if (this.duration.hasValue())
49
+            animator.setDuration(this.duration.get());
50
+        if (this.startDelay.hasValue())
51
+            animator.setStartDelay(this.startDelay.get());
52
+        return animator;
53
+    }
54
+
55
+    @Override
56
+    public boolean equals(Object o) {
57
+        if (this == o) return true;
58
+        if (o == null || getClass() != o.getClass()) return false;
59
+
60
+        ValueAnimationOptions options = (ValueAnimationOptions) o;
61
+
62
+        return animProp.equals(options.animProp);
63
+    }
64
+
65
+    @Override
66
+    public int hashCode() {
67
+        return animProp.hashCode();
68
+    }
69
+}

+ 0
- 2
lib/android/app/src/main/java/com/reactnativenavigation/parse/params/Bool.java Datei anzeigen

@@ -1,7 +1,5 @@
1 1
 package com.reactnativenavigation.parse.params;
2 2
 
3
-import com.reactnativenavigation.parse.Param;
4
-
5 3
 public class Bool extends Param<Boolean> {
6 4
     public Bool(Boolean value) {
7 5
         super(value);

lib/android/app/src/main/java/com/reactnativenavigation/parse/Button.java → lib/android/app/src/main/java/com/reactnativenavigation/parse/params/Button.java Datei anzeigen

@@ -1,11 +1,10 @@
1
-package com.reactnativenavigation.parse;
1
+package com.reactnativenavigation.parse.params;
2 2
 
3 3
 import android.support.annotation.ColorInt;
4 4
 import android.view.MenuItem;
5 5
 
6
-import com.reactnativenavigation.parse.params.Bool;
7
-import com.reactnativenavigation.parse.params.NullBool;
8 6
 import com.reactnativenavigation.parse.parsers.BoolParser;
7
+import com.reactnativenavigation.parse.parsers.TextParser;
9 8
 
10 9
 import org.json.JSONArray;
11 10
 import org.json.JSONObject;
@@ -45,7 +44,7 @@ public class Button {
45 44
 		return button;
46 45
 	}
47 46
 
48
-	static ArrayList<Button> parseJsonArray(JSONArray jsonArray) {
47
+	public static ArrayList<Button> parseJsonArray(JSONArray jsonArray) {
49 48
 		ArrayList<Button> buttons = new ArrayList<>();
50 49
 
51 50
 		if (jsonArray == null) {

lib/android/app/src/main/java/com/reactnativenavigation/parse/Color.java → lib/android/app/src/main/java/com/reactnativenavigation/parse/params/Color.java Datei anzeigen

@@ -1,4 +1,4 @@
1
-package com.reactnativenavigation.parse;
1
+package com.reactnativenavigation.parse.params;
2 2
 
3 3
 import android.support.annotation.ColorInt;
4 4
 

+ 9
- 0
lib/android/app/src/main/java/com/reactnativenavigation/parse/params/FloatParam.java Datei anzeigen

@@ -0,0 +1,9 @@
1
+package com.reactnativenavigation.parse.params;
2
+
3
+
4
+public class FloatParam extends Param<Float> {
5
+
6
+    public FloatParam(Float value) {
7
+        super(value);
8
+    }
9
+}

lib/android/app/src/main/java/com/reactnativenavigation/parse/Fraction.java → lib/android/app/src/main/java/com/reactnativenavigation/parse/params/Fraction.java Datei anzeigen

@@ -1,4 +1,4 @@
1
-package com.reactnativenavigation.parse;
1
+package com.reactnativenavigation.parse.params;
2 2
 
3 3
 public class Fraction extends Param<Float> {
4 4
     public Fraction(float value) {

+ 26
- 0
lib/android/app/src/main/java/com/reactnativenavigation/parse/params/Interpolation.java Datei anzeigen

@@ -0,0 +1,26 @@
1
+package com.reactnativenavigation.parse.params;
2
+
3
+
4
+import android.animation.TimeInterpolator;
5
+import android.view.animation.AccelerateDecelerateInterpolator;
6
+import android.view.animation.AccelerateInterpolator;
7
+import android.view.animation.DecelerateInterpolator;
8
+
9
+public enum Interpolation {
10
+    ACCELERATING,
11
+    DECELERATING,
12
+    DEFAULT,
13
+    NO_VALUE;
14
+
15
+    public TimeInterpolator getInterpolator() {
16
+        switch (this) {
17
+            case ACCELERATING:
18
+                return new AccelerateInterpolator();
19
+            case DECELERATING:
20
+                return new DecelerateInterpolator();
21
+            case DEFAULT:
22
+                return new AccelerateDecelerateInterpolator();
23
+        }
24
+        return null;
25
+    }
26
+}

lib/android/app/src/main/java/com/reactnativenavigation/parse/NullColor.java → lib/android/app/src/main/java/com/reactnativenavigation/parse/params/NullColor.java Datei anzeigen

@@ -1,8 +1,8 @@
1
-package com.reactnativenavigation.parse;
1
+package com.reactnativenavigation.parse.params;
2 2
 
3 3
 public class NullColor extends Color {
4 4
 
5
-    NullColor() {
5
+    public NullColor() {
6 6
         super(0);
7 7
     }
8 8
 

+ 14
- 0
lib/android/app/src/main/java/com/reactnativenavigation/parse/params/NullFloatParam.java Datei anzeigen

@@ -0,0 +1,14 @@
1
+package com.reactnativenavigation.parse.params;
2
+
3
+
4
+public class NullFloatParam extends FloatParam {
5
+
6
+    public NullFloatParam() {
7
+        super(0f);
8
+    }
9
+
10
+    @Override
11
+    public boolean hasValue() {
12
+        return false;
13
+    }
14
+}

lib/android/app/src/main/java/com/reactnativenavigation/parse/NullFraction.java → lib/android/app/src/main/java/com/reactnativenavigation/parse/params/NullFraction.java Datei anzeigen

@@ -1,7 +1,7 @@
1
-package com.reactnativenavigation.parse;
1
+package com.reactnativenavigation.parse.params;
2 2
 
3 3
 public class NullFraction extends Fraction {
4
-    NullFraction() {
4
+    public NullFraction() {
5 5
         super(0);
6 6
     }
7 7
 

lib/android/app/src/main/java/com/reactnativenavigation/parse/NullNumber.java → lib/android/app/src/main/java/com/reactnativenavigation/parse/params/NullNumber.java Datei anzeigen

@@ -1,7 +1,7 @@
1
-package com.reactnativenavigation.parse;
1
+package com.reactnativenavigation.parse.params;
2 2
 
3 3
 public class NullNumber extends Number {
4
-    NullNumber() {
4
+    public NullNumber() {
5 5
         super(0);
6 6
     }
7 7
 

lib/android/app/src/main/java/com/reactnativenavigation/parse/NullText.java → lib/android/app/src/main/java/com/reactnativenavigation/parse/params/NullText.java Datei anzeigen

@@ -1,4 +1,4 @@
1
-package com.reactnativenavigation.parse;
1
+package com.reactnativenavigation.parse.params;
2 2
 
3 3
 public class NullText extends Text {
4 4
     public NullText() {

lib/android/app/src/main/java/com/reactnativenavigation/parse/Number.java → lib/android/app/src/main/java/com/reactnativenavigation/parse/params/Number.java Datei anzeigen

@@ -1,4 +1,4 @@
1
-package com.reactnativenavigation.parse;
1
+package com.reactnativenavigation.parse.params;
2 2
 
3 3
 public class Number extends Param<Integer> {
4 4
 

lib/android/app/src/main/java/com/reactnativenavigation/parse/Param.java → lib/android/app/src/main/java/com/reactnativenavigation/parse/params/Param.java Datei anzeigen

@@ -1,4 +1,4 @@
1
-package com.reactnativenavigation.parse;
1
+package com.reactnativenavigation.parse.params;
2 2
 
3 3
 public abstract class Param<T> {
4 4
     protected T value;

lib/android/app/src/main/java/com/reactnativenavigation/parse/Text.java → lib/android/app/src/main/java/com/reactnativenavigation/parse/params/Text.java Datei anzeigen

@@ -1,4 +1,4 @@
1
-package com.reactnativenavigation.parse;
1
+package com.reactnativenavigation.parse.params;
2 2
 
3 3
 public class Text extends Param<String> {
4 4
     public Text(String value) {

lib/android/app/src/main/java/com/reactnativenavigation/parse/ColorParser.java → lib/android/app/src/main/java/com/reactnativenavigation/parse/parsers/ColorParser.java Datei anzeigen

@@ -1,4 +1,7 @@
1
-package com.reactnativenavigation.parse;
1
+package com.reactnativenavigation.parse.parsers;
2
+
3
+import com.reactnativenavigation.parse.params.Color;
4
+import com.reactnativenavigation.parse.params.NullColor;
2 5
 
3 6
 import org.json.JSONObject;
4 7
 

+ 14
- 0
lib/android/app/src/main/java/com/reactnativenavigation/parse/parsers/FloatParser.java Datei anzeigen

@@ -0,0 +1,14 @@
1
+package com.reactnativenavigation.parse.parsers;
2
+
3
+import com.reactnativenavigation.parse.params.FloatParam;
4
+import com.reactnativenavigation.parse.params.NullFloatParam;
5
+import com.reactnativenavigation.parse.params.NullNumber;
6
+import com.reactnativenavigation.parse.params.Number;
7
+
8
+import org.json.JSONObject;
9
+
10
+public class FloatParser {
11
+    public static FloatParam parse(JSONObject json, String number) {
12
+        return json.has(number) ? new FloatParam((float) json.optDouble(number)) : new NullFloatParam();
13
+    }
14
+}

lib/android/app/src/main/java/com/reactnativenavigation/parse/FractionParser.java → lib/android/app/src/main/java/com/reactnativenavigation/parse/parsers/FractionParser.java Datei anzeigen

@@ -1,4 +1,7 @@
1
-package com.reactnativenavigation.parse;
1
+package com.reactnativenavigation.parse.parsers;
2
+
3
+import com.reactnativenavigation.parse.params.Fraction;
4
+import com.reactnativenavigation.parse.params.NullFraction;
2 5
 
3 6
 import org.json.JSONObject;
4 7
 

+ 23
- 0
lib/android/app/src/main/java/com/reactnativenavigation/parse/parsers/InterpolationParser.java Datei anzeigen

@@ -0,0 +1,23 @@
1
+package com.reactnativenavigation.parse.parsers;
2
+
3
+
4
+import com.reactnativenavigation.parse.params.Interpolation;
5
+
6
+import org.json.JSONObject;
7
+
8
+public class InterpolationParser {
9
+    public static Interpolation parse(JSONObject json, String intepolation) {
10
+        Interpolation result = Interpolation.DEFAULT;
11
+        if (json.has(intepolation)) {
12
+            switch (json.optString(intepolation)) {
13
+                case "decelerate":
14
+                    result = Interpolation.DECELERATING;
15
+                    break;
16
+                case "accelerate":
17
+                    result = Interpolation.ACCELERATING;
18
+                    break;
19
+            }
20
+        }
21
+        return result;
22
+    }
23
+}

lib/android/app/src/main/java/com/reactnativenavigation/parse/JSONParser.java → lib/android/app/src/main/java/com/reactnativenavigation/parse/parsers/JSONParser.java Datei anzeigen

@@ -1,4 +1,4 @@
1
-package com.reactnativenavigation.parse;
1
+package com.reactnativenavigation.parse.parsers;
2 2
 
3 3
 import com.facebook.react.bridge.ReadableArray;
4 4
 import com.facebook.react.bridge.ReadableMap;

lib/android/app/src/main/java/com/reactnativenavigation/parse/LayoutNodeParser.java → lib/android/app/src/main/java/com/reactnativenavigation/parse/parsers/LayoutNodeParser.java Datei anzeigen

@@ -1,7 +1,9 @@
1
-package com.reactnativenavigation.parse;
1
+package com.reactnativenavigation.parse.parsers;
2 2
 
3 3
 import android.support.annotation.NonNull;
4 4
 
5
+import com.reactnativenavigation.parse.LayoutNode;
6
+
5 7
 import org.json.JSONArray;
6 8
 import org.json.JSONObject;
7 9
 

lib/android/app/src/main/java/com/reactnativenavigation/parse/NumberParser.java → lib/android/app/src/main/java/com/reactnativenavigation/parse/parsers/NumberParser.java Datei anzeigen

@@ -1,4 +1,7 @@
1
-package com.reactnativenavigation.parse;
1
+package com.reactnativenavigation.parse.parsers;
2
+
3
+import com.reactnativenavigation.parse.params.NullNumber;
4
+import com.reactnativenavigation.parse.params.Number;
2 5
 
3 6
 import org.json.JSONObject;
4 7
 

lib/android/app/src/main/java/com/reactnativenavigation/parse/TextParser.java → lib/android/app/src/main/java/com/reactnativenavigation/parse/parsers/TextParser.java Datei anzeigen

@@ -1,4 +1,7 @@
1
-package com.reactnativenavigation.parse;
1
+package com.reactnativenavigation.parse.parsers;
2
+
3
+import com.reactnativenavigation.parse.params.NullText;
4
+import com.reactnativenavigation.parse.params.Text;
2 5
 
3 6
 import org.json.JSONObject;
4 7
 

+ 1
- 1
lib/android/app/src/main/java/com/reactnativenavigation/presentation/OptionsPresenter.java Datei anzeigen

@@ -1,6 +1,6 @@
1 1
 package com.reactnativenavigation.presentation;
2 2
 
3
-import com.reactnativenavigation.parse.Button;
3
+import com.reactnativenavigation.parse.params.Button;
4 4
 import com.reactnativenavigation.parse.Options;
5 5
 import com.reactnativenavigation.parse.TopBarOptions;
6 6
 import com.reactnativenavigation.parse.TopTabOptions;

+ 2
- 2
lib/android/app/src/main/java/com/reactnativenavigation/react/NavigationModule.java Datei anzeigen

@@ -9,10 +9,10 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
9 9
 import com.facebook.react.bridge.ReactMethod;
10 10
 import com.facebook.react.bridge.ReadableMap;
11 11
 import com.reactnativenavigation.NavigationActivity;
12
-import com.reactnativenavigation.parse.JSONParser;
12
+import com.reactnativenavigation.parse.parsers.JSONParser;
13 13
 import com.reactnativenavigation.parse.LayoutFactory;
14 14
 import com.reactnativenavigation.parse.LayoutNode;
15
-import com.reactnativenavigation.parse.LayoutNodeParser;
15
+import com.reactnativenavigation.parse.parsers.LayoutNodeParser;
16 16
 import com.reactnativenavigation.parse.Options;
17 17
 import com.reactnativenavigation.utils.TypefaceLoader;
18 18
 import com.reactnativenavigation.utils.UiThread;

+ 1
- 1
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/BottomTabsController.java Datei anzeigen

@@ -11,7 +11,7 @@ import com.aurelhubert.ahbottomnavigation.AHBottomNavigation;
11 11
 import com.aurelhubert.ahbottomnavigation.AHBottomNavigationItem;
12 12
 import com.reactnativenavigation.parse.BottomTabOptions;
13 13
 import com.reactnativenavigation.parse.Options;
14
-import com.reactnativenavigation.parse.Text;
14
+import com.reactnativenavigation.parse.params.Text;
15 15
 import com.reactnativenavigation.presentation.BottomTabOptionsPresenter;
16 16
 import com.reactnativenavigation.presentation.NavigationOptionsListener;
17 17
 import com.reactnativenavigation.utils.ImageLoader;

+ 1
- 0
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/StackController.java Datei anzeigen

@@ -46,6 +46,7 @@ public class StackController extends ParentController <StackLayout> {
46 46
                 ((ParentController) parentController).applyOptions(this.options.copy().clearTopBarOptions(), component)
47 47
         );
48 48
         fabOptionsPresenter.applyOptions(options.fabOptions, component, getView());
49
+        animator.setOptions(options.animationsOptions);
49 50
     }
50 51
 
51 52
     @Override

+ 1
- 1
lib/android/app/src/main/java/com/reactnativenavigation/views/BottomTabs.java Datei anzeigen

@@ -4,7 +4,7 @@ import android.annotation.SuppressLint;
4 4
 import android.content.Context;
5 5
 
6 6
 import com.aurelhubert.ahbottomnavigation.AHBottomNavigation;
7
-import com.reactnativenavigation.parse.Text;
7
+import com.reactnativenavigation.parse.params.Text;
8 8
 import com.reactnativenavigation.utils.CompatUtils;
9 9
 
10 10
 @SuppressLint("ViewConstructor")

+ 2
- 2
lib/android/app/src/main/java/com/reactnativenavigation/views/TitleBarButton.java Datei anzeigen

@@ -16,8 +16,8 @@ import android.view.View;
16 16
 import android.widget.ImageButton;
17 17
 import android.widget.TextView;
18 18
 
19
-import com.reactnativenavigation.parse.Button;
20
-import com.reactnativenavigation.parse.Text;
19
+import com.reactnativenavigation.parse.params.Button;
20
+import com.reactnativenavigation.parse.params.Text;
21 21
 import com.reactnativenavigation.utils.ArrayUtils;
22 22
 import com.reactnativenavigation.utils.ImageLoader;
23 23
 import com.reactnativenavigation.utils.UiUtils;

+ 4
- 4
lib/android/app/src/main/java/com/reactnativenavigation/views/TopBar.java Datei anzeigen

@@ -17,10 +17,10 @@ import android.widget.TextView;
17 17
 import com.reactnativenavigation.anim.TopBarAnimator;
18 18
 import com.reactnativenavigation.anim.TopBarCollapseBehavior;
19 19
 import com.reactnativenavigation.interfaces.ScrollEventListener;
20
-import com.reactnativenavigation.parse.Button;
21
-import com.reactnativenavigation.parse.Color;
22
-import com.reactnativenavigation.parse.Fraction;
23
-import com.reactnativenavigation.parse.Number;
20
+import com.reactnativenavigation.parse.params.Button;
21
+import com.reactnativenavigation.parse.params.Color;
22
+import com.reactnativenavigation.parse.params.Fraction;
23
+import com.reactnativenavigation.parse.params.Number;
24 24
 import com.reactnativenavigation.parse.params.Bool;
25 25
 
26 26
 import java.util.ArrayList;

+ 2
- 2
lib/android/app/src/main/java/com/reactnativenavigation/views/TopTabs.java Datei anzeigen

@@ -6,8 +6,8 @@ import android.support.design.widget.TabLayout;
6 6
 import android.support.v4.view.ViewPager;
7 7
 import android.view.ViewManager;
8 8
 
9
-import com.reactnativenavigation.parse.Color;
10
-import com.reactnativenavigation.parse.Number;
9
+import com.reactnativenavigation.parse.params.Color;
10
+import com.reactnativenavigation.parse.params.Number;
11 11
 
12 12
 public class TopTabs extends TabLayout {
13 13
     private final TopTabsStyleHelper styleHelper;

+ 2
- 2
lib/android/app/src/main/java/com/reactnativenavigation/views/TopTabsStyleHelper.java Datei anzeigen

@@ -5,8 +5,8 @@ import android.graphics.Typeface;
5 5
 import android.view.ViewGroup;
6 6
 import android.widget.TextView;
7 7
 
8
-import com.reactnativenavigation.parse.Color;
9
-import com.reactnativenavigation.parse.Number;
8
+import com.reactnativenavigation.parse.params.Color;
9
+import com.reactnativenavigation.parse.params.Number;
10 10
 import com.reactnativenavigation.utils.Task;
11 11
 import com.reactnativenavigation.utils.ViewUtils;
12 12
 

+ 2
- 2
lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestNavigationAnimator.java Datei anzeigen

@@ -13,12 +13,12 @@ public class TestNavigationAnimator extends NavigationAnimator {
13 13
     }
14 14
 
15 15
     @Override
16
-    public void animatePush(final View enteringView, NavigationAnimationListener animationListener) {
16
+    public void animatePush(final View enteringView, AnimationListener animationListener) {
17 17
         if (animationListener != null) animationListener.onAnimationEnd();
18 18
     }
19 19
 
20 20
     @Override
21
-    public void animatePop(final View enteringView, NavigationAnimationListener animationListener) {
21
+    public void animatePop(final View enteringView, AnimationListener animationListener) {
22 22
         if (animationListener != null) animationListener.onAnimationEnd();
23 23
     }
24 24
 }

+ 1
- 0
lib/android/app/src/test/java/com/reactnativenavigation/parse/JSONParserTest.java Datei anzeigen

@@ -2,6 +2,7 @@ package com.reactnativenavigation.parse;
2 2
 
3 3
 import com.facebook.react.bridge.*;
4 4
 import com.reactnativenavigation.*;
5
+import com.reactnativenavigation.parse.parsers.JSONParser;
5 6
 
6 7
 import org.json.*;
7 8
 import org.junit.*;

+ 1
- 0
lib/android/app/src/test/java/com/reactnativenavigation/parse/LayoutNodeParserTest.java Datei anzeigen

@@ -1,6 +1,7 @@
1 1
 package com.reactnativenavigation.parse;
2 2
 
3 3
 import com.reactnativenavigation.*;
4
+import com.reactnativenavigation.parse.parsers.LayoutNodeParser;
4 5
 
5 6
 import org.json.*;
6 7
 import org.junit.*;

+ 3
- 2
lib/android/app/src/test/java/com/reactnativenavigation/parse/OptionsTest.java Datei anzeigen

@@ -5,7 +5,8 @@ import android.support.annotation.*;
5 5
 
6 6
 import com.reactnativenavigation.*;
7 7
 import com.reactnativenavigation.mocks.*;
8
-import com.reactnativenavigation.parse.params.Bool;
8
+import com.reactnativenavigation.parse.params.*;
9
+import com.reactnativenavigation.parse.params.Number;
9 10
 import com.reactnativenavigation.utils.*;
10 11
 
11 12
 import org.json.*;
@@ -223,7 +224,7 @@ public class OptionsTest extends BaseTest {
223 224
     @Test
224 225
     public void clear_bottomTabsOptions() throws Exception {
225 226
         Options uut = new Options();
226
-        uut.bottomTabsOptions.tabColor = new Color(android.graphics.Color.RED);
227
+        uut.bottomTabsOptions.tabColor = new com.reactnativenavigation.parse.params.Color(android.graphics.Color.RED);
227 228
         uut.clearBottomTabsOptions();
228 229
         assertThat(uut.bottomTabsOptions.tabColor.hasValue()).isFalse();
229 230
     }

+ 1
- 1
lib/android/app/src/test/java/com/reactnativenavigation/utils/OptionHelper.java Datei anzeigen

@@ -1,7 +1,7 @@
1 1
 package com.reactnativenavigation.utils;
2 2
 
3 3
 import com.reactnativenavigation.parse.Options;
4
-import com.reactnativenavigation.parse.Text;
4
+import com.reactnativenavigation.parse.params.Text;
5 5
 
6 6
 public class OptionHelper {
7 7
     public static Options createBottomTabOptions() {

+ 1
- 1
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/BottomTabsControllerTest.java Datei anzeigen

@@ -8,7 +8,7 @@ import com.reactnativenavigation.BaseTest;
8 8
 import com.reactnativenavigation.mocks.ImageLoaderMock;
9 9
 import com.reactnativenavigation.mocks.MockPromise;
10 10
 import com.reactnativenavigation.mocks.SimpleViewController;
11
-import com.reactnativenavigation.parse.Color;
11
+import com.reactnativenavigation.parse.params.Color;
12 12
 import com.reactnativenavigation.parse.Options;
13 13
 import com.reactnativenavigation.utils.ImageLoader;
14 14
 import com.reactnativenavigation.utils.OptionHelper;

+ 1
- 1
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/FloatingActionButtonTest.java Datei anzeigen

@@ -9,7 +9,7 @@ import com.reactnativenavigation.mocks.MockPromise;
9 9
 import com.reactnativenavigation.mocks.SimpleViewController;
10 10
 import com.reactnativenavigation.parse.FabOptions;
11 11
 import com.reactnativenavigation.parse.Options;
12
-import com.reactnativenavigation.parse.Text;
12
+import com.reactnativenavigation.parse.params.Text;
13 13
 import com.reactnativenavigation.views.Fab;
14 14
 import com.reactnativenavigation.views.FabMenu;
15 15
 import com.reactnativenavigation.views.StackLayout;

+ 1
- 1
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/NavigatorTest.java Datei anzeigen

@@ -9,7 +9,7 @@ import com.reactnativenavigation.mocks.MockPromise;
9 9
 import com.reactnativenavigation.mocks.SimpleComponentViewController;
10 10
 import com.reactnativenavigation.mocks.SimpleViewController;
11 11
 import com.reactnativenavigation.parse.Options;
12
-import com.reactnativenavigation.parse.Text;
12
+import com.reactnativenavigation.parse.params.Text;
13 13
 import com.reactnativenavigation.utils.CompatUtils;
14 14
 import com.reactnativenavigation.utils.ImageLoader;
15 15
 import com.reactnativenavigation.utils.OptionHelper;

+ 4
- 4
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/OptionsApplyingTest.java Datei anzeigen

@@ -10,9 +10,9 @@ import com.reactnativenavigation.BaseTest;
10 10
 import com.reactnativenavigation.mocks.MockPromise;
11 11
 import com.reactnativenavigation.mocks.TestComponentLayout;
12 12
 import com.reactnativenavigation.mocks.TestReactView;
13
-import com.reactnativenavigation.parse.Fraction;
13
+import com.reactnativenavigation.parse.params.Fraction;
14 14
 import com.reactnativenavigation.parse.Options;
15
-import com.reactnativenavigation.parse.Text;
15
+import com.reactnativenavigation.parse.params.Text;
16 16
 import com.reactnativenavigation.parse.params.Bool;
17 17
 
18 18
 import org.junit.Test;
@@ -98,7 +98,7 @@ public class OptionsApplyingTest extends BaseTest {
98 98
         uut.onViewAppeared();
99 99
 
100 100
         Options opts = new Options();
101
-        opts.topBarOptions.backgroundColor = new com.reactnativenavigation.parse.Color(Color.RED);
101
+        opts.topBarOptions.backgroundColor = new com.reactnativenavigation.parse.params.Color(Color.RED);
102 102
         uut.mergeOptions(opts);
103 103
 
104 104
         assertThat(((ColorDrawable) stackController.getTopBar().getTitleBar().getBackground()).getColor()).isEqualTo(Color.RED);
@@ -112,7 +112,7 @@ public class OptionsApplyingTest extends BaseTest {
112 112
             public void resolve(@Nullable Object value) {
113 113
                 Options opts = new Options();
114 114
                 opts.topBarOptions.title = new Text("the title");
115
-                opts.topBarOptions.textColor = new com.reactnativenavigation.parse.Color(Color.RED);
115
+                opts.topBarOptions.textColor = new com.reactnativenavigation.parse.params.Color(Color.RED);
116 116
                 uut.mergeOptions(opts);
117 117
 
118 118
                 assertThat(stackController.getTopBar().getTitleTextView()).isNotEqualTo(null);

+ 1
- 1
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/ParentControllerTest.java Datei anzeigen

@@ -9,7 +9,7 @@ import com.reactnativenavigation.BaseTest;
9 9
 import com.reactnativenavigation.mocks.MockPromise;
10 10
 import com.reactnativenavigation.mocks.SimpleViewController;
11 11
 import com.reactnativenavigation.parse.Options;
12
-import com.reactnativenavigation.parse.Text;
12
+import com.reactnativenavigation.parse.params.Text;
13 13
 import com.reactnativenavigation.views.ReactComponent;
14 14
 
15 15
 import org.junit.Test;

+ 1
- 1
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/StackControllerTest.java Datei anzeigen

@@ -7,8 +7,8 @@ import com.reactnativenavigation.BaseTest;
7 7
 import com.reactnativenavigation.mocks.MockPromise;
8 8
 import com.reactnativenavigation.mocks.SimpleViewController;
9 9
 import com.reactnativenavigation.parse.Options;
10
-import com.reactnativenavigation.parse.Text;
11 10
 import com.reactnativenavigation.parse.params.Bool;
11
+import com.reactnativenavigation.parse.params.Text;
12 12
 import com.reactnativenavigation.utils.ViewHelper;
13 13
 import com.reactnativenavigation.views.ReactComponent;
14 14
 import com.reactnativenavigation.views.StackLayout;

+ 1
- 1
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/TopTabsViewControllerTest.java Datei anzeigen

@@ -9,7 +9,7 @@ import com.reactnativenavigation.mocks.MockPromise;
9 9
 import com.reactnativenavigation.mocks.TestComponentViewCreator;
10 10
 import com.reactnativenavigation.mocks.TestReactView;
11 11
 import com.reactnativenavigation.parse.Options;
12
-import com.reactnativenavigation.parse.Text;
12
+import com.reactnativenavigation.parse.params.Text;
13 13
 import com.reactnativenavigation.utils.ViewHelper;
14 14
 import com.reactnativenavigation.viewcontrollers.toptabs.TopTabsAdapter;
15 15
 import com.reactnativenavigation.viewcontrollers.toptabs.TopTabsController;

+ 2
- 2
lib/android/app/src/test/java/com/reactnativenavigation/views/TopBarTest.java Datei anzeigen

@@ -5,8 +5,8 @@ import android.view.MenuItem;
5 5
 
6 6
 import com.reactnativenavigation.BaseTest;
7 7
 import com.reactnativenavigation.anim.TopBarAnimator;
8
-import com.reactnativenavigation.parse.Button;
9
-import com.reactnativenavigation.parse.Text;
8
+import com.reactnativenavigation.parse.params.Button;
9
+import com.reactnativenavigation.parse.params.Text;
10 10
 import com.reactnativenavigation.parse.params.Bool;
11 11
 import com.reactnativenavigation.parse.params.NullBool;
12 12
 import com.reactnativenavigation.utils.TitleBarHelper;

+ 46
- 0
playground/src/app.js Datei anzeigen

@@ -23,6 +23,52 @@ if (Platform.OS === 'android') {
23 23
 function start() {
24 24
   registerScreens();
25 25
   Navigation.events().onAppLaunched(() => {
26
+    Navigation.setDefaultOptions({
27
+      animations: {
28
+        push: {
29
+          y: {
30
+            from: 1000,
31
+            to: 0,
32
+            duration: 500,
33
+            interpolation: 'decelerate',
34
+          },
35
+          x: {
36
+            from: 1000,
37
+            to: 0,
38
+            duration: 500,
39
+            interpolation: 'decelerate',
40
+            startDelay: 100
41
+          },
42
+          scaleY: {
43
+            from: 0,
44
+            to: 1,
45
+            duration: 1000,
46
+            interpolation: 'decelerate',
47
+          }
48
+        },
49
+        pop : {
50
+          rotationY: {
51
+            from: 0,
52
+            to: -360,
53
+            duration: 500,
54
+            interpolation: 'accelerate',
55
+          },
56
+          x: {
57
+            from: 0,
58
+            to: -1000,
59
+            duration: 500,
60
+            interpolation: 'accelerate',
61
+            startDelay: 100
62
+          },
63
+          alpha: {
64
+            from: 1,
65
+            to: 0,
66
+            duration: 500
67
+          }
68
+        }
69
+      }
70
+    });
71
+
26 72
     Navigation.setRoot({
27 73
       stack: {
28 74
         children: [

+ 2
- 1
playground/src/screens/OptionsScreen.js Datei anzeigen

@@ -231,7 +231,8 @@ class OptionsScreen extends Component {
231 231
   onClickPushDefaultOptionsScreen() {
232 232
     Navigation.setDefaultOptions({
233 233
       topBar: {
234
-        visible: false
234
+        visible: false,
235
+        animate: false
235 236
       }
236 237
     });
237 238