|
@@ -22,19 +22,30 @@ function startTabBasedApp(params) {
|
22
|
22
|
{
|
23
|
23
|
params.tabs.map(function(tab, index) {
|
24
|
24
|
const navigatorID = controllerID + '_nav' + index;
|
|
25
|
+ const screenInstanceID = utils.getRandomId();
|
25
|
26
|
if (!tab.screen) {
|
26
|
27
|
console.error('startTabBasedApp(params): every tab must include a screen property, take a look at tab#' + (index+1));
|
27
|
28
|
return;
|
28
|
29
|
}
|
29
|
|
- const { navigatorStyle } = _mergeScreenSpecificSettings(tab.screen, tab);
|
|
30
|
+ const {
|
|
31
|
+ navigatorStyle,
|
|
32
|
+ navigatorButtons,
|
|
33
|
+ navigatorEventID
|
|
34
|
+ } = _mergeScreenSpecificSettings(tab.screen, screenInstanceID, tab);
|
30
|
35
|
return (
|
31
|
36
|
<TabBarControllerIOS.Item {...tab} title={tab.label}>
|
32
|
37
|
<NavigationControllerIOS
|
33
|
38
|
id={navigatorID}
|
34
|
39
|
title={tab.title}
|
35
|
40
|
component={tab.screen}
|
36
|
|
- passProps={{navigatorID: navigatorID}}
|
|
41
|
+ passProps={{
|
|
42
|
+ navigatorID: navigatorID,
|
|
43
|
+ screenInstanceID: screenInstanceID,
|
|
44
|
+ navigatorEventID: navigatorEventID
|
|
45
|
+ }}
|
37
|
46
|
style={navigatorStyle}
|
|
47
|
+ leftButtons={navigatorButtons.leftButtons}
|
|
48
|
+ rightButtons={navigatorButtons.rightButtons}
|
38
|
49
|
/>
|
39
|
50
|
</TabBarControllerIOS.Item>
|
40
|
51
|
);
|
|
@@ -58,18 +69,29 @@ function startSingleScreenApp(params) {
|
58
|
69
|
render: function() {
|
59
|
70
|
const screen = params.screen;
|
60
|
71
|
const navigatorID = controllerID + '_nav';
|
|
72
|
+ const screenInstanceID = utils.getRandomId();
|
61
|
73
|
if (!screen.screen) {
|
62
|
74
|
console.error('startSingleScreenApp(params): screen must include a screen property');
|
63
|
75
|
return;
|
64
|
76
|
}
|
65
|
|
- const { navigatorStyle } = _mergeScreenSpecificSettings(screen.screen, screen);
|
|
77
|
+ const {
|
|
78
|
+ navigatorStyle,
|
|
79
|
+ navigatorButtons,
|
|
80
|
+ navigatorEventID
|
|
81
|
+ } = _mergeScreenSpecificSettings(screen.screen, screenInstanceID, screen);
|
66
|
82
|
return (
|
67
|
83
|
<NavigationControllerIOS
|
68
|
84
|
id={navigatorID}
|
69
|
85
|
title={screen.title}
|
70
|
86
|
component={screen.screen}
|
71
|
|
- passProps={{navigatorID: navigatorID}}
|
|
87
|
+ passProps={{
|
|
88
|
+ navigatorID: navigatorID,
|
|
89
|
+ screenInstanceID: screenInstanceID,
|
|
90
|
+ navigatorEventID: navigatorEventID
|
|
91
|
+ }}
|
72
|
92
|
style={navigatorStyle}
|
|
93
|
+ leftButtons={navigatorButtons.leftButtons}
|
|
94
|
+ rightButtons={navigatorButtons.rightButtons}
|
73
|
95
|
/>
|
74
|
96
|
);
|
75
|
97
|
}
|
|
@@ -78,7 +100,7 @@ function startSingleScreenApp(params) {
|
78
|
100
|
ControllerRegistry.setRootController(controllerID);
|
79
|
101
|
}
|
80
|
102
|
|
81
|
|
-function _mergeScreenSpecificSettings(screenID, params) {
|
|
103
|
+function _mergeScreenSpecificSettings(screenID, screenInstanceID, params) {
|
82
|
104
|
const screenClass = Navigation.getRegisteredScreen(screenID);
|
83
|
105
|
if (!screenClass) {
|
84
|
106
|
console.error('Cannot create screen ' + screenID + '. Are you it was registered with Navigation.registerScreen?');
|
|
@@ -88,7 +110,22 @@ function _mergeScreenSpecificSettings(screenID, params) {
|
88
|
110
|
if (params.navigatorStyle) {
|
89
|
111
|
Object.assign(navigatorStyle, params.navigatorStyle);
|
90
|
112
|
}
|
91
|
|
- return { navigatorStyle };
|
|
113
|
+ let navigatorEventID;
|
|
114
|
+ const navigatorButtons = Object.assign({}, screenClass.navigatorButtons);
|
|
115
|
+ if (navigatorButtons.leftButtons) {
|
|
116
|
+ for (let i = 0 ; i < navigatorButtons.leftButtons.length ; i++) {
|
|
117
|
+ navigatorEventID = screenInstanceID + '_events';
|
|
118
|
+ navigatorButtons.leftButtons[i].onPress = navigatorEventID;
|
|
119
|
+ }
|
|
120
|
+ }
|
|
121
|
+ if (navigatorButtons.rightButtons) {
|
|
122
|
+ navigatorEventID = screenInstanceID + '_events';
|
|
123
|
+ for (let i = 0 ; i < navigatorButtons.rightButtons.length ; i++) {
|
|
124
|
+ navigatorEventID = screenInstanceID + '_events';
|
|
125
|
+ navigatorButtons.rightButtons[i].onPress = navigatorEventID;
|
|
126
|
+ }
|
|
127
|
+ }
|
|
128
|
+ return { navigatorStyle, navigatorButtons, navigatorEventID };
|
92
|
129
|
}
|
93
|
130
|
|
94
|
131
|
function navigatorPush(navigator, params) {
|
|
@@ -96,16 +133,25 @@ function navigatorPush(navigator, params) {
|
96
|
133
|
console.error('Navigator.push(params): params.screen is required');
|
97
|
134
|
return;
|
98
|
135
|
}
|
99
|
|
- const { navigatorStyle } = _mergeScreenSpecificSettings(params.screen, params);
|
100
|
|
- const passProps = params.passProps || {};
|
|
136
|
+ const screenInstanceID = utils.getRandomId();
|
|
137
|
+ const {
|
|
138
|
+ navigatorStyle,
|
|
139
|
+ navigatorButtons,
|
|
140
|
+ navigatorEventID
|
|
141
|
+ } = _mergeScreenSpecificSettings(params.screen, screenInstanceID, params);
|
|
142
|
+ const passProps = Object.assign({}, params.passProps);
|
101
|
143
|
passProps.navigatorID = navigator.navigatorID;
|
|
144
|
+ passProps.screenInstanceID = screenInstanceID;
|
|
145
|
+ passProps.navigatorEventID = navigatorEventID;
|
102
|
146
|
Controllers.NavigationControllerIOS(navigator.navigatorID).push({
|
103
|
147
|
title: params.title,
|
104
|
148
|
component: params.screen,
|
105
|
149
|
animated: params.animated,
|
106
|
150
|
passProps: passProps,
|
107
|
151
|
style: navigatorStyle,
|
108
|
|
- backButtonTitle: params.backButtonTitle
|
|
152
|
+ backButtonTitle: params.backButtonTitle,
|
|
153
|
+ leftButtons: navigatorButtons.leftButtons,
|
|
154
|
+ rightButtons: navigatorButtons.rightButtons
|
109
|
155
|
});
|
110
|
156
|
}
|
111
|
157
|
|