zoukankan      html  css  js  c++  java
  • react-native 5.0导航栏配置

    安装的依赖和导入模块参考官网 https://reactnavigation.org/docs/nesting-navigators/#navigating-to-a-screen-in-a-nested-navigator

    页面跳转用的是 https://reactnavigation.org/docs/navigation-actions

    页面跳转

    import { CommonActions } from '@react-navigation/native'; navigation.dispatch( CommonActions.navigate({ name: 'Profile', params: { user: 'jane', }, }) );

      

    页面的层级关系:

    <NavigationContainer>
    
      <Stack.Navigator>
    
        <Stack.Screen
          name=" "
          component={HomeContainerPage}
          options={{
          headerTransparent: true,
        }}/>
        <Stack.Screen name="CheckInPage" component={CheckInPage} />     ...更多页面   </Stack.Navigator> </NavigationContainer>

    从index.js进入 主组件

    主组件中返回的是如下这个

    render (){
      return (

        

    <NavigationContainer>
            <Stack.Navigator>
              <Stack.Screen
                name=" "
                component={HomeContainerPage}
                options={{
                  headerTransparent: true,
                }}/>
                <Stack.Screen name="CheckInPage" component={CheckInPage} />
            ...省略很多页面
    Stack.Screen
    </Stack.Navigator> </NavigationContainer>

      )

    }
    HomeContainerPage组件中配置的是底部切换tab
    return (
        <Tab.Navigator
          initialRouteName="HomePage"
          activeColor='red'
          inactiveColor='black'
          labelStyle={{ fontSize: 12 }}
          barStyle={{ backgroundColor: 'white' }}
    
        >
          <Tab.Screen
            name="HomePage"
            component={HomePage}
            options={{
              tabBarLabel: '首页',
              tabBarIcon: (({tintColor,focused})=>{
                return (
                      <View>
                        <Image
                          source={focused?require('../img/bottomtabbar/ico.home.active.png'):require('../img/bottomtabbar/ico.home.png')}
                          style={{24,height: 23}}
                        />
                      </View>
                  )
              }),
            }}
          />
          <Tab.Screen
            name="ActivityPage"
            component={ActivityPage}
            options={{
              tabBarLabel: '活动',
              tabBarIcon: (({tintColor,focused})=>{
                return (
                      <View>
                        <Image
                          source={focused?require('../img/bottomtabbar/ico.activity.active.png'):require('../img/bottomtabbar/ico.activity.png')}
                          style={{24,height: 23}}
                        />
                      </View>
                  )
              }),
            }}
          />
          <Tab.Screen
            name="RemindPage"
            component={RemindPage}
            options={{
              tabBarLabel: '经营提醒',
              tabBarIcon: (({tintColor,focused})=>{
                return (
                      <View>
                        <Image
                          source={focused?require('../img/bottomtabbar/ico.reminder.active.png'):require('../img/bottomtabbar/ico.reminder.png')}
                          style={{24,height: 23}}
                        />
                      </View>
                  )
              }),
            }}
          />
          <Tab.Screen
            name="MyPage"
            component={MyPage}
            options={{
              tabBarLabel: '我的',
              tabBarIcon: (({tintColor,focused})=>{
                return (
                      <View>
                        <Image
                          source={focused?require('../img/bottomtabbar/ico.personal.active.png'):require('../img/bottomtabbar/ico.personal.png')}
                          style={{24,height: 23}}
                        />
                      </View>
                  )
              }),
            }}
          />
    
        </Tab.Navigator>
      );
    HomePage 组件中定义了顶部切换tab
    return (
          <Tab.Navigator
            tabBarOptions={{
              labelStyle: { fontSize: 18 },
              tabStyle:styles.tabStyle,
              upperCaseLabel:false,//是否使标签大写
              scrollEnabled:true,
              style:{
                backgroundColor:'white',//clear
                zIndex:999,
                position:'absolute',
                375,
                marginTop:30
              },//设置整个TabBar的样式
              indicatorStyle:styles.noiconindicatorStyle,
              showIcon:true,
              pressOpacity:1,
    
    
            }}
    
          >
            <Tab.Screen name="精选" component={FlatListDemo} />
    
          </Tab.Navigator>
      );

     其余页面配置在这里

    <Stack.Screen name="CheckInPage" component={CheckInPage} />
            ...省略很多页面Stack.Screen
     
     
    此文仅为鄙人学习笔记之用,朋友你来了,如有不明白或者建议又或者想给我指点一二,请私信我。liuw_flexi@163.com/QQ群:582039935. 我的gitHub: (学习代码都在gitHub) https://github.com/nwgdegitHub/
  • 相关阅读:
    selenium 模拟键盘事件 复制粘贴、右键、回车等
    02安卓用户界面优化之(二)SlidingMenu使用方法
    02Android用户界面优化之(一)Android Fragment
    (九)Android权限系统
    Android SDK 在线更新镜像服务器资源
    (八)Android广播接收器BroadcastReceiver
    (七)Android中AIDL的应用与理解
    (六)Android中Service通信
    (五)认识Android中的Service
    Gradle中文乱码
  • 原文地址:https://www.cnblogs.com/liuw-flexi/p/12447719.html
Copyright © 2011-2022 走看看