Pārlūkot izejas kodu

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 gadus atpakaļ
vecāks
revīzija
0557b61ab2

+ 4
- 4
android/app/src/main/java/com/reactnativenavigation/bridge/NavigationReactModule.java Parādīt failu

@@ -214,13 +214,13 @@ public class NavigationReactModule extends ReactContextBaseJavaModule {
214 214
     }
215 215
 
216 216
     @ReactMethod
217
-    public void dismissAllModals() {
218
-        NavigationCommandsHandler.dismissAllModals();
217
+    public void dismissAllModals(Promise promise) {
218
+        NavigationCommandsHandler.dismissAllModals(promise);
219 219
     }
220 220
 
221 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 226
     @ReactMethod

+ 4
- 2
android/app/src/main/java/com/reactnativenavigation/controllers/NavigationCommandsHandler.java Parādīt failu

@@ -247,7 +247,7 @@ public class NavigationCommandsHandler {
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 251
         final NavigationActivity currentActivity = NavigationActivity.currentActivity;
252 252
         if (currentActivity == null) {
253 253
             return;
@@ -257,11 +257,12 @@ public class NavigationCommandsHandler {
257 257
             @Override
258 258
             public void run() {
259 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 266
         final NavigationActivity currentActivity = NavigationActivity.currentActivity;
266 267
         if (currentActivity == null) {
267 268
             return;
@@ -271,6 +272,7 @@ public class NavigationCommandsHandler {
271 272
             @Override
272 273
             public void run() {
273 274
                 currentActivity.dismissAllModals();
275
+                promise.resolve("true");
274 276
             }
275 277
         });
276 278
     }

+ 2
- 2
src/deprecated/platformSpecificDeprecated.android.js Parādīt failu

@@ -559,8 +559,8 @@ function dismissModal(params) {
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 566
 function showInAppNotification(params) {

+ 2
- 2
src/deprecated/platformSpecificDeprecated.ios.js Parādīt failu

@@ -631,8 +631,8 @@ async function dismissModal(params) {
631 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 638
 function showLightBox(params) {

+ 4
- 4
src/platformSpecific.android.js Parādīt failu

@@ -62,12 +62,12 @@ function dismissLightBox() {
62 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 73
 function showInAppNotification(params) {