简体   繁体   English

如何使用底部标签导航器实现全局访问屏幕

[英]How to implement global accesed screens with bottom tab navigator

I'm developing an application whose main navigation is composed by bottom tabs , this application has some screens which need to be globally accesed from different tabs/places.我正在开发一个应用程序,其主要导航由底部选项卡组成,该应用程序有一些屏幕需要从不同的选项卡/位置全局访问。 An important thing to highlight is that from this global screen I can go back to the place from which it was accessed(go back navigation action).需要强调的重要一点是,从这个全局屏幕我可以 go 回到访问它的地方(返回导航操作)。 Here a simple UI to ilustrate the use case:这里有一个简单的用户界面来说明用例:

在此处输入图像描述

It's not clear to me how the distribution of the navigators must be to be able to implement this navigation architecture.我不清楚导航器的分布必须如何才能实现这种导航架构。

what you can go is Nest bottom tabs navigator inside a stack navigator你能做什么 go 是Nest bottom tabs navigator inside a stack navigator

and put the global screens inside the stack navigator并将全局屏幕放在堆栈导航器中

something like this:是这样的:

function bottomTabNavigator() {
  return (
    <Tab.Navigator>
      <Tab.Screen name="Feed" component={Feed} />
      <Tab.Screen name="Messages" component={Messages} />
    </Tab.Navigator>
  );
}

function App() {
  return (
    
      <Stack.Navigator>
        <Stack.Screen
          name="Home"
          component={bottomTabNavigator}
          options={{ headerShown: false }}
        />
        <Stack.Screen name="GlobalScreen" component={GloballyAccessedScreen} />
      </Stack.Navigator>
    
  );
}

for the second part of your question, to go back you should use navigation.goBack();对于问题的第二部分,返回 go 应该使用navigation.goBack();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在底部选项卡导航器 react-navigation 中卸载非活动屏幕? - How to unmount inactive screens in bottom tab navigator react-navigation? 如何将底部选项卡导航器与抽屉导航器结合使用 - How to combine bottom tab navigator with drawer navigator 在底部选项卡导航器中卸载非活动屏幕(重置堆栈) - Unmount inactive screens (reset stacks) in bottom tab navigator 如何在反应导航 5 中的选项卡导航器中的选项卡屏幕之间移动? - How to move between tab screens in tab navigator in react navigation 5? 一个标签导航器中的多个屏幕 - Multiple screens in one Tab Navigator 如何在底部选项卡导航器中重新加载组件 - How to reload a component in a bottom tab navigator React Native 底部标签导航器 - React Native bottom tab navigator 如何将多个导航器相互嵌套? 即在抽屉导航器中嵌套底部选项卡并将抽屉导航器嵌套到堆栈导航器 - How to nest multiple navigator within each other? i.e. nesting bottom tab in drawer navigator and nesting drawer navigator to stack navigator 如何在底部选项卡导航器中删除顶部栏(主页) - How to remove top bar (Home) in Bottom Tab Navigator 如何获取底部选项卡导航器内的堆栈导航器的当前路由名称? - How to get the current route name of a Stack Navigator that is inside a Bottom Tab Navigator?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM