Bladeren bron

Support showing modals without animation (#900)

Guy Carmeli 7 jaren geleden
bovenliggende
commit
1166473fde

+ 9
- 0
android/app/src/main/java/com/reactnativenavigation/controllers/Modal.java Bestand weergeven

@@ -90,6 +90,7 @@ public class Modal extends Dialog implements DialogInterface.OnDismissListener,
90 90
         this.onModalDismissedListener = onModalDismissedListener;
91 91
         this.screenParams = screenParams;
92 92
         createContent();
93
+        setAnimation();
93 94
     }
94 95
 
95 96
     public AppCompatActivity getActivity() {
@@ -106,6 +107,14 @@ public class Modal extends Dialog implements DialogInterface.OnDismissListener,
106 107
         setContentView(layout.asView());
107 108
     }
108 109
 
110
+    private void setAnimation() {
111
+        if (!screenParams.animateScreenTransitions) {
112
+            if (getWindow() != null) {
113
+                getWindow().setWindowAnimations(android.R.style.Animation);
114
+            }
115
+        }
116
+    }
117
+
109 118
     @Override
110 119
     public void push(ScreenParams params) {
111 120
         layout.push(params);

+ 19
- 0
android/app/src/main/java/com/reactnativenavigation/params/parsers/AnimationParser.java Bestand weergeven

@@ -0,0 +1,19 @@
1
+package com.reactnativenavigation.params.parsers;
2
+
3
+import android.os.Bundle;
4
+
5
+class AnimationParser extends Parser {
6
+    private Bundle params;
7
+
8
+    AnimationParser(Bundle params) {
9
+        this.params = params;
10
+    }
11
+
12
+    public boolean parse() {
13
+        if (params.isEmpty()) {
14
+            return true;
15
+        }
16
+        final String animationType = params.getString("animationType", "slide-up");
17
+        return !animationType.equals("none") && params.getBoolean("animated", true);
18
+    }
19
+}

+ 1
- 1
android/app/src/main/java/com/reactnativenavigation/params/parsers/ScreenParamsParser.java Bestand weergeven

@@ -46,7 +46,7 @@ public class ScreenParamsParser extends Parser {
46 46
         result.tabLabel = getTabLabel(params);
47 47
         result.tabIcon = new TabIconParser(params).parse();
48 48
 
49
-        result.animateScreenTransitions = params.getBoolean("animated", true);
49
+        result.animateScreenTransitions = new AnimationParser(params).parse();
50 50
 
51 51
         return result;
52 52
     }