Browse Source

added support for closeAllModals

talkol 8 years ago
parent
commit
19a11b054b
4 changed files with 22 additions and 2 deletions
  1. 7
    0
      example/src/screens/ModalScreen.js
  2. 5
    0
      src/Navigation.js
  3. 3
    0
      src/Screen.js
  4. 7
    2
      src/platformSpecific.ios.js

+ 7
- 0
example/src/screens/ModalScreen.js View File

@@ -35,6 +35,10 @@ export default class ModalScreen extends Component {
35 35
           <Text style={styles.button}>Close Modal</Text>
36 36
         </TouchableOpacity>
37 37
 
38
+        <TouchableOpacity onPress={ this.onCloseAllPress.bind(this) }>
39
+          <Text style={styles.button}>Close All Modals</Text>
40
+        </TouchableOpacity>
41
+
38 42
       </View>
39 43
     );
40 44
   }
@@ -58,6 +62,9 @@ export default class ModalScreen extends Component {
58 62
   onClosePress() {
59 63
     this.props.navigator.dismissModal();
60 64
   }
65
+  onCloseAllPress() {
66
+    this.props.navigator.dismissAllModals();
67
+  }
61 68
 }
62 69
 
63 70
 const styles = StyleSheet.create({

+ 5
- 0
src/Navigation.js View File

@@ -67,6 +67,10 @@ function dismissModal(params = {}) {
67 67
   return platformSpecific.dismissModal(params);
68 68
 }
69 69
 
70
+function dismissAllModals(params = {}) {
71
+  return platformSpecific.dismissAllModals(params);
72
+}
73
+
70 74
 function showLightBox(params = {}) {
71 75
   return platformSpecific.showLightBox(params);
72 76
 }
@@ -81,6 +85,7 @@ export default {
81 85
   registerComponent,
82 86
   showModal,
83 87
   dismissModal,
88
+  dismissAllModals,
84 89
   showLightBox,
85 90
   dismissLightBox,
86 91
   startTabBasedApp: platformSpecific.startTabBasedApp,

+ 3
- 0
src/Screen.js View File

@@ -29,6 +29,9 @@ class Navigator {
29 29
   dismissModal(params = {}) {
30 30
     return Navigation.dismissModal(params);
31 31
   }
32
+  dismissAllModals(params = {}) {
33
+    return Navigation.dismissAllModals(params);
34
+  }
32 35
   showLightBox(params = {}) {
33 36
     return Navigation.showLightBox(params);
34 37
   }

+ 7
- 2
src/platformSpecific.ios.js View File

@@ -76,7 +76,7 @@ function startTabBasedApp(params) {
76 76
     }
77 77
   });
78 78
   ControllerRegistry.registerController(controllerID, () => Controller);
79
-  ControllerRegistry.setRootController(controllerID, params.animationType, params.passProps || {});
79
+  ControllerRegistry.setRootController(controllerID);
80 80
 }
81 81
 
82 82
 function startSingleScreenApp(params) {
@@ -134,7 +134,7 @@ function startSingleScreenApp(params) {
134 134
     }
135 135
   });
136 136
   ControllerRegistry.registerController(controllerID, () => Controller);
137
-  ControllerRegistry.setRootController(controllerID, params.animationType, params.passProps || {});
137
+  ControllerRegistry.setRootController(controllerID);
138 138
 }
139 139
 
140 140
 function _mergeScreenSpecificSettings(screenID, screenInstanceID, params) {
@@ -350,6 +350,10 @@ function dismissModal(params) {
350 350
   Modal.dismissController(params.animationType);
351 351
 }
352 352
 
353
+function dismissAllModals(params) {
354
+  Modal.dismissAllControllers(params.animationType);
355
+}
356
+
353 357
 function showLightBox(params) {
354 358
   if (!params.screen) {
355 359
     console.error('showLightBox(params): params.screen is required');
@@ -387,6 +391,7 @@ export default {
387 391
   navigatorResetTo,
388 392
   showModal,
389 393
   dismissModal,
394
+  dismissAllModals,
390 395
   showLightBox,
391 396
   dismissLightBox,
392 397
   navigatorSetButtons,