Skip to content

Commit dbf6e03

Browse files
Merge pull request #34 from sethx/patch-6
Update NavBarContainer.js
2 parents d83f25d + a1db68f commit dbf6e03

File tree

1 file changed

+60
-21
lines changed

1 file changed

+60
-21
lines changed

components/NavBarContainer.js

Lines changed: 60 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,50 @@ 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;
46+
47+
if (this.props.currentRoute.trans) {
48+
trans = {backgroundColor: 'transparent'};
49+
} else {
50+
trans = {};
51+
}
4852

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-
}
53+
if (this.props.currentRoute.hideNavigationBar) {
54+
navbarStyle = styles.navbarContainerHidden;
55+
} else {
56+
navbarStyle = styles.navbarContainer;
57+
}
58+
59+
if(this.props.currentRoute.trans) {
60+
navbarContent = (
61+
<NavBarContent
62+
route={this.state.previousRoute}
63+
backButtonComponent={this.props.backButtonComponent}
64+
rightCorner={this.props.rightCorner}
65+
titleStyle={this.props.titleStyle}
66+
willDisappear="true"></NavBarContent>
67+
);
68+
} else if (this.props.currentRoute.hideNavigationBar) {
69+
navbarContent = (
70+
<NavBarContent
71+
route={this.props.currentRoute}
72+
backButtonComponent={this.props.backButtonComponent}
73+
rightCorner={this.props.rightCorner}
74+
titleStyle={this.props.titleStyle}
75+
borderBottomWidth={this.props.borderBottomWidth}
76+
borderColor={this.props.borderColor}
77+
goBack={this.goBack}
78+
goForward={this.goForward}
79+
leftProps={this.props.leftProps}
80+
rightProps={this.props.rightProps}
81+
titleProps={this.props.titleProps}
82+
customAction={this.customAction}>
83+
</NavBarContent>
84+
);
85+
} else {
86+
navbarContent = (
6087
<NavBarContent
6188
route={this.props.currentRoute}
6289
backButtonComponent={this.props.backButtonComponent}
@@ -69,22 +96,34 @@ var NavBarContainer = React.createClass({
6996
leftProps={this.props.leftProps}
7097
rightProps={this.props.rightProps}
7198
titleProps={this.props.titleProps}
72-
customAction={this.customAction}
73-
/>
74-
</View> )
99+
customAction={this.customAction}>
100+
</NavBarContent>
101+
);
102+
}
103+
104+
return (
105+
<View style={[navbarStyle, this.props.style, trans]}>
106+
{navbarContent}
107+
</View>
108+
);
75109
}
76110
});
77111

78-
79112
var styles = StyleSheet.create({
80113
navbarContainer: {
81114
position: 'absolute',
82115
top: 0,
83116
left: 0,
84117
right: 0,
85118
height: 64
119+
},
120+
navbarContainerHidden: {
121+
position: 'absolute',
122+
top: -64,
123+
left: 0,
124+
right: 0,
125+
height: 64
86126
}
87127
});
88128

89-
90129
module.exports = NavBarContainer;

0 commit comments

Comments
 (0)