Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tab bar styling #2313

Closed
tomexa opened this issue Aug 31, 2017 · 4 comments
Closed

Tab bar styling #2313

tomexa opened this issue Aug 31, 2017 · 4 comments

Comments

@tomexa
Copy link

tomexa commented Aug 31, 2017

Version

Tell us which versions you are using:

  • react-native-router-flux v4.0.0-beta.21
  • react-native v0.45.1

Problem

I recently migrated from v3 and I have a hard time styling my main tab bar.
I have two goals:

  1. Change the color of the top border of the tab bar:
    I've tried the tabBarStyle prop, but it doesn't seem to work anymore and I didn't find a specific prop for that in your documentation.

  2. Change the icon color of my active tab:
    With v3 I used the 'icon' prop of the nested scenes and computed the icon based on the title and the selected boolean:

const TabIcon = ({ selected, title }) => {
  switch (title) {
    case 'dash':
      return (
        <Ionicons name={selected ? 'ios-speedometer' : 'ios-speedometer-outline'} size={30} color={selected ? Colors.themeColor : Colors.label} />
      )
    case 'mess':
      return (
        <Ionicons name={selected ? 'ios-mail' : 'ios-mail-outline'} size={30} color={selected ? Colors.themeColor : Colors.label} />
      )
    case 'params':
      return (
        <Ionicons name={selected ? 'ios-settings' : 'ios-settings-outline'} size={30} color={selected ? Colors.themeColor : Colors.label} />
      )
  }
}

But now, the selected boolean is always undefined...
I thought that it was the role of activeTintColor now, so I removed the color prop of my icons and set the activeTintColor prop to the desired value, without success...

Do you have any idea?
Thanks!

Scene:

<Tabs key='tabbar' tabs showLabel={false} activeTintColor={Colors.themeColor} inactiveTintColor={Colors.label} tabBarPosition='bottom' activeBackgroundColor='#111' inactiveBackgroundColor='#111'>
  <Scene key='dashtab' initial title='dash' icon={TabIcon}>

capture d ecran 2017-08-31 a 18 14 24

@mcabs3
Copy link
Collaborator

mcabs3 commented Aug 31, 2017

For #2, the attribute selected changed to focused

@mcabs3
Copy link
Collaborator

mcabs3 commented Aug 31, 2017

I looked into your first issue, you should be able to use tabBarStyle to do your top border, maybe try adjusting padding or margin?

I will update the docs for these props.

@aksonov
Copy link
Owner

aksonov commented Sep 2, 2017

Docs are updated, thanks to @mcabs3

@aksonov aksonov closed this as completed Sep 2, 2017
@ArcadeRenegade
Copy link

ArcadeRenegade commented Sep 24, 2017

@aksonov i couldn't find it in the docs. i was at a loss of why selected prop wasn't working until i found this thread

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants