|
@@ -1,6 +1,6 @@
|
1
|
1
|
import utils from './utils';
|
2
|
|
-import Navigation from './Navigation';
|
3
|
|
-import Controllers, { Modal, Notification } from 'react-native-controllers';
|
|
2
|
+import Navigation from './../Navigation';
|
|
3
|
+import Controllers, {Modal, Notification} from 'react-native-controllers';
|
4
|
4
|
const React = Controllers.hijackReact();
|
5
|
5
|
const {
|
6
|
6
|
ControllerRegistry,
|
|
@@ -23,13 +23,13 @@ function startTabBasedApp(params) {
|
23
|
23
|
const navigatorID = controllerID + '_drawer';
|
24
|
24
|
return (
|
25
|
25
|
<DrawerControllerIOS id={navigatorID}
|
26
|
|
- componentLeft={params.drawer.left ? params.drawer.left.screen : undefined}
|
27
|
|
- passPropsLeft={{navigatorID: navigatorID}}
|
28
|
|
- componentRight={params.drawer.right ? params.drawer.right.screen : undefined}
|
29
|
|
- passPropsRight={{navigatorID: navigatorID}}
|
30
|
|
- disableOpenGesture={params.drawer.disableOpenGesture}
|
31
|
|
- type={params.drawer.type ? params.drawer.type : undefined}
|
32
|
|
- animationType={params.drawer.animationType ? params.drawer.animationType : undefined}
|
|
26
|
+ componentLeft={params.drawer.left ? params.drawer.left.screen : undefined}
|
|
27
|
+ passPropsLeft={{navigatorID: navigatorID}}
|
|
28
|
+ componentRight={params.drawer.right ? params.drawer.right.screen : undefined}
|
|
29
|
+ passPropsRight={{navigatorID: navigatorID}}
|
|
30
|
+ disableOpenGesture={params.drawer.disableOpenGesture}
|
|
31
|
+ type={params.drawer.type ? params.drawer.type : undefined}
|
|
32
|
+ animationType={params.drawer.animationType ? params.drawer.animationType : undefined}
|
33
|
33
|
>
|
34
|
34
|
{this.renderBody()}
|
35
|
35
|
</DrawerControllerIOS>
|
|
@@ -42,38 +42,38 @@ function startTabBasedApp(params) {
|
42
|
42
|
id={controllerID + '_tabs'}
|
43
|
43
|
style={params.tabsStyle}>
|
44
|
44
|
{
|
45
|
|
- params.tabs.map(function(tab, index) {
|
46
|
|
- const navigatorID = controllerID + '_nav' + index;
|
47
|
|
- const screenInstanceID = utils.getRandomId();
|
48
|
|
- if (!tab.screen) {
|
49
|
|
- console.error('startTabBasedApp(params): every tab must include a screen property, take a look at tab#' + (index+1));
|
50
|
|
- return;
|
51
|
|
- }
|
52
|
|
- const {
|
53
|
|
- navigatorStyle,
|
54
|
|
- navigatorButtons,
|
55
|
|
- navigatorEventID
|
56
|
|
- } = _mergeScreenSpecificSettings(tab.screen, screenInstanceID, tab);
|
57
|
|
- return (
|
58
|
|
- <TabBarControllerIOS.Item {...tab} title={tab.label}>
|
59
|
|
- <NavigationControllerIOS
|
60
|
|
- id={navigatorID}
|
61
|
|
- title={tab.title}
|
62
|
|
- titleImage={tab.titleImage}
|
63
|
|
- component={tab.screen}
|
64
|
|
- passProps={{
|
|
45
|
+ params.tabs.map(function(tab, index) {
|
|
46
|
+ const navigatorID = controllerID + '_nav' + index;
|
|
47
|
+ const screenInstanceID = utils.getRandomId();
|
|
48
|
+ if (!tab.screen) {
|
|
49
|
+ console.error('startTabBasedApp(params): every tab must include a screen property, take a look at tab#' + (index + 1));
|
|
50
|
+ return;
|
|
51
|
+ }
|
|
52
|
+ const {
|
|
53
|
+ navigatorStyle,
|
|
54
|
+ navigatorButtons,
|
|
55
|
+ navigatorEventID
|
|
56
|
+ } = _mergeScreenSpecificSettings(tab.screen, screenInstanceID, tab);
|
|
57
|
+ return (
|
|
58
|
+ <TabBarControllerIOS.Item {...tab} title={tab.label}>
|
|
59
|
+ <NavigationControllerIOS
|
|
60
|
+ id={navigatorID}
|
|
61
|
+ title={tab.title}
|
|
62
|
+ titleImage={tab.titleImage}
|
|
63
|
+ component={tab.screen}
|
|
64
|
+ passProps={{
|
65
|
65
|
navigatorID: navigatorID,
|
66
|
66
|
screenInstanceID: screenInstanceID,
|
67
|
67
|
navigatorEventID: navigatorEventID
|
68
|
68
|
}}
|
69
|
|
- style={navigatorStyle}
|
70
|
|
- leftButtons={navigatorButtons.leftButtons}
|
71
|
|
- rightButtons={navigatorButtons.rightButtons}
|
72
|
|
- />
|
73
|
|
- </TabBarControllerIOS.Item>
|
74
|
|
- );
|
75
|
|
- })
|
76
|
|
- }
|
|
69
|
+ style={navigatorStyle}
|
|
70
|
+ leftButtons={navigatorButtons.leftButtons}
|
|
71
|
+ rightButtons={navigatorButtons.rightButtons}
|
|
72
|
+ />
|
|
73
|
+ </TabBarControllerIOS.Item>
|
|
74
|
+ );
|
|
75
|
+ })
|
|
76
|
+ }
|
77
|
77
|
</TabBarControllerIOS>
|
78
|
78
|
);
|
79
|
79
|
}
|
|
@@ -96,11 +96,11 @@ function startSingleScreenApp(params) {
|
96
|
96
|
const navigatorID = controllerID + '_drawer';
|
97
|
97
|
return (
|
98
|
98
|
<DrawerControllerIOS id={navigatorID}
|
99
|
|
- componentLeft={params.drawer.left ? params.drawer.left.screen : undefined}
|
100
|
|
- passPropsLeft={{navigatorID: navigatorID}}
|
101
|
|
- componentRight={params.drawer.right ? params.drawer.right.screen : undefined}
|
102
|
|
- passPropsRight={{navigatorID: navigatorID}}
|
103
|
|
- disableOpenGesture={params.drawer.disableOpenGesture}>
|
|
99
|
+ componentLeft={params.drawer.left ? params.drawer.left.screen : undefined}
|
|
100
|
+ passPropsLeft={{navigatorID: navigatorID}}
|
|
101
|
+ componentRight={params.drawer.right ? params.drawer.right.screen : undefined}
|
|
102
|
+ passPropsRight={{navigatorID: navigatorID}}
|
|
103
|
+ disableOpenGesture={params.drawer.disableOpenGesture}>
|
104
|
104
|
{this.renderBody()}
|
105
|
105
|
</DrawerControllerIOS>
|
106
|
106
|
);
|
|
@@ -158,16 +158,16 @@ function _mergeScreenSpecificSettings(screenID, screenInstanceID, params) {
|
158
|
158
|
Object.assign(navigatorButtons, params.navigatorButtons);
|
159
|
159
|
}
|
160
|
160
|
if (navigatorButtons.leftButtons) {
|
161
|
|
- for (let i = 0 ; i < navigatorButtons.leftButtons.length ; i++) {
|
|
161
|
+ for (let i = 0; i < navigatorButtons.leftButtons.length; i++) {
|
162
|
162
|
navigatorButtons.leftButtons[i].onPress = navigatorEventID;
|
163
|
163
|
}
|
164
|
164
|
}
|
165
|
165
|
if (navigatorButtons.rightButtons) {
|
166
|
|
- for (let i = 0 ; i < navigatorButtons.rightButtons.length ; i++) {
|
|
166
|
+ for (let i = 0; i < navigatorButtons.rightButtons.length; i++) {
|
167
|
167
|
navigatorButtons.rightButtons[i].onPress = navigatorEventID;
|
168
|
168
|
}
|
169
|
169
|
}
|
170
|
|
- return { navigatorStyle, navigatorButtons, navigatorEventID };
|
|
170
|
+ return {navigatorStyle, navigatorButtons, navigatorEventID};
|
171
|
171
|
}
|
172
|
172
|
|
173
|
173
|
function navigatorPush(navigator, params) {
|
|
@@ -318,14 +318,14 @@ function navigatorSwitchToTab(navigator, params) {
|
318
|
318
|
function navigatorSetButtons(navigator, navigatorEventID, params) {
|
319
|
319
|
if (params.leftButtons) {
|
320
|
320
|
const buttons = params.leftButtons.slice(); // clone
|
321
|
|
- for (let i = 0 ; i < buttons.length ; i++) {
|
|
321
|
+ for (let i = 0; i < buttons.length; i++) {
|
322
|
322
|
buttons[i].onPress = navigatorEventID;
|
323
|
323
|
}
|
324
|
324
|
Controllers.NavigationControllerIOS(navigator.navigatorID).setLeftButtons(buttons, params.animated);
|
325
|
325
|
}
|
326
|
326
|
if (params.rightButtons) {
|
327
|
327
|
const buttons = params.rightButtons.slice(); // clone
|
328
|
|
- for (let i = 0 ; i < buttons.length ; i++) {
|
|
328
|
+ for (let i = 0; i < buttons.length; i++) {
|
329
|
329
|
buttons[i].onPress = navigatorEventID;
|
330
|
330
|
}
|
331
|
331
|
Controllers.NavigationControllerIOS(navigator.navigatorID).setRightButtons(buttons, params.animated);
|