Browse Source

dismissModal working

Daniel Zlotin 8 years ago
parent
commit
5311972d40

+ 1
- 0
android/app/src/main/java/com/reactnativenavigation/bridge/NavigationReactModule.java View File

@@ -109,5 +109,6 @@ public class NavigationReactModule extends ReactContextBaseJavaModule {
109 109
 
110 110
     @ReactMethod
111 111
     public void dismissTopModal() {
112
+        NavigationCommandsHandler.dismissTopModal();
112 113
     }
113 114
 }

+ 4
- 1
android/app/src/main/java/com/reactnativenavigation/controllers/ModalController.java View File

@@ -23,7 +23,9 @@ public class ModalController implements ScreenStackContainer, Modal.OnModalDismi
23 23
     }
24 24
 
25 25
     public void dismissModal() {
26
-        stack.pop().destroy();
26
+        if (isShowing()) {
27
+            stack.pop().dismiss();
28
+        }
27 29
     }
28 30
 
29 31
     public boolean onBackPressed() {
@@ -58,6 +60,7 @@ public class ModalController implements ScreenStackContainer, Modal.OnModalDismi
58 60
     public void destroy() {
59 61
         for (Modal modal : stack) {
60 62
             modal.destroy();
63
+            modal.dismiss();
61 64
         }
62 65
         stack.clear();
63 66
     }

+ 4
- 0
android/app/src/main/java/com/reactnativenavigation/controllers/NavigationActivity.java View File

@@ -148,4 +148,8 @@ public class NavigationActivity extends AppCompatActivity implements DefaultHard
148 148
     void showModal(ScreenParams screenParams) {
149 149
         modalController.showModal(screenParams);
150 150
     }
151
+
152
+    void dismissTopModal() {
153
+        modalController.dismissModal();
154
+    }
151 155
 }

+ 14
- 0
android/app/src/main/java/com/reactnativenavigation/controllers/NavigationCommandsHandler.java View File

@@ -150,4 +150,18 @@ public class NavigationCommandsHandler {
150 150
             }
151 151
         });
152 152
     }
153
+
154
+    public static void dismissTopModal() {
155
+        final NavigationActivity currentActivity = NavigationActivity.currentActivity;
156
+        if (currentActivity == null) {
157
+            return;
158
+        }
159
+
160
+        NavigationApplication.instance.runOnMainThread(new Runnable() {
161
+            @Override
162
+            public void run() {
163
+                currentActivity.dismissTopModal();
164
+            }
165
+        });
166
+    }
153 167
 }

+ 1
- 1
src/deprecated/platformSpecificDeprecated.android.js View File

@@ -211,7 +211,7 @@ function showModal(params) {
211 211
 }
212 212
 
213 213
 function dismissModal() {
214
-  //RctActivity.dismissModal();
214
+  newPlatformSpecific.dismissTopModal();
215 215
 }
216 216
 
217 217
 function dismissAllModals(params) {

+ 6
- 1
src/platformSpecific.android.js View File

@@ -50,6 +50,10 @@ function showModal(screenParams) {
50 50
   NativeBridge.showModal(screenParams);
51 51
 }
52 52
 
53
+function dismissTopModal() {
54
+  NativeBridge.dismissTopModal();
55
+}
56
+
53 57
 module.exports = {
54 58
   startApp,
55 59
   push,
@@ -59,5 +63,6 @@ module.exports = {
59 63
   toggleTopBarVisible,
60 64
   setScreenTitleBarTitle,
61 65
   setScreenTitleBarButtons,
62
-  showModal
66
+  showModal,
67
+  dismissTopModal
63 68
 };