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

Double Line in Navigation Bar for nested StackedNavigation and Title does not center in 4.0.0 #2080

Closed
abhaychitnis opened this issue Jul 20, 2017 · 9 comments

Comments

@abhaychitnis
Copy link

My Router.js code is as follows:

  import React from 'react';
  import { Scene, Router, Modal } from 'react-native-router-flux';
  import JobList from './components/JobList';
  import JobList2 from './components/JobList2';
  import EntryForm from './components/EntryForm';
  import TopDashboard from './components/TopDashboard';

  const RouterComponent = () => {
    return (
      <Router>
        <Scene
          key="modal"
          component={Modal}
          hideNavBar
        >
          <Scene key="auth">
            <Scene
              key="login"
              component={EntryForm}
              hideNavBar
            />
          </Scene>
          <Scene key="main" >
            <Scene
              key="topdashboard"
              component={TopDashboard}
              title="Dashboard"
              navigationBarStyle={styles.navBar}
              titleStyle={styles.titleStyle}
              initial
            />
            <Scene key="tabMain" tabs tabBarPosition="bottom">
             <Scene
                key="OpenJobs"
                component={JobList}
                title="Open Jobs"
                navigationBarStyle={styles.navBar}
                titleStyle={styles.titleStyle}
                hideTabBar={false}
              />
              <Scene
                key="AllJobs"
                component={JobList2}
                title="All Jobs"
                navigationBarStyle={styles.navBar}
                titleStyle={styles.titleStyle}
                hideTabBar={false}
              />
          </Scene>
        </Scene>
        </Scene>
      </Router>
    );
  };


  const styles = {
    navBar: {
      backgroundColor: '#01a1d3' // changing navbar color
    },
    titleStyle: {
      color: 'white', // changing navbar title color
      fontWeight: 'bold'
    }
  };

  export default RouterComponent;

I having two problems in Screen tabMain

  1. There are two lines for the Navigation Bar. The top one has the back button arrow and no styling and the second has the title with styling. I want the back button arrow and the title on a single line of Navigation Bar. I have tried all combinations, but am not able to make it happen.

  2. The titles on the Navigation Base do not center, no matter what property I give ! Where am I going wrong ?

Following is image from the Android Emulator:

image

@abhaychitnis abhaychitnis changed the title Double Line in Navigation Bar for nested StackedNavigation and Title does not center Double Line in Navigation Bar for nested StackedNavigation and Title does not center in 4.0.0 Jul 20, 2017
@diegocouto
Copy link
Contributor

Hi, @abhaychitnis! I've experienced something similar. Have you tried to add hideNavBar to your Scene with key main?

Regarding the title not being centered, I think that this is expected by Material design guidelines, but you can always change it with the titleStyle attribute. What if you tried this:

titleStyle: {
  color: 'white',
  fontWeight: 'bold',
  alignSelf: 'center',
}

@abhaychitnis
Copy link
Author

@diegocouto

The alignSelf did work ! Thanks !

However if I add hideNavBar to 'main' screen, it will hide the top line in the navigation bar. Which means I do not get the back functionality. So the issue remains open......

@ghost
Copy link

ghost commented Jul 21, 2017

I see the same thing, but what i noticed when messing with their example is that is you send the navTransparent prop it fixes the problem and you can have the back button show without the navebar... however, I cant get the navTransparent prop to work outside their example js file..... not sure why

@diegocouto
Copy link
Contributor

That's good news, @abhaychitnis!

To show the back button, maybe you could add the back prop to the OpenJobs scene... but I've never tried it. 😂

@abhaychitnis
Copy link
Author

Nope that did not work. Interesting though after adding the back prop, the title of the screen shifted to the right little bit. Now the screen looks like,

image

@abhaychitnis
Copy link
Author

@Paloman If I add navTransparent instead of hideNavBar to 'main' screen, I do get both the title and back button on a single row. However now the screen looks like this !!!!

image

@diegocouto
Copy link
Contributor

@abhaychitnis, well... that's odd. If you try to touch where there should be the back button, does anything happen?

Off the top of my head, I'd guess that:

  1. The button is right there, but it has the same tint color than the background;
  2. You're using a outdated version of the RNRF, where the button wouldn't show on android (try to update to beta12).

@abhaychitnis
Copy link
Author

abhaychitnis commented Jul 21, 2017

Yup ! That worked. I updated the version to beta12. The screen now looks like,

image
I will work on styling a little bit more...
@diegocouto rocks ! Thanks you !

@abhaychitnis
Copy link
Author

abhaychitnis commented Jul 21, 2017 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

2 participants