|
@@ -11,32 +11,45 @@ const resolveAssetSource = require('react-native/Libraries/Image/resolveAssetSou
|
11
|
11
|
import * as newPlatformSpecific from './../platformSpecific';
|
12
|
12
|
|
13
|
13
|
async function startSingleScreenApp(params) {
|
14
|
|
- const screen = params.screen;
|
15
|
|
- if (!screen.screen) {
|
|
14
|
+ const components = params.components;
|
|
15
|
+ if (!params.screen && !components) {
|
16
|
16
|
console.error('startSingleScreenApp(params): screen must include a screen property');
|
17
|
17
|
return;
|
18
|
18
|
}
|
|
19
|
+
|
|
20
|
+ if (components) {
|
|
21
|
+ params.screen = createSingleScreen(components[0]);
|
|
22
|
+ components.shift();
|
|
23
|
+ params.screen.screens = components.map(createSingleScreen);
|
|
24
|
+ } else {
|
|
25
|
+ params.screen = createSingleScreen(params.screen);
|
|
26
|
+ }
|
|
27
|
+
|
|
28
|
+ params.sideMenu = convertDrawerParamsToSideMenuParams(params.drawer);
|
|
29
|
+ params.overrideBackPress = params.screen.overrideBackPress;
|
|
30
|
+ params.animateShow = convertAnimationType(params.animationType);
|
|
31
|
+ params.appStyle = convertStyleParams(params.appStyle);
|
|
32
|
+ if (params.appStyle) {
|
|
33
|
+ params.appStyle.orientation = getOrientation(params);
|
|
34
|
+ }
|
|
35
|
+
|
|
36
|
+ return await newPlatformSpecific.startApp(params);
|
|
37
|
+}
|
|
38
|
+
|
|
39
|
+function createSingleScreen(params) {
|
|
40
|
+ let screen = params;
|
19
|
41
|
addNavigatorParams(screen);
|
20
|
42
|
addNavigatorButtons(screen, params.drawer);
|
21
|
43
|
addNavigationStyleParams(screen);
|
22
|
44
|
screen.passProps = params.passProps;
|
23
|
|
-
|
24
|
45
|
/*
|
25
|
46
|
* adapt to new API
|
26
|
47
|
*/
|
27
|
48
|
adaptTopTabs(screen, screen.navigatorID);
|
28
|
49
|
screen.screenId = screen.screen;
|
29
|
|
- params.screen = adaptNavigationStyleToScreenStyle(screen);
|
30
|
|
- params.screen = adaptNavigationParams(screen);
|
31
|
|
- params.appStyle = convertStyleParams(params.appStyle);
|
32
|
|
- if (params.appStyle) {
|
33
|
|
- params.appStyle.orientation = getOrientation(params);
|
34
|
|
- }
|
35
|
|
- params.sideMenu = convertDrawerParamsToSideMenuParams(params.drawer);
|
36
|
|
- params.overrideBackPress = screen.overrideBackPress;
|
37
|
|
- params.animateShow = convertAnimationType(params.animationType);
|
38
|
|
-
|
39
|
|
- return await newPlatformSpecific.startApp(params);
|
|
50
|
+ screen = adaptNavigationStyleToScreenStyle(screen);
|
|
51
|
+ screen = adaptNavigationParams(screen);
|
|
52
|
+ return screen;
|
40
|
53
|
}
|
41
|
54
|
|
42
|
55
|
function getOrientation(params) {
|
|
@@ -297,23 +310,18 @@ async function startTabBasedApp(params) {
|
297
|
310
|
params.tabs = _.cloneDeep(params.tabs);
|
298
|
311
|
|
299
|
312
|
params.tabs.forEach(function(tab, idx) {
|
300
|
|
- addNavigatorParams(tab, null, idx);
|
301
|
|
- addNavigatorButtons(tab, params.drawer);
|
302
|
|
- addNavigationStyleParams(tab);
|
303
|
|
- addTabIcon(tab);
|
304
|
|
- if (!tab.passProps) {
|
305
|
|
- tab.passProps = params.passProps;
|
|
313
|
+ if (tab.components) {
|
|
314
|
+ const components = tab.components;
|
|
315
|
+ const screen = createBottomTabScreen(components[0], idx, params)
|
|
316
|
+ const {label, icon} = components[0];
|
|
317
|
+ components.shift();
|
|
318
|
+ console.log('guyca', `${JSON.stringify(components[0])}`);
|
|
319
|
+ screen.screens = components.map(c => createBottomTabScreen({...c, icon, label}, idx, params));
|
|
320
|
+
|
|
321
|
+ newTabs.push(screen);
|
|
322
|
+ } else {
|
|
323
|
+ newTabs.push(createBottomTabScreen(tab, idx, params));
|
306
|
324
|
}
|
307
|
|
-
|
308
|
|
- adaptTopTabs(tab, tab.navigatorID);
|
309
|
|
-
|
310
|
|
- tab.screenId = tab.screen;
|
311
|
|
-
|
312
|
|
- let newtab = adaptNavigationStyleToScreenStyle(tab);
|
313
|
|
- newtab = adaptNavigationParams(tab);
|
314
|
|
- newtab.overrideBackPress = tab.overrideBackPress;
|
315
|
|
- newtab.timestamp = Date.now();
|
316
|
|
- newTabs.push(newtab);
|
317
|
325
|
});
|
318
|
326
|
params.tabs = newTabs;
|
319
|
327
|
|
|
@@ -327,6 +335,26 @@ async function startTabBasedApp(params) {
|
327
|
335
|
return await newPlatformSpecific.startApp(params);
|
328
|
336
|
}
|
329
|
337
|
|
|
338
|
+function createBottomTabScreen(tab, idx, params) {
|
|
339
|
+ addNavigatorParams(tab, null, idx);
|
|
340
|
+ addNavigatorButtons(tab, params.drawer);
|
|
341
|
+ addNavigationStyleParams(tab);
|
|
342
|
+ addTabIcon(tab);
|
|
343
|
+ if (!tab.passProps) {
|
|
344
|
+ tab.passProps = params.passProps;
|
|
345
|
+ }
|
|
346
|
+
|
|
347
|
+ adaptTopTabs(tab, tab.navigatorID);
|
|
348
|
+
|
|
349
|
+ tab.screenId = tab.screen;
|
|
350
|
+
|
|
351
|
+ let newtab = adaptNavigationStyleToScreenStyle(tab);
|
|
352
|
+ newtab = adaptNavigationParams(tab);
|
|
353
|
+ newtab.overrideBackPress = tab.overrideBackPress;
|
|
354
|
+ newtab.timestamp = Date.now();
|
|
355
|
+ return newtab;
|
|
356
|
+};
|
|
357
|
+
|
330
|
358
|
function addTabIcon(tab) {
|
331
|
359
|
if (tab.icon) {
|
332
|
360
|
const icon = resolveAssetSource(tab.icon);
|
|
@@ -553,7 +581,6 @@ function addNavigatorParams(screen, navigator = null, idx = '') {
|
553
|
581
|
}
|
554
|
582
|
|
555
|
583
|
function addNavigatorButtons(screen, sideMenuParams) {
|
556
|
|
-
|
557
|
584
|
const Screen = Navigation.getRegisteredScreen(screen.screen);
|
558
|
585
|
if (screen.navigatorButtons == null) {
|
559
|
586
|
screen.navigatorButtons = _.cloneDeep(Screen.navigatorButtons);
|