react-native-navigation icon indicating copy to clipboard operation
react-native-navigation copied to clipboard

Custom topBar not working in combination with bottomTabs on iOS

Open francbelak opened this issue 7 years ago • 8 comments

Issue Description

In my app I have a centered stack where each component (view) should have a custom topBar and a sideMenu. Everything works fine with simple views (without bottomTabs). Views with bottomTabs are working on android but on iOS I am missing my custom topBar and rightButtons (rightButtons and component: TopMenu). They will not appear.

Steps to Reproduce / Code Snippets / Screenshots

see: reproducable and reduced use case in forked playground repo: forked playground with reproducable bug

Expected behavior:

  • push simple: should show component with topbar (centered icon and right button)
  • push complex: should show component with topbar (centered icon and right button) --> not working as expected

topBar

{
  buttonColor: PROJECT_COLOR['white-light'],
  backButton: {
    color: PROJECT_COLOR['white-light']
  },
  background: {
    color: PROJECT_COLOR['primary'],
  },
  title: {
    component: {
      name: 'TopMenu',
      alignment: 'center',
    },
  },
  rightButtons: [{
    id: menuConfig['TOP_BAR_BURGER_ID'],
    icon: require('../../assets/Burger.png')
  }]
};

root

{
 sideMenu: {
   id: 'sideMenu',
   right: {
     component: {
       id: menuConfig['SIDE_MENU_ID'],
       name: 'Menu'
     }
   },
   center: {
     stack: {
       id: 'AppRoot',
       children: [{
         component: {
           name: screen,
           passProps: passProps || {},
           options: {
             topBar: this.topBar,
             sideMenu: this.sideMenu
           }
         }
       }]
     }
   }
 }
}

bottomTabs

{
  options: {
    bottomTabs: {
      animate: true,
      backgroundColor: PROJECT_COLOR['white-ultradark'],
      titleDisplayMode: 'alwaysShow',
      currentTabIndex: 0
    }
  },
  children: [{
    component: {
      name: 'view 1',
      passProps: passProps,
      options: {
        topBar: this.topBar,
        sideMenu: this.sideMenu,
        bottomTab: {
          text: 'view 1',
          icon: require('../../assets/icon.png'),
          testID: 'VIEW_1_TAB_BAR_BUTTON',
          selectedIconColor: PROJECT_COLOR['primary'],
          selectedTextColor: PROJECT_COLOR['primary']
        }
      }
    }
  }, {
    component: {
      name: 'view 2',
      passProps: passProps,
      options: {
        topBar: this.topBar,
        sideMenu: this.sideMenu,
        bottomTab: {
          text: 'view 2',
          icon: require('../../assets/icon.png'),
          testID: 'VIEW_2_TAB_BAR_BUTTON',
          selectedIconColor: PROJECT_COLOR['primary'],
          selectedTextColor: PROJECT_COLOR['primary']
        }
      }
    }
  }, {
    component: {
      name: 'view 3',
      passProps: passProps,
      options: {
        topBar: this.topBar,
        sideMenu: this.sideMenu,
        bottomTab: {
          text: 'view 3',
          icon: require('../../assets/icon.png'),
          testID: 'VIEW_3_TAB_BAR_BUTTON',
          selectedIconColor: PROJECT_COLOR['primary'],
          selectedTextColor: PROJECT_COLOR['primary']
        }
      }
    }
  }]
}

bug


Environment

  • React Native Navigation version: ^2.27.9 & ^3.5.0
  • React Native version: 0.59.9
  • Platform(s) (iOS, Android, or both?): iOS
  • Device info (Simulator/Device? OS version? Debug/Release?): Simulator e.g. iphone 8 (13.1)

francbelak avatar Nov 06 '19 14:11 francbelak

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back. Thank you for your contributions.

stale[bot] avatar Dec 07 '19 16:12 stale[bot]

I am on React Native 0.61.3 and RNN 4.0.4 and this still happens.

davidmarinangeli avatar Dec 11 '19 14:12 davidmarinangeli

I'm having the same issue. react-native 0.61.5, RNN 4.0.9. TopBar will not appear on screens inside bottomTabs layout.

hbarylskyi avatar Dec 29 '19 17:12 hbarylskyi

I was able to get TopBar working after wrapping my tab screens inside stack layout:

const bottomTabs = {
  children: [
    {
      stack: {
        children: [{ component: { name: 'Explore', options: { topBar } } }],
        options: {
          bottomTab: {
            text: 'Explore',
            icon: Icon,
          },
        },
      },
    },
    {
      stack: {
        children: [{ component: { name: 'Search', options: { topBar } } }],
        options: {
          bottomTab: {
            text: 'Search',
            icon: Icon,
          },
        },
      },
    },
  ],
  options: {
  },
};

hbarylskyi avatar Dec 29 '19 18:12 hbarylskyi

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back. Thank you for your contributions.

stale[bot] avatar Jan 28 '20 18:01 stale[bot]

The issue has been closed for inactivity.

stale[bot] avatar Feb 04 '20 19:02 stale[bot]

This is still happening in current version 6.4.0 in combination with react-native 0.62.1

francbelak avatar Apr 07 '20 12:04 francbelak

Thanks @hbarylskyi for the hint with wrapping the components in stack. I reworked the top bar and got it to look like it should visually. Unfortunately I did not manage to get the back button working in the topbar. It seems like there is an issue with the fact that the bottomTabs screen is being opened inside an existing stack in my case. I also tried to use pop to see if i can go back but without success.

As a workaround I am displaying the bottomTabs screen in a modal window.

francbelak avatar May 04 '20 13:05 francbelak