Ver código fonte

Use linearInterpolator as default interpolator for command animations

Guy Carmeli 6 anos atrás
pai
commit
e1d28d61ae

+ 9
- 5
lib/android/app/src/main/java/com/reactnativenavigation/parse/params/Interpolation.java Ver arquivo

@@ -5,21 +5,25 @@ import android.animation.TimeInterpolator;
5 5
 import android.view.animation.AccelerateDecelerateInterpolator;
6 6
 import android.view.animation.AccelerateInterpolator;
7 7
 import android.view.animation.DecelerateInterpolator;
8
+import android.view.animation.LinearInterpolator;
8 9
 
9 10
 public enum Interpolation {
10
-    ACCELERATING,
11
-    DECELERATING,
11
+    ACCELERATE,
12
+    DECELERATE,
13
+    ACCELERATE_DECELERATE,
12 14
     DEFAULT,
13 15
     NO_VALUE;
14 16
 
15 17
     public TimeInterpolator getInterpolator() {
16 18
         switch (this) {
17
-            case ACCELERATING:
19
+            case ACCELERATE:
18 20
                 return new AccelerateInterpolator();
19
-            case DECELERATING:
21
+            case DECELERATE:
20 22
                 return new DecelerateInterpolator();
21
-            case DEFAULT:
23
+            case ACCELERATE_DECELERATE:
22 24
                 return new AccelerateDecelerateInterpolator();
25
+            case DEFAULT:
26
+                return new LinearInterpolator();
23 27
         }
24 28
         return null;
25 29
     }

+ 9
- 11
lib/android/app/src/main/java/com/reactnativenavigation/parse/parsers/InterpolationParser.java Ver arquivo

@@ -7,17 +7,15 @@ import org.json.JSONObject;
7 7
 
8 8
 public class InterpolationParser {
9 9
     public static Interpolation parse(JSONObject json, String interpolation) {
10
-        Interpolation result = Interpolation.DEFAULT;
11
-        if (json.has(interpolation)) {
12
-            switch (json.optString(interpolation)) {
13
-                case "decelerate":
14
-                    result = Interpolation.DECELERATING;
15
-                    break;
16
-                case "accelerate":
17
-                    result = Interpolation.ACCELERATING;
18
-                    break;
19
-            }
10
+        switch (json.optString(interpolation, "default")) {
11
+            case "decelerate":
12
+                return Interpolation.DECELERATE;
13
+            case "accelerateDecelerate":
14
+                return Interpolation.ACCELERATE_DECELERATE;
15
+            case "accelerate":
16
+                return Interpolation.ACCELERATE;
17
+            default:
18
+                return Interpolation.DEFAULT;
20 19
         }
21
-        return result;
22 20
     }
23 21
 }