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
 
109
 
110
     @ReactMethod
110
     @ReactMethod
111
     public void dismissTopModal() {
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
     }
23
     }
24
 
24
 
25
     public void dismissModal() {
25
     public void dismissModal() {
26
-        stack.pop().destroy();
26
+        if (isShowing()) {
27
+            stack.pop().dismiss();
28
+        }
27
     }
29
     }
28
 
30
 
29
     public boolean onBackPressed() {
31
     public boolean onBackPressed() {
58
     public void destroy() {
60
     public void destroy() {
59
         for (Modal modal : stack) {
61
         for (Modal modal : stack) {
60
             modal.destroy();
62
             modal.destroy();
63
+            modal.dismiss();
61
         }
64
         }
62
         stack.clear();
65
         stack.clear();
63
     }
66
     }

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

148
     void showModal(ScreenParams screenParams) {
148
     void showModal(ScreenParams screenParams) {
149
         modalController.showModal(screenParams);
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
             }
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
 }
211
 }
212
 
212
 
213
 function dismissModal() {
213
 function dismissModal() {
214
-  //RctActivity.dismissModal();
214
+  newPlatformSpecific.dismissTopModal();
215
 }
215
 }
216
 
216
 
217
 function dismissAllModals(params) {
217
 function dismissAllModals(params) {

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

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