单一布局到选项卡布局可响应本机导航

时间:2020-09-26 09:14:54

标签: react-native react-native-navigation wix-react-native-navigation

App navigation pattern

我正在尝试使用React Native Navigation来实现上述导航模式,并且使它正常工作,但是当尝试从状态C返回到状态B时,后退按钮似乎无法正常工作。

状态A是应用程序根目录,然后当用户要从状态A导航到状态B时,我将推送底部的选项卡布局。每个选项卡项均包含其自己的堆栈,并且当用户希望导航至状态CI时,我推送状态C屏幕。到目前为止,它工作正常,但是现在按下后退按钮(iOS和Android中都为Android硬件后退或顶部栏后退按钮)时,React Native Navigation显示状态A而不是状态B。

如何解决此问题?到目前为止,请参见以下代码。

Navigation.events().registerAppLaunchedListener(async () => { 
  Navigation.setRoot({
    root: {
      stack: {
        children: [
          {
            component: {
              name: 'app.home' // State A
            }
          }
        ]
      }
    }
  });
});

//when user want to navigate from State A to State B

  Navigation.push(componentId, {
    bottomTabs: {
      children: [
        {
          stack: {
            children: [
              {
                component: {
                  name: 'app.overview'
                }
              }
            ]
          }
        },
        {
          stack: {
            children: [
              {
                component: {
                  name: 'secure.profile'
                }
              }
            ]
          }
        }
      ]
    }
  });

// when user want to navigate from State B to State C

  Navigation.push(componentId, {
    component: {
      name: 'app.overview.details',
      passProps: {
        data: {
          ...props
        }
      }
    }
  });

0 个答案:

没有答案
相关问题