Skip to content

Instantly share code, notes, and snippets.

@rt2zz
Last active March 23, 2016 01:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rt2zz/bedd70a4ee2d2ee2be74 to your computer and use it in GitHub Desktop.
Save rt2zz/bedd70a4ee2d2ee2be74 to your computer and use it in GitHub Desktop.
<NavBar
left=((routeProps, nextProps) => { return string or component })
middle={<SomeComponent />}
right='string'
otherPropsDoOtherThings
/>
// navbar can be specified per route declaratively in the corresponding routeDictionary
{
testdrive: {
Component: Testdrive,
navbar: {
left: (routeProps, prevRouteProps) => prevRouteProps.title // can be function of props & routeStack
left: 'Active Drive' // or string
left: <SomeComponent /> // or component
middle: // ... same thing
right: // ... same thing
underlay: <UnderlayComponent />
overlay: <OverlayComponent />
}
}
}
// @IMPLEMENTATION this will passed along to the navbar via context too, but it will be standardized and abstracted away in the app navigator
// navbar can be imperatively set / overrode via context
// this is a little automagical, but also allows for unlimited flexibility including changing route title within one route (e.g. intentBuilder)
class SomeScene extends Component {
componentWillMount() {
this.context.navbar.set({
left,
middle,
right,
//...
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment