1
votes

modification de la couleur d'arrière-plan de la tabBar native de réaction

Je suis donc vraiment nouveau pour réagir aux développeurs natifs et mobiles, Je voulais changer la couleur d'arrière-plan d'une navigation dans la barre d'onglets inférieure et je n'arrive pas à comprendre comment le faire, depuis que j'ai commencé avec un projet natif de réaction avec navigation (option dans la phase d'initialisation de l'expo), la façon dont les choses sont écrites est différent de ce que j'ai vu sur le net, je sais que je dois ajouter

import React from 'react';
import { Platform } from 'react-native';
import { createStackNavigator } from 'react-navigation-stack';
import { createBottomTabNavigator } from 'react-navigation-tabs';

import TabBarIcon from '../components/TabBarIcon';
import HomeScreen from '../screens/HomeScreen';
import LinksScreen from '../screens/LinksScreen';
import SettingsScreen from '../screens/SettingsScreen';


const config = Platform.select({
  web: { headerMode: 'screen' },
  default: {},
});

const HomeStack = createStackNavigator(
  {
    Home: HomeScreen,
  },{
    defaultNavigationOptions: {
      headerTintColor: '#444',
      headerStyle: {
        backgroundColor: 'pink'
      }
    }
  },
  config
);

HomeStack.navigationOptions = {
  tabBarLabel: 'Home',
  tabBarIcon: ({ focused, tintColor }) => (
    <TabBarIcon
      focused={focused}
      name={
        Platform.OS === 'ios'
          ? `ios-information-circle${focused ? '' : '-outline'}`
          : 'md-information-circle'
      }
      color= {"#cd077dr"}
    />
  ), style: {
    backgroundColor: 'pink'
  }
};

HomeStack.path = '';

const LinksStack = createStackNavigator(
  {
    Links: LinksScreen,
  },{
    defaultNavigationOptions: {
      headerTintColor: '#444',
      headerStyle: {
        backgroundColor: 'pink'
      }
    }
  },
  config
);

LinksStack.navigationOptions = {
  tabBarLabel: 'Links',
  tabBarIcon: ({ focused }) => (
    <TabBarIcon focused={focused} name={Platform.OS === 'ios' ? 'ios-link' : 'md-link'} />
  )
};

LinksStack.path = '';

const SettingsStack = createStackNavigator(
  {
    Settings: SettingsScreen,
  },{
    defaultNavigationOptions: {
      headerTintColor: '#444',
      headerStyle: {
        backgroundColor: 'pink'
      },
      tabBarOptions: {
        style: { backgroundColor: 'orange'}
      }
    }
  },
  config
);

SettingsStack.navigationOptions = {
  tabBarLabel: 'Settings',
  tabBarIcon: ({ focused }) => (
    <TabBarIcon focused={focused} name={Platform.OS === 'ios' ? 'ios-options' : 'md-options'} />
  ),
};

SettingsStack.path = '';


const tabNavigator = createBottomTabNavigator({
  HomeStack,
  LinksStack,
  SettingsStack,
});

tabNavigator.path = '';

export default tabNavigator;

mais pour être honnête idk où exactement, si quelqu'un pouvait aider, ce serait très apprécié !! voici mon code:

      tabBarOptions: {
        style: { backgroundColor: 'orange'}
      }


0 commentaires

3 Réponses :


0
votes

@Zelda, veuillez consulter ce lien (problème de react-native-tab-view git-hub).

https://github.com/react -native-community / react-native-tab-view / issues / 152


0 commentaires

2
votes

Je pense que vous devriez modifier votre const tabNavigator en quelque chose comme

const tabNavigator = createBottomTabNavigator({
  HomeStack,
  LinksStack,
  SettingsStack,
}, {
    defaultNavigationOptions: {
      tabBarOptions: {
        style: { backgroundColor: 'orange'}
      }
    }
});


0 commentaires

0
votes

essayez de l'utiliser, cela fonctionne sur Android et iOS https://github.com/react-navigation/react- navigation / issues / 1270 # issuecomment-342757336

const tabBarOptions = {
// setting height 'null', and top 0 will change the color of pressed tab
indicatorStyle: {
 height: null,
 top: 0,
 backgroundColor: "red",
 borderBottomColor: "black",
 borderBottomWidth: 3,
},
activeTintColor: "black",
pressColor: "white",
style: {
 backgroundColor: "#ddc8be",
},
labelStyle: { fontSize: 13 },
};


0 commentaires