lazaronixon / react-native-turbolinks

React Native adapter for building hybrid apps with Turbolinks 5
MIT License
193 stars 18 forks source link

[Android] TabBar title and actions are not taken into account #4

Closed fcatuhe closed 6 years ago

fcatuhe commented 6 years ago

Hi @lazaronixon, thanks again for the great work on TabBar!

I have this issue only on Android with the following setting in componentDidMount():

Turbolinks.setTabBar({
  routes: [
    {
      tabTitle: 'Home',
      title: 'RNT Showcase',
      url: env.BASE_URL,
      actions: [{ id: 404, title: '404 error' }]
    },
    {
      tabTitle: 'Posts',
      title: 'View all posts',
      url: `${env.BASE_URL}/posts`,
      actions: [{ id: 11, title: 'New post' }]
    }
  ]
});

The title and actions on all Tabs are the ones of the first route only, they do not change when navigating to other tabs.

It works as expected on iOS.

I brought up a repo for my experiments ;-) available here: RNT Showcase

lazaronixon commented 6 years ago

Unfortunately this is the default behavior on android. On android we have a component called PagerView where it is possible slide between views so I used it to slide between TurbolinksViews and NativeViews but with only one Toolbar. By default react-native-turbolinks will use route from selectedIndex to mount this single toolbar. If possible see baseCamp App for android. You will see the same behavior.

lazaronixon commented 6 years ago

What could be done is implement a eventListener like turbolinksTabChanged with selectedIndex as return. So you could use on JavaScript side renderActions or renderTitle methods... But i think it would be a lot of code to you implement only for android to do such a simple thing. If I have more requests i can do that.

fcatuhe commented 6 years ago

OK thanks for the explanation, for the moment I will explore the possibilities with this configuration!