Browse Source

Support showing modals without animation (#900)

Guy Carmeli 7 years ago
parent
commit
1166473fde

+ 9
- 0
android/app/src/main/java/com/reactnativenavigation/controllers/Modal.java View File

90
         this.onModalDismissedListener = onModalDismissedListener;
90
         this.onModalDismissedListener = onModalDismissedListener;
91
         this.screenParams = screenParams;
91
         this.screenParams = screenParams;
92
         createContent();
92
         createContent();
93
+        setAnimation();
93
     }
94
     }
94
 
95
 
95
     public AppCompatActivity getActivity() {
96
     public AppCompatActivity getActivity() {
106
         setContentView(layout.asView());
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
     @Override
118
     @Override
110
     public void push(ScreenParams params) {
119
     public void push(ScreenParams params) {
111
         layout.push(params);
120
         layout.push(params);

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

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 View File

46
         result.tabLabel = getTabLabel(params);
46
         result.tabLabel = getTabLabel(params);
47
         result.tabIcon = new TabIconParser(params).parse();
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
         return result;
51
         return result;
52
     }
52
     }