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
           <Text style={styles.button}>Close Modal</Text>
35
           <Text style={styles.button}>Close Modal</Text>
36
         </TouchableOpacity>
36
         </TouchableOpacity>
37
 
37
 
38
+        <TouchableOpacity onPress={ this.onCloseAllPress.bind(this) }>
39
+          <Text style={styles.button}>Close All Modals</Text>
40
+        </TouchableOpacity>
41
+
38
       </View>
42
       </View>
39
     );
43
     );
40
   }
44
   }
58
   onClosePress() {
62
   onClosePress() {
59
     this.props.navigator.dismissModal();
63
     this.props.navigator.dismissModal();
60
   }
64
   }
65
+  onCloseAllPress() {
66
+    this.props.navigator.dismissAllModals();
67
+  }
61
 }
68
 }
62
 
69
 
63
 const styles = StyleSheet.create({
70
 const styles = StyleSheet.create({

+ 5
- 0
src/Navigation.js View File

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

+ 3
- 0
src/Screen.js View File

29
   dismissModal(params = {}) {
29
   dismissModal(params = {}) {
30
     return Navigation.dismissModal(params);
30
     return Navigation.dismissModal(params);
31
   }
31
   }
32
+  dismissAllModals(params = {}) {
33
+    return Navigation.dismissAllModals(params);
34
+  }
32
   showLightBox(params = {}) {
35
   showLightBox(params = {}) {
33
     return Navigation.showLightBox(params);
36
     return Navigation.showLightBox(params);
34
   }
37
   }

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

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