如何在屏幕上导入defaultNavigationOptions属性?

问题描述 投票:0回答:1

我正在尝试将react-navigation属性导入到我的屏幕中,问题是我总是为不同的Stack导入相同的defaultNavigationOptions然后优化我想要创建的代码作为一种函数,所以我只在每个上面导入一次屏幕,而不必像我一样写多次,然后我的代码,所以他们了解更多。

    const BloquesStack = createStackNavigator(
  {
    BLOQUES: {
      screen: ScreenBloquesRedux,
      navigationOptions: ({ navigation }) => {
        return {
          headerLeft: <ButtonMenu navigation={navigation} />,
          headerRight: <ButtonHome navigation={navigation} />
        };
      }
    },
    DetalleBloques: {
      screen: DetalleBloque
    },
    IntegrantesBloque: {
      screen: IntegrantesBloque
    }
  },
  {
    defaultNavigationOptions: {
      headerBackTitle: "Atras",
      headerTitleStyle: {
        fontFamily: "RobotoCondensed-Regular",
        fontWeight: "100",
        fontSize: 20,
        textAlign: "center",
        color: white,
        flex: 1
      },
      headerStyle: { backgroundColor: blue, height: 60 },
      headerTintColor: white
    }
  }
);
export { BloquesStack };

const ComisionesStack = createStackNavigator(
  {
    COMISIONES: {
      screen: ComisionesRedux,
      navigationOptions: ({ navigation }) => {
        return {
          headerLeft: <ButtonMenu navigation={navigation} />,
          headerRight: <ButtonHome navigation={navigation} />
        };
      }
    }
  },
  {
    defaultNavigationOptions: {
      headerBackTitle: "Atras",
      headerTitleStyle: {
        fontFamily: "RobotoCondensed-Regular",
        fontWeight: "100",
        fontSize: 20,
        textAlign: "center",
        color: white,
        flex: 1
      },
      headerStyle: { backgroundColor: blue, height: 60 },
      headerTintColor: white
    }
  }
export { ComisionesStack };

const DrawerNavigator = createDrawerNavigator(
  {
    Diputados: { screen: DiputadosStack },
    Bloques: { screen: BloquesStack },
    Interbloques: { screen: InterBloquesStack },
    Comisiones: { screen: ComisionesStack },
    Autoridades: { screen: AutoridadesStack },
    "Sesion En Vivo": { screen: SesionEnVivoStack },
    "Diputados TV": { screen: DiputadosTVStack },
    "Reglamentos HCDN": { screen: PDFReglamentosStack }
  },
  {
    contentComponent: CustomDrawerContentComponent,
    drawerWidth: width / 2,
    contentOptions: {
      activeTintColor: white,
      activeBackgroundColor: Gris_Drawer,
      inactiveTintColor: "rgb(105,105,104)",
      itemsContainerStyle: {
        textAlign: "center"
      },
      labelStyle: {
        fontFamily: "RobotoCondensed-Regular",
        fontWeight: "100",
        fontSize: 17,
        marginTop: 8,
        marginLeft: 10
      }
    },
    iconContainerStyle: {
      opacity: 1
    }
  }
);

我只想导入默认的导航选项我不打算修改我的导航,我只是想知道它是否可以完成。非常感谢你

react-native react-navigation
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.