Skip to content

Commit f2b93ae

Browse files
committed
Merge pull request #25 from charpeni/issue-12
Add Material design style
2 parents fd2ec7f + 5145255 commit f2b93ae

File tree

5 files changed

+36
-20
lines changed

5 files changed

+36
-20
lines changed

components/NavBarContainer.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { StyleSheet, View, PropTypes, Platform, BackAndroid } from 'react-native';
22

33
import NavBarContent from './NavBarContent';
4+
import * as Styles from '../styles';
45

56
const propTypes = {
67
backButtonComponent: PropTypes.func,
@@ -39,14 +40,14 @@ class NavBarContainer extends React.Component {
3940
top: 0,
4041
left: 0,
4142
right: 0,
42-
height: 64,
43+
height: Styles.NAV_BAR_HEIGHT,
4344
},
4445
navbarContainerHidden: {
4546
position: 'absolute',
46-
top: -64,
47+
top: -Styles.NAV_BAR_HEIGHT,
4748
left: 0,
4849
right: 0,
49-
height: 64,
50+
height: Styles.NAV_BAR_HEIGHT,
5051
},
5152
});
5253
}

components/NavBarContent.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { StyleSheet, Text, View, Animated, Easing, PropTypes } from 'react-native';
22
import NavButton from './NavButton';
3+
import * as Styles from '../styles';
34

45
const propTypes = {
56
backButtonComponent: PropTypes.func,
@@ -35,19 +36,20 @@ class NavBarContent extends React.Component {
3536
top: 0,
3637
left: 0,
3738
right: 0,
38-
height: 64, // Default iOS navbar height
39+
height: Styles.NAV_BAR_HEIGHT,
3940
justifyContent: 'center',
4041
alignItems: 'center',
4142
flexDirection: 'row',
42-
paddingTop: 13,
43+
paddingTop: Styles.NAV_BAR_PADDING_TOP,
4344
},
4445
navbarText: {
4546
color: 'white',
4647
fontSize: 17,
4748
margin: 10,
48-
marginTop: 14,
49+
marginTop: Styles.NAV_BAR_TEXT_MARGIN_TOP,
50+
marginBottom: Styles.NAV_BAR_TEXT_MARGIN_TOP,
4951
fontWeight: '600',
50-
textAlign: 'center',
52+
textAlign: Styles.NAV_BAR_TEXT_ALIGN,
5153
alignItems: 'center',
5254
},
5355
corner: {
@@ -141,11 +143,13 @@ class NavBarContent extends React.Component {
141143
);
142144
}
143145

144-
leftCorner = (
145-
<View style={[this.styles.corner, this.styles.alignLeft]}>
146-
{leftCornerContent}
147-
</View>
148-
);
146+
if (this.props.route.leftCorner || this.props.route.index > 0) {
147+
leftCorner = (
148+
<View style={[this.styles.corner, this.styles.alignLeft]}>
149+
{leftCornerContent}
150+
</View>
151+
);
152+
}
149153

150154
/**
151155
* Set rightCorner
@@ -161,13 +165,13 @@ class NavBarContent extends React.Component {
161165
{...this.props.route.rightCornerProps}
162166
/>
163167
);
164-
}
165168

166-
rightCorner = (
167-
<View style={[this.styles.corner, this.styles.alignRight]}>
168-
{rightCornerContent}
169-
</View>
170-
);
169+
rightCorner = (
170+
<View style={[this.styles.corner, this.styles.alignRight]}>
171+
{rightCornerContent}
172+
</View>
173+
);
174+
}
171175

172176
/**
173177
* Set title message
@@ -185,7 +189,7 @@ class NavBarContent extends React.Component {
185189
}
186190

187191
titleComponent = (
188-
<View style={{ flex: 3 }}>
192+
<View style={{ flex: 6 }}>
189193
{titleContent}
190194
</View>
191195
);

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import React, {
99
import { EventEmitter } from 'fbemitter';
1010

1111
import NavBarContainer from './components/NavBarContainer';
12+
import * as Styles from './styles';
1213

1314
const propTypes = {
1415
backButtonComponent: PropTypes.func,
@@ -156,7 +157,7 @@ class Router extends React.Component {
156157
} else if (this.props.hideNavigationBar || route.hideNavigationBar) {
157158
margin = this.props.noStatusBar ? 0 : 20;
158159
} else {
159-
margin = 64;
160+
margin = Styles.NAV_BAR_HEIGHT;
160161
}
161162

162163
return (

styles.android.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const NAV_BAR_HEIGHT = 56;
2+
export const NAV_BAR_TEXT_ALIGN = 'left';
3+
export const NAV_BAR_TEXT_MARGIN_TOP = 0;
4+
export const NAV_BAR_TEXT_MARGIN_BOTTOM = 20;
5+
export const NAV_BAR_PADDING_TOP = 0;

styles.ios.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const NAV_BAR_HEIGHT = 64;
2+
export const NAV_BAR_TEXT_ALIGN = 'center';
3+
export const NAV_BAR_TEXT_MARGIN_TOP = 14;
4+
export const NAV_BAR_TEXT_MARGIN_BOTTOM = 0;
5+
export const NAV_BAR_PADDING_TOP = 13;

0 commit comments

Comments
 (0)