Skip to content

Commit

Permalink
add customization of navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavlo Aksonov committed Feb 29, 2016
1 parent 662001d commit 36ffa9a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 34 deletions.
37 changes: 5 additions & 32 deletions ExRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,30 +167,19 @@ class ExNavigationBar extends Navigator.NavigationBar {
}
render(){
const route = this.props.router.nextRoute || this.props.router.currentRoute;
if (route.props.hideNavBar === false){
return super.render();
}
if (this.props.router.props.hideNavBar || route.props.hideNavBar){
return null;
}
return super.render();
}
}
class ExNavigatorBar extends React.Component {
render(){
const route = this.props.router.nextRoute || this.props.router.currentRoute;
const renderNavBar = (route.component && route.component.renderNavigationBar) || route.renderNavigationBar || this.props.renderNavigationBar || (props=><Navigator.NavigationBar {...props}/>);
const navBar = renderNavBar(this.props);
const renderNavBar = (route.component && route.component.renderNavigationBar) || route.renderNavigationBar || this.props.renderNavigationBar;
let res = renderNavBar ? renderNavBar(this.props) : super.render();

if (route.props.hideNavBar === false){
return navBar;
return res;
}
if (this.props.router.props.hideNavBar || route.props.hideNavBar){
return null;
}
return navBar;
return res;
}
}

export default class ExRouter extends React.Component {
router: BaseRouter;

Expand Down Expand Up @@ -301,22 +290,6 @@ export default class ExRouter extends React.Component {
this.refs.actionsheet.showActionSheetWithOptions({...route.props, ...props}, props.callback);
}

_renderNavigationBar(props){
const route = this.props.router.nextRoute || this.props.router.currentRoute;
console.log("ROUTE:"+route.name);
const renderNavBar = (route.component && route.component.renderNavigationBar) || route.renderNavigationBar || this.props.renderNavigationBar || (props=><Navigator.NavigationBar {...props}/>);
const navBar = renderNavBar(props);

if (route.props.hideNavBar === false){
return navBar;
}
if (this.props.router.props.hideNavBar || route.props.hideNavBar){
return null;
}
return navBar;

}

render() {
const router = this.props.router;
if (!router){
Expand Down
2 changes: 1 addition & 1 deletion Example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"dependencies": {
"react-native": "^0.20.0",
"react-native-button": "^1.2.1",
"react-native-router-flux": "^2.3.7",
"react-native-router-flux": "^2.3.8",
"react-native-modalbox": "^1.3.0",
"react-redux": "^4.4.0",
"redux": "^3.3.1"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-router-flux",
"version": "2.3.7",
"version": "2.3.8",
"description": "React Native Router using Flux architecture",
"repository": {
"type": "git",
Expand Down

0 comments on commit 36ffa9a

Please sign in to comment.