瀏覽代碼

Fix issues with starting app with deep stack

* add back button to screens pushed to stack
* resolve tab icon from root screen, instead of first pushed screen
* omit components object from tabs
Guy Carmeli 6 年之前
父節點
當前提交
1a89256200
共有 1 個文件被更改,包括 7 次插入4 次删除
  1. 7
    4
      src/deprecated/platformSpecificDeprecated.android.js

+ 7
- 4
src/deprecated/platformSpecificDeprecated.android.js 查看文件

@@ -20,7 +20,8 @@ async function startSingleScreenApp(params) {
20 20
   if (components) {
21 21
     params.screen = createSingleScreen(components[0]);
22 22
     components.shift();
23
-    params.screen.screens = components.map(createSingleScreen);
23
+    params.screen.screens = components.map(createSingleScreen) || [];
24
+    params.screen.screens.map((c, i) => i === 0 ? c : addTitleBarBackButtonIfNeeded(c));
24 25
   } else {
25 26
     params.screen = createSingleScreen({...params.screen, passProps: params.passProps});
26 27
   }
@@ -314,10 +315,12 @@ async function startTabBasedApp(params) {
314 315
   params.tabs.forEach(function(tab, idx) {
315 316
     if (tab.components) {
316 317
       const components = tab.components;
317
-      const screen = createBottomTabScreen(components[0], idx, params)
318
-      const {label, icon} = components[0];
319
-      components.shift();
318
+      const screen = createBottomTabScreen(tab, idx, params)
319
+      const {label, icon} = screen;
320 320
       screen.screens = components.map(c => createBottomTabScreen({...c, icon, label}, idx, params));
321
+      screen.screens.map((s, i) => addTitleBarBackButtonIfNeeded(s));
322
+      screen.screens.map((s, i) => s.navigationParams.navigatorID = screen.navigationParams.navigatorID);
323
+      screen = _.omit(screen, ['components']);
321 324
       newTabs.push(screen);
322 325
     } else {
323 326
       newTabs.push(createBottomTabScreen(tab, idx, params));