Giter VIP home page Giter VIP logo

Comments (7)

chrissm79 avatar chrissm79 commented on April 19, 2024 1

It would be nice if DrawerNavigator rendered a header that the drawer would render on top of (it currently doesn't seem to render a header at all), then we could do something like this:

const MainNavigator: any = DrawerNavigator({
  Dashboard: { screen: Scenes.Dashboard },
  Log: { screen: Scenes.Log },
}, {
  initialRouteName: 'Dashboard',
});

const PagesNavigator: any = StackNavigator({
  Login: { screen: Scenes.Login },
  Password: { screen: Scenes.Password },
}, {
  initialRouteName: 'Login',
});

const AppNavigator: any = StackNavigator({
  Drawer: { screen: MainNavigator },
  Pages: { screen: PagesNavigator },
}, {
  initialRouteName: 'Drawer',
  headerMode: 'none',
});

from react-navigation.

Steviey avatar Steviey commented on April 19, 2024

In the examples the drawer renders on top of everything.
I would prefer the drawer underneath a top bar as usual.

from react-navigation.

chrissm79 avatar chrissm79 commented on April 19, 2024

@Steviey You should be able to put the DrawerNavigator inside a StackNavigator (similar to my example). The StackNavigator will render a header and the drawer will render underneath it.

const MainNavigator = DrawerNavigator({
  Dashboard: { screen: Scenes.Dashboard },
  Log: { screen: Scenes.Log },
}, {
  initialRouteName: 'Dashboard',
});

const AppNavigator = StackNavigator({
  Main: { screen: MainNavigator },
}, {
  initialRouteName: 'Main',
});

from react-navigation.

Steviey avatar Steviey commented on April 19, 2024

I'm totally new to this project, only have seen the examples. During the last days I was busy to provide some install scripts. Could you provide boilerplate code to see it in action?

from react-navigation.

chrissm79 avatar chrissm79 commented on April 19, 2024

Okay, I've got an insanely ugly hack going here, but it does render a header for the DrawerNavigator which the DrawerLayout slides over top of. I created a custom navigator that renders a CardStack instead of DrawerScreen (I did this because the CardStack renders the Header component which is not currently exported by react-navigation).

However, the CardStack does a SlideFromRightIOS which looks really odd when switching between Drawer Items. Does anyone know how I could override the Transitioner returned by the CardStack to do a cross fade instead?

from react-navigation.

nonameolsson avatar nonameolsson commented on April 19, 2024

This is just what I was looking for. @chrissm79 do you have any code we could try? :)

from react-navigation.

chrissm79 avatar chrissm79 commented on April 19, 2024

@nonameolsson I was able to get this to work by wrapping my Drawer screens with a StackNavigator like so:

const MainNavigator: any = DrawerNavigator({
  // I created a helper function to generate these single stack navigators 
  // to reduce boilerplate but this is what it produced
  Dashboard: { 
    screen: StackNavigator({ 
      Index: { screen: Scenes.Dashboard } 
    }) 
  },
  Log: { 
    screen: StackNavigator({ 
      Index: { screen: Scenes.Log } 
    }) 
  },
}, {
  initialRouteName: 'Dashboard',
});

const PagesNavigator: any = StackNavigator({
  Login: { screen: Scenes.Login },
  Password: { screen: Scenes.Password },
}, {
  initialRouteName: 'Login',
});

const AppNavigator: any = StackNavigator({
  Drawer: { screen: MainNavigator },
  Pages: { screen: PagesNavigator },
}, {
  initialRouteName: 'Drawer',
  headerMode: 'none',
});

I did, however, have some weird flickering when changing routes, and I had some issues with trying to navigate out of a nested view (in this example, going from the nested Log screen to the Password screen) so for the time being I went back to ex-navigation but I'm sure I'll be back soon :-)

from react-navigation.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.