Browse Source

dismissAllModals

Daniel Zlotin 8 years ago
parent
commit
85cf841e5d

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

104
     }
104
     }
105
 
105
 
106
     @ReactMethod
106
     @ReactMethod
107
-    public void dismissAllModals(final ReadableMap params) {
107
+    public void dismissAllModals() {
108
+        NavigationCommandsHandler.dismissAlModals();
108
     }
109
     }
109
 
110
 
110
     @ReactMethod
111
     @ReactMethod

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

22
         stack.add(modal);
22
         stack.add(modal);
23
     }
23
     }
24
 
24
 
25
-    public void dismissModal() {
25
+    public void dismissTopModal() {
26
         if (isShowing()) {
26
         if (isShowing()) {
27
             stack.pop().dismiss();
27
             stack.pop().dismiss();
28
         }
28
         }
29
     }
29
     }
30
 
30
 
31
+    public void dismissAllModals() {
32
+        while (isShowing()) {
33
+            dismissTopModal();
34
+        }
35
+    }
36
+
31
     public boolean onBackPressed() {
37
     public boolean onBackPressed() {
32
         Log.d("LOG", "ModalController.onBackPressed ");
38
         Log.d("LOG", "ModalController.onBackPressed ");
33
         return false;
39
         return false;
69
     public void onModalDismissed(Modal modal) {
75
     public void onModalDismissed(Modal modal) {
70
         stack.remove(modal);
76
         stack.remove(modal);
71
     }
77
     }
78
+
72
 }
79
 }

+ 5
- 1
android/app/src/main/java/com/reactnativenavigation/controllers/NavigationActivity.java View File

150
     }
150
     }
151
 
151
 
152
     void dismissTopModal() {
152
     void dismissTopModal() {
153
-        modalController.dismissModal();
153
+        modalController.dismissTopModal();
154
+    }
155
+
156
+    void dismissAllModals() {
157
+        modalController.dismissAllModals();
154
     }
158
     }
155
 }
159
 }

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

164
             }
164
             }
165
         });
165
         });
166
     }
166
     }
167
+
168
+    public static void dismissAlModals() {
169
+        final NavigationActivity currentActivity = NavigationActivity.currentActivity;
170
+        if (currentActivity == null) {
171
+            return;
172
+        }
173
+
174
+        NavigationApplication.instance.runOnMainThread(new Runnable() {
175
+            @Override
176
+            public void run() {
177
+                currentActivity.dismissAllModals();
178
+            }
179
+        });
180
+    }
167
 }
181
 }

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

215
 }
215
 }
216
 
216
 
217
 function dismissAllModals(params) {
217
 function dismissAllModals(params) {
218
-  //RctActivity.dismissAllModals(params.animationType);
218
+  newPlatformSpecific.dismissAllModals();
219
 }
219
 }
220
 
220
 
221
 function addNavigatorParams(screen, navigator = null, idx = '') {
221
 function addNavigatorParams(screen, navigator = null, idx = '') {

+ 17
- 12
src/platformSpecific.android.js View File

4
 
4
 
5
 import Navigation from './Navigation';
5
 import Navigation from './Navigation';
6
 
6
 
7
-NativeBridge = NativeModules.NavigationReactModule;
7
+const NativeReactModule = NativeModules.NavigationReactModule;
8
 
8
 
9
 const resolveAssetSource = require('react-native/Libraries/Image/resolveAssetSource');
9
 const resolveAssetSource = require('react-native/Libraries/Image/resolveAssetSource');
10
 
10
 
15
     return;
15
     return;
16
   }
16
   }
17
 
17
 
18
-  NativeBridge.startApp(activityParams);
18
+  NativeReactModule.startApp(activityParams);
19
 }
19
 }
20
 
20
 
21
 function push(screenParams) {
21
 function push(screenParams) {
22
-  NativeBridge.push(screenParams);
22
+  NativeReactModule.push(screenParams);
23
 }
23
 }
24
 
24
 
25
 function pop(screenParams) {
25
 function pop(screenParams) {
26
-  NativeBridge.pop(screenParams);
26
+  NativeReactModule.pop(screenParams);
27
 }
27
 }
28
 
28
 
29
 function popToRoot(screenParams) {
29
 function popToRoot(screenParams) {
30
-  NativeBridge.popToRoot(screenParams);
30
+  NativeReactModule.popToRoot(screenParams);
31
 }
31
 }
32
 
32
 
33
 function newStack(screenParams) {
33
 function newStack(screenParams) {
34
-  NativeBridge.newStack(screenParams);
34
+  NativeReactModule.newStack(screenParams);
35
 }
35
 }
36
 
36
 
37
 function toggleTopBarVisible(screenInstanceID, visible, animated) {
37
 function toggleTopBarVisible(screenInstanceID, visible, animated) {
38
-  NativeBridge.setTopBarVisible(screenInstanceID, visible, animated);
38
+  NativeReactModule.setTopBarVisible(screenInstanceID, visible, animated);
39
 }
39
 }
40
 
40
 
41
 function setScreenTitleBarTitle(screenInstanceID, title) {
41
 function setScreenTitleBarTitle(screenInstanceID, title) {
42
-  NativeBridge.setScreenTitleBarTitle(screenInstanceID, title);
42
+  NativeReactModule.setScreenTitleBarTitle(screenInstanceID, title);
43
 }
43
 }
44
 
44
 
45
 function setScreenTitleBarButtons(screenInstanceID, navigatorEventID, buttons) {
45
 function setScreenTitleBarButtons(screenInstanceID, navigatorEventID, buttons) {
46
-  NativeBridge.setScreenTitleBarButtons(screenInstanceID, navigatorEventID, buttons);
46
+  NativeReactModule.setScreenTitleBarButtons(screenInstanceID, navigatorEventID, buttons);
47
 }
47
 }
48
 
48
 
49
 function showModal(screenParams) {
49
 function showModal(screenParams) {
50
-  NativeBridge.showModal(screenParams);
50
+  NativeReactModule.showModal(screenParams);
51
 }
51
 }
52
 
52
 
53
 function dismissTopModal() {
53
 function dismissTopModal() {
54
-  NativeBridge.dismissTopModal();
54
+  NativeReactModule.dismissTopModal();
55
+}
56
+
57
+function dismissAllModals() {
58
+  NativeReactModule.dismissAllModals();
55
 }
59
 }
56
 
60
 
57
 module.exports = {
61
 module.exports = {
64
   setScreenTitleBarTitle,
68
   setScreenTitleBarTitle,
65
   setScreenTitleBarButtons,
69
   setScreenTitleBarButtons,
66
   showModal,
70
   showModal,
67
-  dismissTopModal
71
+  dismissTopModal,
72
+  dismissAllModals
68
 };
73
 };