Skip to content

Commit fc7bd48

Browse files
committed
Update NavBarContainer.js
Added support for hiding navbar per route Style improvements
1 parent 0c9d26c commit fc7bd48

File tree

1 file changed

+61
-21
lines changed

1 file changed

+61
-21
lines changed

components/NavBarContainer.js

Lines changed: 61 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ var {
99
View
1010
} = React;
1111

12-
1312
var NavBarContainer = React.createClass({
1413

1514
getInitialState: function() {
@@ -41,22 +40,51 @@ var NavBarContainer = React.createClass({
4140

4241
// We render both the current and the previous navbar (for animation)
4342
render: function() {
44-
if(this.props.currentRoute.trans === true)
45-
var trans = {backgroundColor: 'transparent'}
46-
else
47-
var trans = {}
43+
var trans,
44+
navbarStyle,
45+
navbarContent;
4846

49-
return (
50-
<View style={[styles.navbarContainer, this.props.style, trans]}>
51-
{this.props.currentRoute.trans
52-
?( <View /> )
53-
:( <NavBarContent
54-
route={this.state.previousRoute}
55-
backButtonComponent={this.props.backButtonComponent}
56-
rightCorner={this.props.rightCorner}
57-
titleStyle={this.props.titleStyle}
58-
willDisappear="true" /> )
59-
}
47+
if (this.props.currentRoute.trans) {
48+
trans = {backgroundColor: 'transparent'};
49+
}
50+
else {
51+
trans = {};
52+
}
53+
54+
if (this.props.currentRoute.hideNavigationBar) {
55+
navbarStyle = styles.navbarContainerHidden;
56+
} else {
57+
navbarStyle = styles.navbarContainer;
58+
}
59+
60+
if(this.props.currentRoute.trans) {
61+
navbarContent = (
62+
<NavBarContent
63+
route={this.state.previousRoute}
64+
backButtonComponent={this.props.backButtonComponent}
65+
rightCorner={this.props.rightCorner}
66+
titleStyle={this.props.titleStyle}
67+
willDisappear="true"></NavBarContent>
68+
);
69+
} else if (this.props.currentRoute.hideNavigationBar) {
70+
navbarContent = (
71+
<NavBarContent
72+
route={this.props.currentRoute}
73+
backButtonComponent={this.props.backButtonComponent}
74+
rightCorner={this.props.rightCorner}
75+
titleStyle={this.props.titleStyle}
76+
borderBottomWidth={this.props.borderBottomWidth}
77+
borderColor={this.props.borderColor}
78+
goBack={this.goBack}
79+
goForward={this.goForward}
80+
leftProps={this.props.leftProps}
81+
rightProps={this.props.rightProps}
82+
titleProps={this.props.titleProps}
83+
customAction={this.customAction}>
84+
</NavBarContent>
85+
);
86+
} else {
87+
navbarContent = (
6088
<NavBarContent
6189
route={this.props.currentRoute}
6290
backButtonComponent={this.props.backButtonComponent}
@@ -69,22 +97,34 @@ var NavBarContainer = React.createClass({
6997
leftProps={this.props.leftProps}
7098
rightProps={this.props.rightProps}
7199
titleProps={this.props.titleProps}
72-
customAction={this.customAction}
73-
/>
74-
</View> )
100+
customAction={this.customAction}>
101+
</NavBarContent>
102+
);
103+
}
104+
105+
return (
106+
<View style={[navbarStyle, this.props.style, trans]}>
107+
{navbarContent}
108+
</View>
109+
);
75110
}
76111
});
77112

78-
79113
var styles = StyleSheet.create({
80114
navbarContainer: {
81115
position: 'absolute',
82116
top: 0,
83117
left: 0,
84118
right: 0,
85119
height: 64
120+
},
121+
navbarContainerHidden: {
122+
position: 'absolute',
123+
top: -64,
124+
left: 0,
125+
right: 0,
126+
height: 64
86127
}
87128
});
88129

89-
90130
module.exports = NavBarContainer;

0 commit comments

Comments
 (0)