Browse Source

bug fix with modals

talkol 8 years ago
parent
commit
5e74e13388
3 changed files with 25 additions and 4 deletions
  1. 11
    0
      example/src/screens/ModalScreen.js
  2. 1
    1
      package.json
  3. 13
    3
      src/platformSpecific.ios.js

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

@@ -15,6 +15,12 @@ import './StyledScreen';
15 15
 
16 16
 // instead of React.Component, we extend Screen (imported above)
17 17
 class ModalScreen extends Screen {
18
+  static navigatorButtons = {
19
+    leftButtons: [{
20
+      title: 'Close',
21
+      id: 'close'
22
+    }]
23
+  };
18 24
   constructor(props) {
19 25
     super(props);
20 26
   }
@@ -37,6 +43,11 @@ class ModalScreen extends Screen {
37 43
       </View>
38 44
     );
39 45
   }
46
+  onNavigatorEvent(event) {
47
+    if (event.id == 'close') {
48
+      this.navigator.dismissModal();
49
+    }
50
+  }
40 51
   onPushPress() {
41 52
     this.navigator.push({
42 53
       title: "More",

+ 1
- 1
package.json View File

@@ -7,7 +7,7 @@
7 7
     "type": "git",
8 8
     "url": "https://github.com/wix/react-native-navigation.git"
9 9
   },
10
-  "version": "0.0.2",
10
+  "version": "0.0.3",
11 11
   "description": "React Native Navigation - truly native navigation for iOS and Android",
12 12
   "nativePackage": true,
13 13
   "bugs": {

+ 13
- 3
src/platformSpecific.ios.js View File

@@ -166,19 +166,29 @@ function showModal(params) {
166 166
     console.error('showModal(params): params.screen is required');
167 167
     return;
168 168
   }
169
-  const { navigatorStyle } = _mergeScreenSpecificSettings(params.screen, params);
170 169
   const controllerID = utils.getRandomId();
171 170
   const Controller = Controllers.createClass({
172 171
     render: function() {
173 172
       const navigatorID = controllerID + '_nav';
174
-      const { navigatorStyle } = _mergeScreenSpecificSettings(params.screen, params);
173
+      const screenInstanceID = utils.getRandomId();
174
+      const {
175
+        navigatorStyle,
176
+        navigatorButtons,
177
+        navigatorEventID
178
+      } = _mergeScreenSpecificSettings(params.screen, screenInstanceID, params);
175 179
       return (
176 180
         <NavigationControllerIOS
177 181
           id={navigatorID}
178 182
           title={params.title}
179 183
           component={params.screen}
180
-          passProps={{navigatorID: navigatorID}}
184
+          passProps={{
185
+            navigatorID: navigatorID,
186
+            screenInstanceID: screenInstanceID,
187
+            navigatorEventID: navigatorEventID
188
+          }}
181 189
           style={navigatorStyle}
190
+          leftButtons={navigatorButtons.leftButtons}
191
+          rightButtons={navigatorButtons.rightButtons}
182 192
         />
183 193
       );
184 194
     }