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

work with react-navigation #2

Open
esthor opened this issue May 31, 2019 · 6 comments
Open

work with react-navigation #2

esthor opened this issue May 31, 2019 · 6 comments

Comments

@esthor
Copy link

esthor commented May 31, 2019

Hi. I think this animation is amazing! Any chance you could post an example with it being used with react-navigation?

@ebrahimhassan121
Copy link

try this
const BottomContainer = createAppContainer(
createBottomTabNavigator(
{
Main: {
screen: MyDrawerNavigator,
navigationOptions: {
header: null
}
}
},
{ initialRouteName: "Main", tabBarComponent: Tabs }
)
);

@VictorLi08
Copy link

VictorLi08 commented Oct 10, 2019

  1. Create a tab navigator and supply a custom component to tabBarComponent.
const myTabNavigator = createBottomTabNavigator(
  {  // RouteConfigs
    Tab1: { screen: Tab1Screen },
    Tab2: { screen: Tab2Screen },
  },
  {
    initialRouteName: 'Tab1',
    tabBarComponent: FluidTabBar,
  }
);
  1. Define your custom component to render TabBar with the values you want. The tab navigator will pass navigation and onTabPress props to your component (along with many others that are irrelevant for this use case); use these to implement the onPress callback to navigate to the appropriate route:
class FluidTabBar extends Component {
  render() {
    return (
      <TabBar
        onPress={(tabIndex) => {
          let route = this.props.navigation.state.routes[tabIndex];
          this.props.onTabPress({route});
        }}
        values={[  // tabs
          {
            title: 'Tab 1',
            icon: require('assets/icon.png')
          }, {
            title: 'Tab 2',
            icon: require('assets/icon.png')
          }
        ]}
      />
    );
  }
}

In this case, pressing a tab in FluidTabBar navigates to a route in RouteConfigs that shares the same array index.

  1. Create an app container from your tab navigator and use it as your top-level component.
const myAppContainer = createAppContainer(myTabNavigator)

@pulpdood
Copy link

pulpdood commented Oct 11, 2019

I've forked the code to make it work with react navigation here: https://github.com/pulpdood/FluidBottomNavigation-rn

Make sure you pass props into the component for it to work i.e

tabBarComponent: (props) => <TabBar {...props} />

@BuiChiBach
Copy link

BuiChiBach commented Oct 18, 2019

@pulpdood , What a wonderful, but when I click back button on Andorid, they are like this
image,
first , it's active at Menu button, then i click back button on Andorid, the active status return Home button, and then , it's like below
Can't you fix it :( , thanks !

@pulpdood
Copy link

@BuiChiBach Thanks, I've updated the code and I seemed to have fixed it!

Also can I ask how did you make the shadow above the tab bar? I've tried box shadow, elevation etc. but it's not working :(. Thanks!

@BuiChiBach
Copy link

BuiChiBach commented Oct 20, 2019 via email

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

5 participants