Browse Source

V1 [iOS/Android] Feature/async dismiss modal (#2975)

* for iOS

* first try for android

* iOS indent

* Android Indent

* Update platformSpecific.android.js

* Update NavigationReactModule.java

* Update NavigationCommandsHandler.java

* Update platformSpecificDeprecated.android.js

* Update platformSpecificDeprecated.ios.js
Quentin Valmori 6 years ago
parent
commit
0557b61ab2

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

214
     }
214
     }
215
 
215
 
216
     @ReactMethod
216
     @ReactMethod
217
-    public void dismissAllModals() {
218
-        NavigationCommandsHandler.dismissAllModals();
217
+    public void dismissAllModals(Promise promise) {
218
+        NavigationCommandsHandler.dismissAllModals(promise);
219
     }
219
     }
220
 
220
 
221
     @ReactMethod
221
     @ReactMethod
222
-    public void dismissTopModal(final ReadableMap params) {
223
-        NavigationCommandsHandler.dismissTopModal(ScreenParamsParser.parse(BundleConverter.toBundle(params)));
222
+    public void dismissTopModal(final ReadableMap params, Promise promise) {
223
+        NavigationCommandsHandler.dismissTopModal(ScreenParamsParser.parse(BundleConverter.toBundle(params)), promise);
224
     }
224
     }
225
 
225
 
226
     @ReactMethod
226
     @ReactMethod

+ 4
- 2
android/app/src/main/java/com/reactnativenavigation/controllers/NavigationCommandsHandler.java View File

247
         });
247
         });
248
     }
248
     }
249
 
249
 
250
-    public static void dismissTopModal(final ScreenParams params) {
250
+    public static void dismissTopModal(final ScreenParams params, final Promise promise) {
251
         final NavigationActivity currentActivity = NavigationActivity.currentActivity;
251
         final NavigationActivity currentActivity = NavigationActivity.currentActivity;
252
         if (currentActivity == null) {
252
         if (currentActivity == null) {
253
             return;
253
             return;
257
             @Override
257
             @Override
258
             public void run() {
258
             public void run() {
259
                 currentActivity.dismissTopModal(params);
259
                 currentActivity.dismissTopModal(params);
260
+                promise.resolve("true");
260
             }
261
             }
261
         });
262
         });
262
     }
263
     }
263
 
264
 
264
-    public static void dismissAllModals() {
265
+    public static void dismissAllModals(final Promise promise) {
265
         final NavigationActivity currentActivity = NavigationActivity.currentActivity;
266
         final NavigationActivity currentActivity = NavigationActivity.currentActivity;
266
         if (currentActivity == null) {
267
         if (currentActivity == null) {
267
             return;
268
             return;
271
             @Override
272
             @Override
272
             public void run() {
273
             public void run() {
273
                 currentActivity.dismissAllModals();
274
                 currentActivity.dismissAllModals();
275
+                promise.resolve("true");
274
             }
276
             }
275
         });
277
         });
276
     }
278
     }

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

559
   });
559
   });
560
 }
560
 }
561
 
561
 
562
-function dismissAllModals(params) {
563
-  newPlatformSpecific.dismissAllModals();
562
+async function dismissAllModals(params) {
563
+  return await newPlatformSpecific.dismissAllModals();
564
 }
564
 }
565
 
565
 
566
 function showInAppNotification(params) {
566
 function showInAppNotification(params) {

+ 2
- 2
src/deprecated/platformSpecificDeprecated.ios.js View File

631
   return await Modal.dismissController(params.animationType);
631
   return await Modal.dismissController(params.animationType);
632
 }
632
 }
633
 
633
 
634
-function dismissAllModals(params) {
635
-  Modal.dismissAllControllers(params.animationType);
634
+async function dismissAllModals(params) {
635
+  return await Modal.dismissAllControllers(params.animationType);
636
 }
636
 }
637
 
637
 
638
 function showLightBox(params) {
638
 function showLightBox(params) {

+ 4
- 4
src/platformSpecific.android.js View File

62
   NativeReactModule.dismissLightBox();
62
   NativeReactModule.dismissLightBox();
63
 }
63
 }
64
 
64
 
65
-function dismissTopModal(params) {
66
-  NativeReactModule.dismissTopModal(params);
65
+async function dismissTopModal(params) {
66
+  return await NativeReactModule.dismissTopModal(params);
67
 }
67
 }
68
 
68
 
69
-function dismissAllModals() {
70
-  NativeReactModule.dismissAllModals();
69
+async function dismissAllModals() {
70
+  return await NativeReactModule.dismissAllModals();
71
 }
71
 }
72
 
72
 
73
 function showInAppNotification(params) {
73
 function showInAppNotification(params) {