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

+ 1
- 1
package.json View File

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

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

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