Browse Source

reverted throttled commands, refactored uniqueIds

Daniel Zlotin 8 years ago
parent
commit
f3e8b3f316

+ 4
- 5
src/Navigation.js View File

2
 import {AppRegistry} from 'react-native';
2
 import {AppRegistry} from 'react-native';
3
 import platformSpecific from './deprecated/platformSpecificDeprecated';
3
 import platformSpecific from './deprecated/platformSpecificDeprecated';
4
 import Screen from './Screen';
4
 import Screen from './Screen';
5
-import _ from 'lodash';
6
 
5
 
7
 const registeredScreens = {};
6
 const registeredScreens = {};
8
 
7
 
106
   registerScreen,
105
   registerScreen,
107
   getRegisteredScreen,
106
   getRegisteredScreen,
108
   registerComponent,
107
   registerComponent,
109
-  showModal: _.throttle(showModal, 1000, {leading: true, trailing: false}),
108
+  showModal: showModal,
110
   dismissModal: dismissModal,
109
   dismissModal: dismissModal,
111
   dismissAllModals: dismissAllModals,
110
   dismissAllModals: dismissAllModals,
112
-  showLightBox: _.throttle(showLightBox, 1000, {leading: true, trailing: false}),
111
+  showLightBox: showLightBox,
113
   dismissLightBox: dismissLightBox,
112
   dismissLightBox: dismissLightBox,
114
   showInAppNotification: showInAppNotification,
113
   showInAppNotification: showInAppNotification,
115
   dismissInAppNotification: dismissInAppNotification,
114
   dismissInAppNotification: dismissInAppNotification,
116
-  startTabBasedApp: _.throttle(startTabBasedApp, 1000, {leading: true, trailing: false}),
117
-  startSingleScreenApp: _.throttle(startSingleScreenApp, 1000, {leading: true, trailing: false})
115
+  startTabBasedApp: startTabBasedApp,
116
+  startSingleScreenApp: startSingleScreenApp
118
 };
117
 };

+ 9
- 10
src/Screen.js View File

6
 } from 'react-native';
6
 } from 'react-native';
7
 import platformSpecific from './deprecated/platformSpecificDeprecated';
7
 import platformSpecific from './deprecated/platformSpecificDeprecated';
8
 import Navigation from './Navigation';
8
 import Navigation from './Navigation';
9
-import _ from 'lodash';
10
 
9
 
11
 const _allNavigatorEventHandlers = {};
10
 const _allNavigatorEventHandlers = {};
12
 
11
 
13
-const throttledPlatformSpecificFunctions = {
14
-  push: _.throttle(platformSpecific.navigatorPush, 1000, {leading: true, trailing: false}),
15
-  pop: _.throttle(platformSpecific.navigatorPop, 100, {leading: true, trailing: false}),
16
-  popToRoot: _.throttle(platformSpecific.navigatorPopToRoot, 100, {leading: true, trailing: false}),
17
-  resetTo: _.throttle(platformSpecific.navigatorResetTo, 100, {leading: true, trailing: false})
12
+const NavigationSpecific = {
13
+  push: platformSpecific.navigatorPush,
14
+  pop: platformSpecific.navigatorPop,
15
+  popToRoot: platformSpecific.navigatorPopToRoot,
16
+  resetTo: platformSpecific.navigatorResetTo
18
 };
17
 };
19
 
18
 
20
 class Navigator {
19
 class Navigator {
27
   }
26
   }
28
 
27
 
29
   push(params = {}) {
28
   push(params = {}) {
30
-    return throttledPlatformSpecificFunctions.push(this, params);
29
+    return NavigationSpecific.push(this, params);
31
   }
30
   }
32
 
31
 
33
   pop(params = {}) {
32
   pop(params = {}) {
34
-    return throttledPlatformSpecificFunctions.pop(this, params);
33
+    return NavigationSpecific.pop(this, params);
35
   }
34
   }
36
 
35
 
37
   popToRoot(params = {}) {
36
   popToRoot(params = {}) {
38
-    return throttledPlatformSpecificFunctions.popToRoot(this, params);
37
+    return NavigationSpecific.popToRoot(this, params);
39
   }
38
   }
40
 
39
 
41
   resetTo(params = {}) {
40
   resetTo(params = {}) {
42
-    return throttledPlatformSpecificFunctions.resetTo(this, params);
41
+    return NavigationSpecific.resetTo(this, params);
43
   }
42
   }
44
 
43
 
45
   showModal(params = {}) {
44
   showModal(params = {}) {

+ 2
- 3
src/deprecated/platformSpecificDeprecated.android.js View File

1
 import React, {Component} from 'react';
1
 import React, {Component} from 'react';
2
 import {AppRegistry, NativeModules} from 'react-native';
2
 import {AppRegistry, NativeModules} from 'react-native';
3
 import _ from 'lodash';
3
 import _ from 'lodash';
4
-import utils from './utils';
5
 
4
 
6
 import Navigation from './../Navigation';
5
 import Navigation from './../Navigation';
7
 
6
 
259
 }
258
 }
260
 
259
 
261
 function addNavigatorParams(screen, navigator = null, idx = '') {
260
 function addNavigatorParams(screen, navigator = null, idx = '') {
262
-  screen.navigatorID = navigator ? navigator.navigatorID : utils.getRandomId() + '_nav' + idx;
263
-  screen.screenInstanceID = utils.getRandomId();
261
+  screen.navigatorID = navigator ? navigator.navigatorID : _.uniqueId('navigatorID') + '_nav' + idx;
262
+  screen.screenInstanceID = _.uniqueId('screenInstanceID');
264
   screen.navigatorEventID = screen.screenInstanceID + '_events';
263
   screen.navigatorEventID = screen.screenInstanceID + '_events';
265
 }
264
 }
266
 
265
 

+ 13
- 13
src/deprecated/platformSpecificDeprecated.ios.js View File

1
-import utils from './utils';
2
 import Navigation from './../Navigation';
1
 import Navigation from './../Navigation';
3
 import Controllers, {Modal, Notification} from 'react-native-controllers';
2
 import Controllers, {Modal, Notification} from 'react-native-controllers';
4
 const React = Controllers.hijackReact();
3
 const React = Controllers.hijackReact();
8
   NavigationControllerIOS,
7
   NavigationControllerIOS,
9
   DrawerControllerIOS
8
   DrawerControllerIOS
10
 } = React;
9
 } = React;
10
+import _ from 'lodash';
11
 
11
 
12
 function startTabBasedApp(params) {
12
 function startTabBasedApp(params) {
13
   if (!params.tabs) {
13
   if (!params.tabs) {
14
     console.error('startTabBasedApp(params): params.tabs is required');
14
     console.error('startTabBasedApp(params): params.tabs is required');
15
     return;
15
     return;
16
   }
16
   }
17
-  const controllerID = utils.getRandomId();
17
+  const controllerID = _.uniqueId('controllerID');
18
   const Controller = Controllers.createClass({
18
   const Controller = Controllers.createClass({
19
     render: function() {
19
     render: function() {
20
       if (!params.drawer || (!params.drawer.left && !params.drawer.right)) {
20
       if (!params.drawer || (!params.drawer.left && !params.drawer.right)) {
44
           {
44
           {
45
             params.tabs.map(function(tab, index) {
45
             params.tabs.map(function(tab, index) {
46
               const navigatorID = controllerID + '_nav' + index;
46
               const navigatorID = controllerID + '_nav' + index;
47
-              const screenInstanceID = utils.getRandomId();
47
+              const screenInstanceID = _.uniqueId('screenInstanceID');
48
               if (!tab.screen) {
48
               if (!tab.screen) {
49
                 console.error('startTabBasedApp(params): every tab must include a screen property, take a look at tab#' + (index + 1));
49
                 console.error('startTabBasedApp(params): every tab must include a screen property, take a look at tab#' + (index + 1));
50
                 return;
50
                 return;
87
     console.error('startSingleScreenApp(params): params.screen is required');
87
     console.error('startSingleScreenApp(params): params.screen is required');
88
     return;
88
     return;
89
   }
89
   }
90
-  const controllerID = utils.getRandomId();
90
+  const controllerID = _.uniqueId('controllerID');
91
   const Controller = Controllers.createClass({
91
   const Controller = Controllers.createClass({
92
     render: function() {
92
     render: function() {
93
       if (!params.drawer || (!params.drawer.left && !params.drawer.right)) {
93
       if (!params.drawer || (!params.drawer.left && !params.drawer.right)) {
109
     renderBody: function() {
109
     renderBody: function() {
110
       const screen = params.screen;
110
       const screen = params.screen;
111
       const navigatorID = controllerID + '_nav';
111
       const navigatorID = controllerID + '_nav';
112
-      const screenInstanceID = utils.getRandomId();
112
+      const screenInstanceID = _.uniqueId('screenInstanceID');
113
       if (!screen.screen) {
113
       if (!screen.screen) {
114
         console.error('startSingleScreenApp(params): screen must include a screen property');
114
         console.error('startSingleScreenApp(params): screen must include a screen property');
115
         return;
115
         return;
175
     console.error('Navigator.push(params): params.screen is required');
175
     console.error('Navigator.push(params): params.screen is required');
176
     return;
176
     return;
177
   }
177
   }
178
-  const screenInstanceID = utils.getRandomId();
178
+  const screenInstanceID = _.uniqueId('screenInstanceID');
179
   const {
179
   const {
180
     navigatorStyle,
180
     navigatorStyle,
181
     navigatorButtons,
181
     navigatorButtons,
216
     console.error('Navigator.resetTo(params): params.screen is required');
216
     console.error('Navigator.resetTo(params): params.screen is required');
217
     return;
217
     return;
218
   }
218
   }
219
-  const screenInstanceID = utils.getRandomId();
219
+  const screenInstanceID = _.uniqueId('screenInstanceID');
220
   const {
220
   const {
221
     navigatorStyle,
221
     navigatorStyle,
222
     navigatorButtons,
222
     navigatorButtons,
337
     console.error('showModal(params): params.screen is required');
337
     console.error('showModal(params): params.screen is required');
338
     return;
338
     return;
339
   }
339
   }
340
-  const controllerID = utils.getRandomId();
340
+  const controllerID = _.uniqueId('controllerID');
341
   const Controller = Controllers.createClass({
341
   const Controller = Controllers.createClass({
342
     render: function() {
342
     render: function() {
343
       const navigatorID = controllerID + '_nav';
343
       const navigatorID = controllerID + '_nav';
344
-      const screenInstanceID = utils.getRandomId();
344
+      const screenInstanceID = _.uniqueId('screenInstanceID');
345
       const {
345
       const {
346
         navigatorStyle,
346
         navigatorStyle,
347
         navigatorButtons,
347
         navigatorButtons,
381
     console.error('showLightBox(params): params.screen is required');
381
     console.error('showLightBox(params): params.screen is required');
382
     return;
382
     return;
383
   }
383
   }
384
-  const controllerID = utils.getRandomId();
384
+  const controllerID = _.uniqueId('controllerID');
385
   const navigatorID = controllerID + '_nav';
385
   const navigatorID = controllerID + '_nav';
386
-  const screenInstanceID = utils.getRandomId();
386
+  const screenInstanceID = _.uniqueId('screenInstanceID');
387
   const {
387
   const {
388
     navigatorStyle,
388
     navigatorStyle,
389
     navigatorButtons,
389
     navigatorButtons,
410
     return;
410
     return;
411
   }
411
   }
412
 
412
 
413
-  const controllerID = utils.getRandomId();
413
+  const controllerID = _.uniqueId('controllerID');
414
   const navigatorID = controllerID + '_nav';
414
   const navigatorID = controllerID + '_nav';
415
-  const screenInstanceID = utils.getRandomId();
415
+  const screenInstanceID = _.uniqueId('screenInstanceID');
416
   const {
416
   const {
417
     navigatorStyle,
417
     navigatorStyle,
418
     navigatorButtons,
418
     navigatorButtons,

+ 0
- 7
src/deprecated/utils.js View File

1
-function getRandomId() {
2
-  return (Math.random()*1e20).toString(36);
3
-}
4
-
5
-export default {
6
-  getRandomId
7
-}

+ 0
- 3
src/platformSpecific.android.js View File

1
 import React, {Component} from 'react';
1
 import React, {Component} from 'react';
2
 import {AppRegistry, NativeModules} from 'react-native';
2
 import {AppRegistry, NativeModules} from 'react-native';
3
-import _ from 'lodash';
4
-
5
-import Navigation from './Navigation';
6
 
3
 
7
 const NativeReactModule = NativeModules.NavigationReactModule;
4
 const NativeReactModule = NativeModules.NavigationReactModule;
8
 
5
 

+ 1
- 468
src/platformSpecific.ios.js View File

1
-/**
2
- * copy paste from deprecated - for now
3
- */
4
-
5
-import utils from './utils';
6
-import Navigation from './../Navigation';
7
-import Controllers, {Modal, Notification} from 'react-native-controllers';
8
-const React = Controllers.hijackReact();
9
-const {
10
-  ControllerRegistry,
11
-  TabBarControllerIOS,
12
-  NavigationControllerIOS,
13
-  DrawerControllerIOS
14
-} = React;
15
-
16
-function startTabBasedApp(params) {
17
-  if (!params.tabs) {
18
-    console.error('startTabBasedApp(params): params.tabs is required');
19
-    return;
20
-  }
21
-  const controllerID = utils.getRandomId();
22
-  const Controller = Controllers.createClass({
23
-    render: function() {
24
-      if (!params.drawer || (!params.drawer.left && !params.drawer.right)) {
25
-        return this.renderBody();
26
-      } else {
27
-        const navigatorID = controllerID + '_drawer';
28
-        return (
29
-          <DrawerControllerIOS id={navigatorID}
30
-                               componentLeft={params.drawer.left ? params.drawer.left.screen : undefined}
31
-                               passPropsLeft={{navigatorID: navigatorID}}
32
-                               componentRight={params.drawer.right ? params.drawer.right.screen : undefined}
33
-                               passPropsRight={{navigatorID: navigatorID}}
34
-                               disableOpenGesture={params.drawer.disableOpenGesture}
35
-                               type={params.drawer.type ? params.drawer.type : undefined}
36
-                               animationType={params.drawer.animationType ? params.drawer.animationType : undefined}
37
-          >
38
-            {this.renderBody()}
39
-          </DrawerControllerIOS>
40
-        );
41
-      }
42
-    },
43
-    renderBody: function() {
44
-      return (
45
-        <TabBarControllerIOS
46
-          id={controllerID + '_tabs'}
47
-          style={params.tabsStyle}>
48
-          {
49
-            params.tabs.map(function(tab, index) {
50
-              const navigatorID = controllerID + '_nav' + index;
51
-              const screenInstanceID = utils.getRandomId();
52
-              if (!tab.screen) {
53
-                console.error('startTabBasedApp(params): every tab must include a screen property, take a look at tab#' + (index + 1));
54
-                return;
55
-              }
56
-              const {
57
-                navigatorStyle,
58
-                navigatorButtons,
59
-                navigatorEventID
60
-              } = _mergeScreenSpecificSettings(tab.screen, screenInstanceID, tab);
61
-              return (
62
-                <TabBarControllerIOS.Item {...tab} title={tab.label}>
63
-                  <NavigationControllerIOS
64
-                    id={navigatorID}
65
-                    title={tab.title}
66
-                    titleImage={tab.titleImage}
67
-                    component={tab.screen}
68
-                    passProps={{
69
-                    navigatorID: navigatorID,
70
-                    screenInstanceID: screenInstanceID,
71
-                    navigatorEventID: navigatorEventID
72
-                  }}
73
-                    style={navigatorStyle}
74
-                    leftButtons={navigatorButtons.leftButtons}
75
-                    rightButtons={navigatorButtons.rightButtons}
76
-                  />
77
-                </TabBarControllerIOS.Item>
78
-              );
79
-            })
80
-          }
81
-        </TabBarControllerIOS>
82
-      );
83
-    }
84
-  });
85
-  ControllerRegistry.registerController(controllerID, () => Controller);
86
-  ControllerRegistry.setRootController(controllerID, params.animationType, params.passProps || {});
87
-}
88
-
89
-function startSingleScreenApp(params) {
90
-  if (!params.screen) {
91
-    console.error('startSingleScreenApp(params): params.screen is required');
92
-    return;
93
-  }
94
-  const controllerID = utils.getRandomId();
95
-  const Controller = Controllers.createClass({
96
-    render: function() {
97
-      if (!params.drawer || (!params.drawer.left && !params.drawer.right)) {
98
-        return this.renderBody();
99
-      } else {
100
-        const navigatorID = controllerID + '_drawer';
101
-        return (
102
-          <DrawerControllerIOS id={navigatorID}
103
-                               componentLeft={params.drawer.left ? params.drawer.left.screen : undefined}
104
-                               passPropsLeft={{navigatorID: navigatorID}}
105
-                               componentRight={params.drawer.right ? params.drawer.right.screen : undefined}
106
-                               passPropsRight={{navigatorID: navigatorID}}
107
-                               disableOpenGesture={params.drawer.disableOpenGesture}>
108
-            {this.renderBody()}
109
-          </DrawerControllerIOS>
110
-        );
111
-      }
112
-    },
113
-    renderBody: function() {
114
-      const screen = params.screen;
115
-      const navigatorID = controllerID + '_nav';
116
-      const screenInstanceID = utils.getRandomId();
117
-      if (!screen.screen) {
118
-        console.error('startSingleScreenApp(params): screen must include a screen property');
119
-        return;
120
-      }
121
-      const {
122
-        navigatorStyle,
123
-        navigatorButtons,
124
-        navigatorEventID
125
-      } = _mergeScreenSpecificSettings(screen.screen, screenInstanceID, screen);
126
-      return (
127
-        <NavigationControllerIOS
128
-          id={navigatorID}
129
-          title={screen.title}
130
-          titleImage={screen.titleImage}
131
-          component={screen.screen}
132
-          passProps={{
133
-            navigatorID: navigatorID,
134
-            screenInstanceID: screenInstanceID,
135
-            navigatorEventID: navigatorEventID
136
-          }}
137
-          style={navigatorStyle}
138
-          leftButtons={navigatorButtons.leftButtons}
139
-          rightButtons={navigatorButtons.rightButtons}
140
-        />
141
-      );
142
-    }
143
-  });
144
-  ControllerRegistry.registerController(controllerID, () => Controller);
145
-  ControllerRegistry.setRootController(controllerID, params.animationType, params.passProps || {});
146
-}
147
-
148
-function _mergeScreenSpecificSettings(screenID, screenInstanceID, params) {
149
-  const screenClass = Navigation.getRegisteredScreen(screenID);
150
-  if (!screenClass) {
151
-    console.error('Cannot create screen ' + screenID + '. Are you it was registered with Navigation.registerScreen?');
152
-    return;
153
-  }
154
-  const navigatorStyle = Object.assign({}, screenClass.navigatorStyle);
155
-  if (params.navigatorStyle) {
156
-    Object.assign(navigatorStyle, params.navigatorStyle);
157
-  }
158
-
159
-  const navigatorEventID = screenInstanceID + '_events';
160
-  const navigatorButtons = Object.assign({}, screenClass.navigatorButtons);
161
-  if (params.navigatorButtons) {
162
-    Object.assign(navigatorButtons, params.navigatorButtons);
163
-  }
164
-  if (navigatorButtons.leftButtons) {
165
-    for (let i = 0; i < navigatorButtons.leftButtons.length; i++) {
166
-      navigatorButtons.leftButtons[i].onPress = navigatorEventID;
167
-    }
168
-  }
169
-  if (navigatorButtons.rightButtons) {
170
-    for (let i = 0; i < navigatorButtons.rightButtons.length; i++) {
171
-      navigatorButtons.rightButtons[i].onPress = navigatorEventID;
172
-    }
173
-  }
174
-  return {navigatorStyle, navigatorButtons, navigatorEventID};
175
-}
176
-
177
-function navigatorPush(navigator, params) {
178
-  if (!params.screen) {
179
-    console.error('Navigator.push(params): params.screen is required');
180
-    return;
181
-  }
182
-  const screenInstanceID = utils.getRandomId();
183
-  const {
184
-    navigatorStyle,
185
-    navigatorButtons,
186
-    navigatorEventID
187
-  } = _mergeScreenSpecificSettings(params.screen, screenInstanceID, params);
188
-  const passProps = Object.assign({}, params.passProps);
189
-  passProps.navigatorID = navigator.navigatorID;
190
-  passProps.screenInstanceID = screenInstanceID;
191
-  passProps.navigatorEventID = navigatorEventID;
192
-  Controllers.NavigationControllerIOS(navigator.navigatorID).push({
193
-    title: params.title,
194
-    titleImage: params.titleImage,
195
-    component: params.screen,
196
-    animated: params.animated,
197
-    passProps: passProps,
198
-    style: navigatorStyle,
199
-    backButtonTitle: params.backButtonTitle,
200
-    backButtonHidden: params.backButtonHidden,
201
-    leftButtons: navigatorButtons.leftButtons,
202
-    rightButtons: navigatorButtons.rightButtons
203
-  });
204
-}
205
-
206
-function navigatorPop(navigator, params) {
207
-  Controllers.NavigationControllerIOS(navigator.navigatorID).pop({
208
-    animated: params.animated
209
-  });
210
-}
211
-
212
-function navigatorPopToRoot(navigator, params) {
213
-  Controllers.NavigationControllerIOS(navigator.navigatorID).popToRoot({
214
-    animated: params.animated
215
-  });
216
-}
217
-
218
-function navigatorResetTo(navigator, params) {
219
-  if (!params.screen) {
220
-    console.error('Navigator.resetTo(params): params.screen is required');
221
-    return;
222
-  }
223
-  const screenInstanceID = utils.getRandomId();
224
-  const {
225
-    navigatorStyle,
226
-    navigatorButtons,
227
-    navigatorEventID
228
-  } = _mergeScreenSpecificSettings(params.screen, screenInstanceID, params);
229
-  const passProps = Object.assign({}, params.passProps);
230
-  passProps.navigatorID = navigator.navigatorID;
231
-  passProps.screenInstanceID = screenInstanceID;
232
-  passProps.navigatorEventID = navigatorEventID;
233
-  Controllers.NavigationControllerIOS(navigator.navigatorID).resetTo({
234
-    title: params.title,
235
-    titleImage: params.titleImage,
236
-    component: params.screen,
237
-    animated: params.animated,
238
-    passProps: passProps,
239
-    style: navigatorStyle,
240
-    leftButtons: navigatorButtons.leftButtons,
241
-    rightButtons: navigatorButtons.rightButtons
242
-  });
243
-}
244
-
245
-function navigatorSetTitle(navigator, params) {
246
-  Controllers.NavigationControllerIOS(navigator.navigatorID).setTitle({
247
-    title: params.title
248
-  });
249
-}
250
-
251
-function navigatorSetTitleImage(navigator, params) {
252
-  Controllers.NavigationControllerIOS(navigator.navigatorID).setTitleImage({
253
-    titleImage: params.titleImage
254
-  });
255
-}
256
-
257
-function navigatorToggleNavBar(navigator, params) {
258
-  Controllers.NavigationControllerIOS(navigator.navigatorID).setHidden({
259
-    hidden: ((params.to === 'hidden') ? true : false),
260
-    animated: params.animated
261
-  });
262
-}
263
-
264
-function navigatorToggleDrawer(navigator, params) {
265
-  const controllerID = navigator.navigatorID.split('_')[0];
266
-  if (params.to == 'open') {
267
-    Controllers.DrawerControllerIOS(controllerID + '_drawer').open({
268
-      side: params.side,
269
-      animated: params.animated
270
-    });
271
-  } else if (params.to == 'closed') {
272
-    Controllers.DrawerControllerIOS(controllerID + '_drawer').close({
273
-      side: params.side,
274
-      animated: params.animated
275
-    });
276
-  } else {
277
-    Controllers.DrawerControllerIOS(controllerID + '_drawer').toggle({
278
-      side: params.side,
279
-      animated: params.animated
280
-    });
281
-  }
282
-}
283
-
284
-function navigatorToggleTabs(navigator, params) {
285
-  const controllerID = navigator.navigatorID.split('_')[0];
286
-  Controllers.TabBarControllerIOS(controllerID + '_tabs').setHidden({
287
-    hidden: params.to == 'hidden',
288
-    animated: !(params.animated === false)
289
-  });
290
-}
291
-
292
-function navigatorSetTabBadge(navigator, params) {
293
-  const controllerID = navigator.navigatorID.split('_')[0];
294
-  if (params.tabIndex || params.tabIndex === 0) {
295
-    Controllers.TabBarControllerIOS(controllerID + '_tabs').setBadge({
296
-      tabIndex: params.tabIndex,
297
-      badge: params.badge
298
-    });
299
-  } else {
300
-    Controllers.TabBarControllerIOS(controllerID + '_tabs').setBadge({
301
-      contentId: navigator.navigatorID,
302
-      contentType: 'NavigationControllerIOS',
303
-      badge: params.badge
304
-    });
305
-  }
306
-}
307
-
308
-function navigatorSwitchToTab(navigator, params) {
309
-  const controllerID = navigator.navigatorID.split('_')[0];
310
-  if (params.tabIndex || params.tabIndex === 0) {
311
-    Controllers.TabBarControllerIOS(controllerID + '_tabs').switchTo({
312
-      tabIndex: params.tabIndex
313
-    });
314
-  } else {
315
-    Controllers.TabBarControllerIOS(controllerID + '_tabs').switchTo({
316
-      contentId: navigator.navigatorID,
317
-      contentType: 'NavigationControllerIOS'
318
-    });
319
-  }
320
-}
321
-
322
-function navigatorSetButtons(navigator, navigatorEventID, params) {
323
-  if (params.leftButtons) {
324
-    const buttons = params.leftButtons.slice(); // clone
325
-    for (let i = 0; i < buttons.length; i++) {
326
-      buttons[i].onPress = navigatorEventID;
327
-    }
328
-    Controllers.NavigationControllerIOS(navigator.navigatorID).setLeftButtons(buttons, params.animated);
329
-  }
330
-  if (params.rightButtons) {
331
-    const buttons = params.rightButtons.slice(); // clone
332
-    for (let i = 0; i < buttons.length; i++) {
333
-      buttons[i].onPress = navigatorEventID;
334
-    }
335
-    Controllers.NavigationControllerIOS(navigator.navigatorID).setRightButtons(buttons, params.animated);
336
-  }
337
-}
338
-
339
-function showModal(params) {
340
-  if (!params.screen) {
341
-    console.error('showModal(params): params.screen is required');
342
-    return;
343
-  }
344
-  const controllerID = utils.getRandomId();
345
-  const Controller = Controllers.createClass({
346
-    render: function() {
347
-      const navigatorID = controllerID + '_nav';
348
-      const screenInstanceID = utils.getRandomId();
349
-      const {
350
-        navigatorStyle,
351
-        navigatorButtons,
352
-        navigatorEventID
353
-      } = _mergeScreenSpecificSettings(params.screen, screenInstanceID, params);
354
-      const passProps = Object.assign({}, params.passProps);
355
-      passProps.navigatorID = navigatorID;
356
-      passProps.screenInstanceID = screenInstanceID;
357
-      passProps.navigatorEventID = navigatorEventID;
358
-      return (
359
-        <NavigationControllerIOS
360
-          id={navigatorID}
361
-          title={params.title}
362
-          titleImage={params.titleImage}
363
-          component={params.screen}
364
-          passProps={passProps}
365
-          style={navigatorStyle}
366
-          leftButtons={navigatorButtons.leftButtons}
367
-          rightButtons={navigatorButtons.rightButtons}/>
368
-      );
369
-    }
370
-  });
371
-  ControllerRegistry.registerController(controllerID, () => Controller);
372
-  Modal.showController(controllerID, params.animationType);
373
-}
374
-
375
-function dismissModal(params) {
376
-  Modal.dismissController(params.animationType);
377
-}
378
-
379
-function dismissAllModals(params) {
380
-  Modal.dismissAllControllers(params.animationType);
381
-}
382
-
383
-function showLightBox(params) {
384
-  if (!params.screen) {
385
-    console.error('showLightBox(params): params.screen is required');
386
-    return;
387
-  }
388
-  const controllerID = utils.getRandomId();
389
-  const navigatorID = controllerID + '_nav';
390
-  const screenInstanceID = utils.getRandomId();
391
-  const {
392
-    navigatorStyle,
393
-    navigatorButtons,
394
-    navigatorEventID
395
-  } = _mergeScreenSpecificSettings(params.screen, screenInstanceID, params);
396
-  const passProps = Object.assign({}, params.passProps);
397
-  passProps.navigatorID = navigatorID;
398
-  passProps.screenInstanceID = screenInstanceID;
399
-  passProps.navigatorEventID = navigatorEventID;
400
-  Modal.showLightBox({
401
-    component: params.screen,
402
-    passProps: passProps,
403
-    style: params.style
404
-  });
405
-}
406
-
407
-function dismissLightBox(params) {
408
-  Modal.dismissLightBox();
409
-}
410
-
411
-function showInAppNotification(params) {
412
-  if (!params.screen) {
413
-    console.error('showInAppNotification(params): params.screen is required');
414
-    return;
415
-  }
416
-
417
-  const controllerID = utils.getRandomId();
418
-  const navigatorID = controllerID + '_nav';
419
-  const screenInstanceID = utils.getRandomId();
420
-  const {
421
-    navigatorStyle,
422
-    navigatorButtons,
423
-    navigatorEventID
424
-  } = _mergeScreenSpecificSettings(params.screen, screenInstanceID, params);
425
-  const passProps = Object.assign({}, params.passProps);
426
-  passProps.navigatorID = navigatorID;
427
-  passProps.screenInstanceID = screenInstanceID;
428
-  passProps.navigatorEventID = navigatorEventID;
429
-
430
-  Notification.show({
431
-    component: params.screen,
432
-    passProps: passProps,
433
-    style: params.style,
434
-    animation: params.animation || Notification.AnimationPresets.default,
435
-    position: params.position,
436
-    shadowRadius: params.shadowRadius,
437
-    dismissWithSwipe: params.dismissWithSwipe || true,
438
-    autoDismissTimerSec: params.autoDismissTimerSec || 5
439
-  });
440
-}
441
-
442
-function dismissInAppNotification(params) {
443
-  Notification.dismiss(params);
444
-}
445
-
446
-export default {
447
-  startTabBasedApp,
448
-  startSingleScreenApp,
449
-  navigatorPush,
450
-  navigatorPop,
451
-  navigatorPopToRoot,
452
-  navigatorResetTo,
453
-  showModal,
454
-  dismissModal,
455
-  dismissAllModals,
456
-  showLightBox,
457
-  dismissLightBox,
458
-  showInAppNotification,
459
-  dismissInAppNotification,
460
-  navigatorSetButtons,
461
-  navigatorSetTitle,
462
-  navigatorSetTitleImage,
463
-  navigatorToggleDrawer,
464
-  navigatorToggleTabs,
465
-  navigatorSetTabBadge,
466
-  navigatorSwitchToTab,
467
-  navigatorToggleNavBar
468
-}
1
+module.exports = {};